Skip to content

Commit

Permalink
Resolve regression from introduction of AER::Config (Qiskit#1747)
Browse files Browse the repository at this point in the history
This commit reduces redundant copy in `AER::Transpile::CircuitOptimization`.
Since 0.12.0, configuration is `AER::Config` instead of `json_t`. This new class
has many fields and then its copy overheads become high. Reduction of
redundant copy improves performance especially for low-qubit simulation.
  • Loading branch information
hhorii committed Apr 20, 2023
1 parent 5c72c81 commit 13f2a6c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 8 additions & 0 deletions releasenotes/notes/avoid_copy_of_config-7f7891864c1a1bd0.yaml
Original file line number Diff line number Diff line change
@@ -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``.
5 changes: 1 addition & 4 deletions src/transpile/circuitopt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/transpile/fusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ void Fusion::set_config(const Config &config) {
threshold = config.fusion_threshold.value();

for (std::shared_ptr<Fuser> &fuser : fusers)
fuser->set_config(config_);
fuser->set_config(config);

if (config.fusion_allow_kraus.has_value())
allow_kraus = config.fusion_allow_kraus.value();
Expand Down

0 comments on commit 13f2a6c

Please sign in to comment.