From 41e23fa7f019a19c442c8c696c055d5eb7390dfd Mon Sep 17 00:00:00 2001 From: Hiroshi Horii Date: Wed, 19 Apr 2023 12:25:41 +0900 Subject: [PATCH 1/3] avoid copy of config in AER::Transpile::CircuitOptimization --- src/transpile/circuitopt.hpp | 5 +---- src/transpile/fusion.hpp | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/transpile/circuitopt.hpp b/src/transpile/circuitopt.hpp index 82c04cbb08..6a02e21a9e 100644 --- a/src/transpile/circuitopt.hpp +++ b/src/transpile/circuitopt.hpp @@ -40,14 +40,11 @@ class CircuitOptimization { const Operations::OpSet &opset, ExperimentResult &result) const = 0; - virtual void set_config(const Config &config); + virtual void set_config(const Config &config) {}; protected: - Config config_; }; -void CircuitOptimization::set_config(const Config &config) { config_ = config; } - //------------------------------------------------------------------------- } // end namespace Transpile } // end namespace AER diff --git a/src/transpile/fusion.hpp b/src/transpile/fusion.hpp index 59c8bf3cfc..d7c14ec8b6 100644 --- a/src/transpile/fusion.hpp +++ b/src/transpile/fusion.hpp @@ -791,7 +791,7 @@ void Fusion::set_config(const Config &config) { threshold = config.fusion_threshold.value(); for (std::shared_ptr &fuser : fusers) - fuser->set_config(config_); + fuser->set_config(config); if (config.fusion_allow_kraus.has_value()) allow_kraus = config.fusion_allow_kraus.value(); From 9422607ee10a62ff80e64cbcd4cfb33f798d2ae3 Mon Sep 17 00:00:00 2001 From: Hiroshi Horii Date: Wed, 19 Apr 2023 12:40:39 +0900 Subject: [PATCH 2/3] add reno --- .../notes/avoid_copy_of_config-7f7891864c1a1bd0.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 releasenotes/notes/avoid_copy_of_config-7f7891864c1a1bd0.yaml diff --git a/releasenotes/notes/avoid_copy_of_config-7f7891864c1a1bd0.yaml b/releasenotes/notes/avoid_copy_of_config-7f7891864c1a1bd0.yaml new file mode 100644 index 0000000000..b426e1da74 --- /dev/null +++ b/releasenotes/notes/avoid_copy_of_config-7f7891864c1a1bd0.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Performance regression due to introduction of ``AER::Config`` is fixed. + This class has many fields but is frequently copied in ``AER::Transpile::CircuitOptimization``. + Originally ``json_t`` (former class for configuration) was also frequently copied but + it does have entries in most cases and then this copy overhead is not a problem. + With this fix, ``AER::Transpile::CircuitOptimization`` does not copy ``AER::Config``. From b1bf0a03b3d72f7cf269a6e1f26f98b4d3b2a6c1 Mon Sep 17 00:00:00 2001 From: Hiroshi Horii Date: Wed, 19 Apr 2023 12:41:49 +0900 Subject: [PATCH 3/3] apply clangformat --- src/transpile/circuitopt.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transpile/circuitopt.hpp b/src/transpile/circuitopt.hpp index 6a02e21a9e..537aaa8e98 100644 --- a/src/transpile/circuitopt.hpp +++ b/src/transpile/circuitopt.hpp @@ -40,7 +40,7 @@ class CircuitOptimization { const Operations::OpSet &opset, ExperimentResult &result) const = 0; - virtual void set_config(const Config &config) {}; + virtual void set_config(const Config &config){}; protected: };