merge conflict resolution for "consistent gate naming"#2
Merged
Cryoris merged 13 commits intoFeb 19, 2020
Merged
Conversation
* Fixup documentation formatting in qiskit.pulse.reschedule where verbatim formatting was not properly closed * Update qiskit/pulse/reschedule.py Co-Authored-By: SooluThomas <soolu.elto@gmail.com> * Update qiskit/pulse/reschedule.py Co-authored-by: SooluThomas <soolu.elto@gmail.com>
* Docathon: Update the documentation TOC, cmd_def module docstring, and InstructionScheduleMap docstrings * Small fixups * Better rst formatting in docstring * Add cross referencing to the docstrings * Apply suggestions from code review Use tilde to prevent the whole path from showing :D Co-Authored-By: Daniel Puzzuoli <dan.puzzuoli@gmail.com> * Style: line length Co-authored-by: Daniel Puzzuoli <dan.puzzuoli@gmail.com>
* fix multiple += qc * add test * use timeout as test failure - patching _append might not catch future implementations where += is done differently - also other tests with timeout already exist - this is cleaner than before * remove accidentially tracked file * remove unused import * add reno * test circuit ops after extension Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
* Single Qubit Transition Visualization Animation This new feature helps visualize what exactly happens to a qubit after applying a sequence of gates. Can be called with visualize_transition(['X','Y','S','T']). Additional arguments are jupyter=bool which decides whether HTML video will be returned in case this function was called from jupyter notebook (as jupyter can't handle interactive tkinter GUI plots). If jupyter=False, it is assumed that the function was called from non-jupyter source and interactive tkinter GUI will be shown. Another argument is saveas=str which, if defined, will tell the function to save the animation as a video file on the system, for example "movie.mp4". It should be noted that encoding the animation into a video (jupyter=True or saveas!=None) takes significant CPU time and any tests * Used wrong function name in release file example, it's good now. * Slowed down animation by half * Linting errors corrected * Support for py35 string formatting * Another string formatting error for py35 fixed * MacOS import error of matplotlib fixed * visualize_transition now takes QuantumCircuit as its argument. Finer control over performance tuning with fpg and spg optional arguments. * Update qiskit/visualization/transition_visualization.py * The decision whether to use HTML GUI or tkinter GUI is decided automatically without user. Traces are no longer arrows, they are points on bloch sphere and they remain on the sphere. Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
* Skip TestJupyter tests if ibmq provider is not installed The tests in test.python.tools.jupyter.TestJupyter rely on the ibmq provider for the execution of the notebooks. However we don't require the local installation (or the configuration) of the provider for running tests anywhere else. In cases where someone is missing either ibmq or credentials the tests (of which only test_jupyter_jobs_pbars) in the class will fail because they can't import qiskit.IBMQ. This commit addresses this issue by adding a skip to the class on hasattr(qiskit, 'IBMQ') so that if the ibmq provider is not installed the tests will all skip. * Disable broken lint rule Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* adding math functions to doc strings in discrete.py, and messing with sphinx table of contents * further work on function documentation * completed another pass of discrete.py fixing sphinx issues * Updated pulse.rst and pulse/__init__.py to include docs correctly as per @SooluThomas' solution * reshuffling sphinx toc stuff * de-indented the second two lines in citation to avoid the 'header' style appearance in the docs. Will need to revisit this once handling of citations is sorted * Update qiskit/pulse/pulse_lib/discrete.py Co-Authored-By: Thomas Alexander <thomasalexander2718@gmail.com> * Update qiskit/pulse/pulse_lib/discrete.py Co-Authored-By: Thomas Alexander <thomasalexander2718@gmail.com> * Update qiskit/pulse/pulse_lib/discrete.py Co-Authored-By: SooluThomas <soolu.elto@gmail.com> * re-adding doc string to pulse_lib/__init__.py * fixed one more error in the drag function- mathematical description did not include beta * Update qiskit/pulse/__init__.py Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com> * Update qiskit/pulse/pulse_lib/discrete.py Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com> * Update qiskit/pulse/pulse_lib/discrete.py Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com> Co-authored-by: Thomas Alexander <thomasalexander2718@gmail.com> Co-authored-by: SooluThomas <soolu.elto@gmail.com> Co-authored-by: Lauren Capelluto <laurencapelluto@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Update the pulse module init file for documentation. This includes adding autosummary references to important parts of the module that were previously unreachable, removing references to pieces that are mostly internal usage, and providing introductary summaries where appropriate * Apply suggestions from code review Helpful feedback from Dan, including more API cross referencing 🎉 Co-Authored-By: Daniel Puzzuoli <dan.puzzuoli@gmail.com> * Small fixups * Another attempt to make linking work Co-authored-by: Daniel Puzzuoli <dan.puzzuoli@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Remove the buffer options in Schedule, Instruction and ScheduleComponent which has been deprecated since 0.11.0. Update Schedule docstrings with minor formatting improvements, rst formatting directives, minor wording improvements. Update the pulse __init__ file to show Instruction near Schedule * style * style * Update other release note that already mentions buffer * Improve the formatting of the math/psuedocode in Schedule.append * Apply suggestions from code review Incorporate feedback from Dan Co-Authored-By: Daniel Puzzuoli <dan.puzzuoli@gmail.com> * Add a few more verbatim instances and fixup some spacing in docstrings. * Release note improvement Co-authored-by: Daniel Puzzuoli <dan.puzzuoli@gmail.com>
Right now the jsonschema validation errors are next to useless because of how the schemas files our constructed. The schemas are built in away that tries to constrict too much of the structure that uses oneOf in multiple levels of the schema. These oneOf's make the schema much more difficult to debug because any rule that fails in the subschema below those will not actually be what fails validation, but instead it will be the oneOf lines because none of the elements in the list of valid subschemas passed validation. This becomes very problematic for debugging things that get jsonschema validated, especially with our current error message structure. The current error message prints the entire error message from jsonschema to either the exception message if it's less than 1000 characters (which it rarely is) or as a debug log message to python logging if it's more than 1000 characters. These messsages are not very useful since the contain most of the schema as the rule that failed (which is why it's often over 1000 characters) because of the use of oneOf checks. This commit changes our error reporting to try and be a bit more useful. It leverages the best_match [1] feature from jsonschema to use a heuristic to try and figure out what actually caused the validation failure instead of just blindly saying it was the whole schema. In local testing this often gets the right spot on the input dictionary while not necessarily the exact rule. For example, if you passed an instruction for a qasm experiment missing a qubits field it says the name field was invalid for that instruction. While not exact this is a much closer hint for debugging. The error messages are adjusted to use the best match path to point to the element (not the specific field) that failed validation, and then print the error message from best match and saying it's possibly the error. This should make it easier to find errors in qobj dictionary that isn't passing schema validation. It's not always perfect, but something more targetted should hopefully be better than everything, which is the status quo. A follow-up here will be to try and rewrite the schema to not rely on so many high level oneOf rules. This will likely result in relaxing the schema slightly so validation won't catch high level errors (like sending both a qasm configuration and a pulse configuration at the same time). But, those errors should be next to non-existent and are not really the class of errors we should be trying to validate with schema anyway. Especially for qiskit where the qobj dictionaries are being generated and we don't have to worry about such cases. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* add ability specify open controls. This PR adds the ability to control on '0' qubit states. * add release notes * expected blank space * allow string control state specification. * linting * linting * remove f-string * add ctrl_state keyword to standard extensions * fix comments. add ctrl_state attribute to ControlledGate. * add ctrl_state and test of open controlled unitary matrix generation * minor bug fixes * linting * linting Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Cryoris
pushed a commit
that referenced
this pull request
Mar 29, 2020
implement BasisTransformationMeasurement
Cryoris
pushed a commit
that referenced
this pull request
Sep 28, 2020
* Enable zero rep delay * Add backend fix Co-authored-by: Luciano Bello <luciano.bello@ibm.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Cryoris
added a commit
that referenced
this pull request
Dec 16, 2020
Cryoris
added a commit
that referenced
this pull request
Jan 14, 2021
* ae codes * add tests * update docstrings in result objects * add reno * fix old aqua dependencies * fix cyclic imports * try fixing windows tests no. 1 * fix test * try fixing windows attempt #2 * stefan's first comments * accumulate -> evaluate in AE * prob to meas 1 -> prob good state * stefans comments pt. 2 * fix lint & indent * add faster ae + bernoulli tests * fix > 1 qubit case * add comments * add FAE specific tests * raise error for rescale on custom q operator * play with the oracles * fix classicalregister > 1 * use correct reflection and rm X gates around oracle * fix construction of rescaled est. problem * fix phase in grover op * adjust result objects * adjust fae result object * fix minus sign and lint * rm trailing whitespaces * fix tests * fix lint * rm utf8 header * move rescale to problem, add evalschedule to MLAE * code review suggestions * state and obj.qubits not optional in estimation problem * add QAE algos to documentation * allow setting post processing and is good state to None to use default * rm quantum instance logic from interface * fix typehints for is good state * add Faster AE to reno * reset shots to user defined shots in FAE * fix doc build (hopefully) * add result classes to docs * make grover op optional in setter * rm reno -- there will be a global one Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Cryoris
pushed a commit
that referenced
this pull request
Jan 17, 2021
Allow any Qiskit gate as basis gates & cleanup
Cryoris
added a commit
that referenced
this pull request
Mar 2, 2021
* change unique list to MappingView * fix test * start adding tests * handle anonymous parameter assigment * fix bind_parameters * fix compose * add reno, remove todos * fix docstring * fix inconsistent argname * fix renaming gone wrong * changes from code review * use deprecate_arguments * add deprecation section in reno * add more tests * fix naming in reno * make compose(front) more efficient * update paramtables in compose w/o iterating over all gates * properly rebuild parameterable upon compose * use params instead of param_dict * fix __new__ * fix sorting * fix tests * fix parameter order in test * Apply suggestions from code review Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * rename params->parameters, update reno * add tests, remove access table by index * use ListEqual over Equal * rm unused islice import * Rm star-swallowers from bind/assign_parameters * store parent instance instead of just name * fix name `params` -> `parameters` * fix typo * fix typo #2 * add test for pickling paramvecelements Co-authored-by: Erick Winston <ewinston@us.ibm.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Cryoris
added a commit
that referenced
this pull request
Mar 25, 2021
* Add PhaseEstimator and related classes * Fix linter complaints * Update qiskit/algorithms/phase_estimators/hamiltonian_phase_estimation.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Fix indentation in doc string * Fix more indentation in doc string * Comment on reasons for removing identity term from Hamiltonian * Replace mistaken description "water" by "H2" * Add default phase shift of 0.0 for identity term * Remove function call from default arg Replace default arg with None, and then set the desired default in the body of the function. * Refactor _run and rename to _result Move all common code out of _run for HamiltonianPhaseEstimation and PhaseEstimation, and rename _run to _result, because it only creates the result class. * Move some inputs and calculation to estimate method * Add cutoff to filter in test_from_bound * An unknown change in the past three weeks caused tests to fail with the default filter threshold of 0 (no filtering). I added a small cutoff so that the tests pass again. * Fix linter complaints * Fix linter complaints * Allow PauliSumOp as input Hamiltonian * Make suggested changes * Move module method to classmethod * Fix indentation * Refactor scale_phase scale_phases * Make HamiltonianPhaseEstimation have a hasa rather than isa use of PE * Remove all computation from PhaseEstimator * Remove ability to set number of computation qubits in PhaseEstimator.estimate() * update to current algorithm paradigm + small fixes * make algorithms stateless (store no problem information) * fix lint and docstrings * fix cyclic imports * Use PauliTrotterEvolution by default in HamiltonianPhaseEstimation * Make HamiltonianPhaseEstmation take a StateFn for state preparation * Add method most_likely_phase to HamiltonianPhaseEstimation * Allow PauliOp as input unitary to HPE * Allow MatrixOp as input Hermitian op to HPE * Fix linter complaints * fix evolution = None case * refactor tests slightly * be explicit about which evolution is used * combine tests using ddt * add some linebreaks * fix import order * Improve docstrings for PE and HPE * attempt to fix sphinx * attempt to fix sphinx #2 * attempt no. 3 to fix sphinx * layout, don't use function calls in defaults * trailing comma Co-authored-by: Julien Gacon <gaconju@gmail.com>
Cryoris
pushed a commit
that referenced
this pull request
Mar 30, 2022
…skit#6899) * added new equivalence rzx_zz4 * added another zz-ish template (looks for basis gates) * looking at adding additions to rzx templates * fixes parsing of Parameter name for sympy during template optimization * generalized fix for multiple parameters in an expression and constant parameters, removed some excess files from another branch * one more minor fix to bring inline with qiskit-terra main * trying to fix parameter parsing for template optimization * made sure floats were added correctly to (template) parameters * got template matching to work with floats, sympy still not understanding Parameters either in equations or symbols set in template_substitution.py * further modifications to accept circuit parameters for template optimization * debugging the binding of template parameters * realized I was not treating ParameterExpressions carefully and should lean on parse_expr from sympy to cast to symbols * converted all bindings to ParameterExpressions (via .assign()), set trace to fix template use with Parameters * cleaned up _attempt_bind routine * exploring overriding removing the matched scenarios with parameters * introduced a total hack for dealing with ParamterExpressions that contain floats for RXGates * (non-latex) parameters now currently working in template optimization transpilig step followed by parameter binding * cleaned up some whitespace and removed commented-out lines * cleaned up some tox/lint errors * removed unneccessary Parameter import * bypassed unit test test_unbound_parameters() and re-tox/lint * fixed one last linting issue * fixed cyclic import error * modified calibration_creator to accept a ParameterExpression containing a float * fixed an mismatch when trying to add calibrations and addressed a conversation in the PR * last tox/lint checks i'm sure ;) * now params comes from node_op argument * handling error in case gate parameters is empty in dagcircuit.py * Fix template matching for parameters with LaTeX name. * added missing docstring * removed pdb set_trace * made changes requested in PR 6899 * made changes requested in PR 6899 #2 * remembered to tighten try/except handling * finished making changes requested in PR 6899 * fixed remaining linting issue * added comment about templates working for parameterized RZXGates and RXGates * Fix test unbound parameters * Check if matrix with Parameter is unitary * Fix merge issue * removed real=True in two symbol Symbol expressions, which was messing up the solver for some reason. * generalized to iterate over parameters, and removed reference to private member * modified .get_sympy_expr() to use symengine if possible * made the negation of the RXGate() much less verbose * working thru tox/lint checks * added unit test test_unbound_parameters_in_rzx_templates to confirm template optimization handles template optimization with unbound parameters correctly * Fix unbund parameters test * fixed issue with adding calibrations without params * Add real=True to symbols * fixed linting issue * Fix for symengine * simplified the parameter handling for adding calibrations to gates * added a check for unitary on an arbitrary float in the case symengine is imported (and fixed a couple minor bugs) * Parammeter can be complex * fixed tox/lint issues * removed one more imposition of real parameters * one last linting issue * modified release notes * fixed some transpiler library imports that were out of date * added sphinx referencing to release notes and print statement for the case of testing unbound parameters when creating a unitary gate * fixed some tox/lint issues * Fix review issues * fixing last tox/lint issues * added release notes and fixed tox/lint issues * added method in template_substitution to compare the number of parameters in circuit with the that of the template that would potentially replace it * fixing up some template matching unit tests * fixed up template matching unit tests to remove calls to UnitaryGate * Update qiskit/dagcircuit/dagcircuit.py Co-authored-by: Jake Lishman <jake@binhbar.com> * Update qiskit/extensions/unitary.py Co-authored-by: Jake Lishman <jake@binhbar.com> * Update qiskit/extensions/unitary.py Co-authored-by: Jake Lishman <jake@binhbar.com> * added template test with two parameters and new logic in the case there are duplicate parameters in the circuit and template * added two-parameter unit test and a check for overlapping parameters between circuits and templates * remove ParameterTypeeException from exceptions.py * Restore lazy symengine imports Use of `_optionals.HAS_SYMENGINE` is intended to be within run-time locations; putting it at the top level of a file causes this fairly heavy library to be imported at runtime, slowing down `import qiskit` for those who won't use that functionality. * Rename to_sympify_expression to sympify * Revert now-unnecessary changes to calibration builder * Fixup release note * Add explicit tests of template matching pass This adds several tests of the exact form produced by running the template-matching transpiler pass, including those with purely numeric circuits and those with symbolic parameters. * Fix template parameter substitution This fixes issues introduced recently in the PR that caused parameters to be incorrectly bound in the result. This meant that the actual numbers in the produced circuits were incorrect. This happened mostly by tracking data structures being updated at the wrong levels within loops. In addition, this commit also updates some data structures to more robust and efficient versions: - Testing whether a parameter has a clash is best done by constructing a set of parameters used in the input circuits, then testing directly on this, rather than stringifying expressions and using subsearch matches; this avoids problems if two parameters have contained names, or if more than one match is catenated into a single string. - Using a dictionary with a missing-element constructor to build the replacement parameters allows the looping logic to be simpler; the "build missing element" logic can be separated out to happen automatically. * Fix overlooked documentation comment * Remove qasm.pi import in favour of numpy * Add tests of multi-parameter instructions * Fix template matching with multiparameter expressions * Silence overzealous pylint warning Co-authored-by: Rafał Pracht <rpracht@wp.pl> Co-authored-by: Rafał Pracht <55279376+rafal-pracht@users.noreply.github.com> Co-authored-by: Jake Lishman <jake@binhbar.com> Co-authored-by: Jake Lishman <jake.lishman@ibm.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Cryoris
pushed a commit
that referenced
this pull request
Dec 14, 2022
Updates VarQRTE --> Fix Right Side Operator for SLE & Streamline Imaginary Part Integration
Cryoris
pushed a commit
that referenced
this pull request
Jul 26, 2024
…iskit#12292) * Initial: Add `Target` class to `_accelerate` - Add `Target` class to test mobility between Rust and Python. - Add `add_instruction` method to test compatibility with instructions. * Fix: Remove empty property check - Property check caused most cases to panic. - Will be commented out and restored at a later time. * Add: Instructions property - Instructions property returns all added to the target. - Similar behavior to source. * Chore: comments and deprecated methods - Add comments to instruction property. - Use new_bound for new PyDicts. * Chore: Remove redundant code - Remove redundant transformation of PyObject to PyTuple. - Remove debugging print statement. * Add: `InstructionProperties` class and type checkers - Add `InstructionProperties` class to process properties in rust. - Add `is_instance` and `is_class` to identify certain Python objects. - Modify logic of `add_instruction` to use class check. - Other tweaks and fixes. * Add: Setter and Getter for calibration in `InstructionProperty` * Add: `update_instruction_properties` to Target. * Add: Update_from_instruction_schedule_map - Partial addition from Target.py\ - Introduction of hashable qarg data structure. - Other tweaks and fixes. * Add: Complete `update_from_instruction_schedule_map1 - Complete missing procedures in function. - Rename `Qargs` to `HashableVec`. - Make `HashableVec` generic. - Separate `import_from_module_call` into call0 and call1. - Other tweaks and fixes. * Add: instruction_schedule_map property. - Remove stray print statements. - Other tweaks and fixes. * Fix: Key issue in `update_from_instruction_schedule_map` - Remove all unsafe unwraps * Fix: Use PyResult Value for void functon - Update `update_from_instruction_schedule_map to use PyResult and '?' operator. - Use Bound Python objects whenever possible. - Other tweaks and fixes. * Add: Python wrapping for Target - Add temporary _target module for testing. - Remove update_from_instruction_schedule_map function back to python. - Add python properties for all public attributes in rust - Other tweaks and fixes. * Add: `qargs` property - Add identical method `qargs` to obtain the qargs of a target. - Other tweaks and fixes. * Add: `qargs_for_operation_name` function. - Add function with identical behavior to the original in Target. - Other tweaks and fixes. * Add: durations method for Target - Add target module to qiskit init file. - Remove is_instance method. - Modify set_calibration method in InstructionProperty to leave typechecking to Python. - Change rust Target alias to Target2. - Other tweaks and fixes, * Add: InstructionProperties wrapper in python * Fix: InstructionProperties could not receive calibrations - Fix wrong setters/getters for calibration in InstructionProperty object in rust. * Add: more methods to Target in `target.rs` - Add FromPyObject trait to Hashable vec to receive Tuples and transform them directly into this type. - Add operations_for_qargs for Target class in Rust side and Python. - Fix return dict keys for `qargs_for_operation_name`. - Add `timing_constrains` and `operation_from_name` to Python side. - Other tweaks and fixes. * Fix: missing return value in `operations_for_args` - Fix wrong name for function operation_for_qargs. - Fix missing return value in the python side. - Other tweaks and fixes. * Fix: Bad compatibility with InstructionProperties - Make `InstructionProperties` "_calibration" attribute visible. - Removed attribute "calibration", treat as class property. - Other tweaks and fixes * Add: `operation_names_for_qargs` to Target - Port class method to rust and connect to Python wrapper. - Other tweaks and fixes. * Add: instruction_supported method to rust and python: - Other tweaks and fixes. * Add: changes to add_instruction function to increase functionality. - These changes break current functionality of other functions, butemulate intended behavior better. - Fixes coming soon. * Fix: Backwards compatibility with `add_instruction` - Fixed wrong additions to HashMaps in the rust side causing instructions to be missing. - Other tweaks and fixes. * Fix: Gate Map behavior didn't match Qiskit#11422 - Make GateMap use optional values to match behavior of Qiskit#11422. - Define GateMapType for complex type in self.gate_map. - Throw Python KeyError exceptions from the rust side in `update_instruction_properties` and other functions. - Modify logic in subsequent functions that use gate_map optional values. - Other tweaks and fixes. * Add: `has_calibration` method to Target * Add: `get_calibraton` method to Target * Add: `instruction_properties` method to Target * Add: `build_coupling_map` and helper methods - `build_coupling_map`will remain in Python for now, along with its helper functions. - Make `gate_name_map` visible to python. - Add `coupling_graph` attribute to Target in Rust. - Other tweaks and fixes. * Add: `get_non_global_operation_names` to Target. - Add attributes `non_global_strict_basis` and `non_global_basis` as Optional. - Other tweaks and fixes. * Add: Missing properties - Add properties: operations, operation_names, and physical_qubits. - Reorganize properties placement. - Other tweaks and fixes. * Add: `from_configuration` classmethod to Target. - Add method that mimics the behavior of the python method. - Change concurrent_measurements to 2d Vec instead of a Vec of sets. - Other tweaks and fixes. * Add: Magic methods to Rust and Python - Add docstring to __init__. - Add __iter__, __getitem__, __len__, __contains__, keys, values, and items methods to rust. - Add equivalen methods to python + the __str__ method. - Make description an optional attribute in rust. - Other tweaks and fixes. * Fix: Bugs when fetching qargs or operations - Fix qarg_for_operation_name logic to account for None and throw correct exceptions. - Stringify description before sending in case of numerical descriptors. - Fix qarg to account for None entry. - Other tweaks and fixes. * Chore: Prepare for Draft PR - Remove _target.py testing file. - Fix incorrect initialization of calibration in InstructionProperties. - Other tweaks and fixes. * Fix: target not being recognized as a module - Add target to the pyext crate. - Change placement of target import for alphabetical ordering. - Other tweaks and fixes. * Fix: Change HashMap to IndexMap - Change from f32 to f64 precision. - Other tweaks and fixes. * Fix: Move InstructionProperties fully to Rust - Move InstructionProperties to rust. - Modify gate_map to accept an InstructionProprties object instead of PyObjecy. - Change update_instruction_properties to use Option InstructionProprtyird. - Remove InstructionProperties from target.py - Other tweaks and fixes. * Fix: Make Target inherit from Rust - Make Target inherit from the rust-side Target by using subclass attribute, then extending its functionality using python. - Switch from __init__ to __new__ to adapt to the Target rust class. - Modify every trait that worked with `target._Target` to use `super()` or `self` instead. - Fix repr in InstructionProperties to not show `Some()` when a value exists. - Fix `__str__` method in `Target` to not display "None" if no description is given. - Assume `num_qubits` is the first argument when an integer is provided as a first argument and nothing else is provided for second (Target initializer). - Return a set in operation_names instead of a Vec. - Other tweaks and fixes. * Fix: Recognize None in `operation_for_qargs`. - Fix module labels for each class in target.rs. - Use py.is_instance instead of passing isinstance to `instruction_supported`. - Modify `operations_for_qargs` to accept optional values less aggressively. Allow it to find instructions with no qargs. (NoneType). - Other tweaks and fixes. * Fix: Make InstructionProperties subclassable. - Fix get_non_global_operation_names to accept optional values and fix search set to use sorted values. - Fix __repr__ method in InstructionProperties to add punctuation. - Fix typo in python durations method. - Modify test to overload __new__ method instead of just __init__ (Possible breaking change). -Other tweaks and fixes. * Fix: errors in `instruction_properties` and others: - Allow `instruction_properties` method to view optional properties. - Allow `operation_names_for_qargs` to select class instructions when None is passed as a qarg. - Modify __str__ method to display error and duration times as int if the value is 0. - Other tweaks and fixes. * Fix: call `isclass` from rust, instead of passing it from Python. * Fix: Move `update_from_instruction_schedule_map` to rust. * Fix: Move `durations` to rust. * Fix: Move `timing_constraints` to rust * Fix: Move operations_from_name fully to rust * Fix: `instruction_supported` method: - Rewrite the logic of instruction_supported due to previous errors in the method. - Move `check_obj_params` to Rust. - Other tweaks and fixes. * Fix: errors in `from_configuration` class method. - Fix some of the logic when retrieving gates from `name_mapping`. - Remove function arguments in favor of implementing counterpart functions in rust. - Add qubit_props_list_from_props function and return rust datatypes. - Fix wrong error handling procedures when retrieving attributes from backend_property. - Other tweaks and fixes. * Fix: Import `InstructionScheduleMap` directly instead of passing. - `instruction_schedule_map()` now imports the classtype directly from rust instead of needing it to be passed from python. - Remove unused imports in `target.py`. - Ignore unused arguments in `test_extra_props_str`. - Other tweaks and fixes. * Docs: Add docstrings to rust functions - Remove redundant redefinitions in python. - Fix text_signatures for some rust functions. - Added lint exceptions to some necessary imports and function arguments. - Other tweaks and fixes. * Add: Make `Target` and `InstructionProperties` pickleable. - Add `__getstate__` and `__setstate__` methods to make both rust subclasses pickleable. * Fix: Wrong calibration assignment in __setstate__ - Use set_calibration to set the correct calibration argument. - Fix wrong signature in get_non_global_operation_names. - Other tweaks and fixes. * Refactor: HashableVec is now Qarg - Use `PhysicalQubit` instead of u32 for qargs. - Use a `SmallVec` of size 4 instead of a dynamic Vec. - Default to using the `Hash()` method embedded in `SmallVec`. - Add a Default method to easily unwrap Qarg objects. - Other tweaks and fixes. * Add: `get` function to target. - Remove some redundant cloning in code. - Other small fixes. * Fix: Remove unnecessary Optional values in gate_map. - Update every gate_map call to use the new format. - Other small tweaks and fixes. * Refactor: `calibration` is for `InstructionProperties` - Use python `None` instead of option to store `calibration` in `InstructionProperties`. - Adapt code to these changes. - Remove redundant implementation of Hash in Qargs. - Other tweaks and fixes. * Fix: Temporary speedup for `gate_map` access - Added temporary speedups to access the gate_map by returning the values as PyObjects. - Convert qargs to rust tuples instead of initializing a `PyTuple`. - Store `InstructionProperties` as a python ref in gate_map. (Will be changed in future updates). - Other tweaks anf fixes. * Fix: Incorrect extractions for `InstructionProperties` - Fix incorrect conversion of `InstructionProperties` to `Py<InstructionProperties>` - Fix incorrect extraction of qargs in `update_from_instruction_schedule_map` * Fix: Hide all private attributes in `Target` - Hide all private attributes of the `Target` to prevent unecessary cloning. - Other small tweaks and fixes. * Add: New representation of gate_map using new pyclasses: - Make Qarg a sequence pyclass. - Make QargPropsMap the new representation of a GateMap value. - Adapt the code to new structure. - TODO: Add missing magic methods for sequence and mapping objects. - Other small tweaks and fixes. * Add: Use custom datatypes to return values to Python. - Add QargSet datatype to return a set of qargs. - Works as return type for `Target.qargs` - Object is has itertype of QargSetIter. - Rename QargPropMap to PropsMap - Use iterator type IterPropsMap - Other small tweaks and fixes. * Fix: Extend `InstructionProperties` to be subclassable using `__init__: - Made a subclass of `InstructionProperties` that can be extended using an `__init__`method. - Revert previous changes to `test_target.py`. - Other tweaks and fixes. * Refactor: Split target into its own module - Reestructure the files to improve readability of code. - `instruction_properties.rs` contaisn the `InstructionProperties` class. - `mod.rs` contains the `Target` class. - `qargs.rs` contains the Qargs struct to store quantum arguments. - `property_map` contains the Qarg: Property Mapping that will be stored in the gate_map. - Add missing methods to PropsMap: - Add `PropsMapKeys` object to store the qargs as a set. - Add methods to compare and access `PropsMapKey`. - Add QargsOrTuple enum in Qargs to parse Qargs instantly. * Fix: Rest of failing tests in Target - Modify the `InstructionProperties` python wrapper. - InstructionProperties was not assigning properties to rust side. - Make duration in `InstructionProperties` setable. - Add `__eq__` method for `PropMap` to compare with other dicts. - `PropMapKeys` can only be compared with a Set. - Remove `qargs_for_operation_name` from `target.py` - Other small tweaks and fixes. * Add: New GateMap Structure - GateMap is now its own mapping object. - Add `__setstate__` and `__getstate__` methods for `PropMap` and `GateMap`. - Other small tweaks and fixes. * Fix: Make new subclasses pickleable - Add module location to `PropsMap`, `GateMap`, and `Qargs`. - Added default method to PropMap. - Made default method part of class initializers. - Other smalls tweaks and fixes. * Fix: Remove redundant lookup in Target (Qiskit#12373) * Format: `mod.rs` qubit_comparison to one line. * Add: `GateMapKeys` object in GateMap: - Use IndexSet as a base to preserve the insertion order. - Other tweaks and fixes. * Add: __sub__ method to GateMapKeys * Fix: Modify `GateMap` to store values in Python heap. - Fix `GateMap.__iter__` to use an IndexKeys iterator. - Other small tweaks and fixes. * Fix: Remove duplicate import of `IndexSet::into_iter` in `GateMap`. - Make `__iter__` use the keys() method in `GateMap`. * Fix:: Adapt to target changes (Qiskit#12288) - Fix lint stray imports. * Fix: Incorrect creation of parameters in `update_from_instruction_schedule_map` - Add `tupelize` function to create tuples from non-downcastable items. - Fix creation of Parameters by iterating through members of tuple object and mapping them to parameters in `update_from_instruction_schedule_map`. - Add missing logic for creating a Target with/without `qubit_properties`. - Add tuple conversion of `Qargs` to store items in a dict in `BasisTranslator` and `UnitarySynthesis` passes. - Cast `PropsMap` object to dict when comparing in `test_fake_backends.py`. - Modify logic of helper functions that receive a bound object reference, a second `py` not required as an argument. - Add set operation methods to `GateMapKeys`. - Other tweaks and fixes. * Fix: More failing tests - Fix repeated erroneous calls to `add_instruction` in `update_from_instruction_schedule_map` - Add missing condition in `instruction_supported` - Use `IndexSet` instead of `HashSet` for `QargsSet`. - Other small tweaks and fixes. * Add: Macro rules for qargs and other sequences. - Create `QargSet` and `PropsMap` using the new macros. - Return a `TargetOpNames` ordered set to python in `operation_names`. - Remove the Python side `operation_names.` - Fix faulty docstring in `target.py`. - Other tweaks and fixes. * Docs: Add necessary docstrings to all new rust functions. - Remove duplicate Iterator in GateMap. - Other small tweaks and fixes. * Fix: Use `GILOneCell` and remove `Qargs` - Use `GILOneCell` to import python modules only once at initialization. - Remove the custom data structure `Qargs` to avoid conversion overhead. - `Qargs` does not use `PhysicalQubits`, `u32` is used instead. - Fix `__setstate__ `and `__getstate__` methods for `PropsMap`, `GateMap`, and `key_like_set_iterator` macro_rule. - Update code to use the new structures. - TODO: Fix broken tests. * Fix: Cast `Qargs` to `Tuple` in specific situations - Use tupleize to cast `Qargs` to `Tuple` in `instructions`. - Use downcast to extract string in `add_instruction`. - Other tweaks and fixes. * Add: Make `Target` Representable in Rust - Rename `InstructionProperties` as `BaseInstructionProperties`. - Remove `Calibration` from the rust space. - Restore `gate_map`, `coupling_map`, `instruction_schedule_map`, and `instruction_durations` to rust. - Remove all unnecessary data structures from rust space. - Other tweaks and fixes. * Refactor: Remove previour changes to unrelated files. * Add: rust native functions to target - Added rust native functionality to target such that a `py` would not be needed to use one. - Add Index trait to make `Target` subscriptable. - Other small tweaks and fixes. * Fix: Remove all unnecessary python method calls. - Remove uage of `inspect.isclass`. - Rename `Target` to `BaseTarget` in the rust side. - Rename `err.rs` to `errors.rs`. - Remove rust-native `add_inst` and `update_inst` as Target should not be modified from Rust. - Made `add_instruction` and `update_instruction_properties` private in `BaseTarget`. - Add missing `get` method in `Target`. - Other tweaks and fixes * Format: Fix lint * Fix: Wrong return value for `BaseTarget.qargs` * Add: Temporary Instruction representation in rust. - Add temporary instruction representation to avoid repeated extraction from python. * Add: Native representation of coupling graph * Fix: Wrong attribute extraction for `GateRep` * Remove: `CouplingGraph` rust native representation. - Move to different PR. * Format: Remove stray whitespace * Add: `get_non_global_op_names` as a rust native function * Fix: Use Ahash for Hashing - Use ahash for hashing when possible. - Rename `BaseTarget` to `Target` in rust only. - Rename `BaseInstructionProperties` to `InstructionProperties` in rust only. - Remove optional logic from `generate_non_global_op_names`. - Use dict for `__setstate__` and `__getstate__` in `Target`. - Reduced the docstring for `Target` and `InstructionProperties`. - Other small tweaks and fixes. * Format: new changes to `lib.rs` * Format: Adapt to new lint rules * Fix: Use new gates infrastructure (Qiskit#12459) - Create custom enum to collect either a `NormalOperation` or a `VariableOperation` depending on what is needed. - Add a rust native `is_instruction_supported` method to check whether a Target supports a certain instruction. - Make conversion methods from `circuit_instruction.rs` public. - Add comparison methods for `Param` in `operations.rs` - Remove need for isclass method in rustwise `add_instruction` - Other tweaks and fixes. * Format: Fix rust formatting * Add: rust-native method to obtain Operstion objects. * Add: Comparison methods for `Param` * FIx: Add display methods for `Params` * Format: Fix lint test * Format: Wrong merge conflict solve * Fix: Improve rust methods to use iterators. - Adapt the Python methods to leverage the rust native improvements. - Use python native structures for the Python methods. * Format: Remove extra blankspace * Fix: Remove `text_signature`, use `signature` instead. * Fix: Rectify the behavior of `qargs` - Keep insertion order by inserting all qargs into a `PySet`. - Perform conversion to `PyTuple` at insertion time leveraging the iterator architecture. - Remove python side counterpart to avoid double iteration. - Make rust-native `qargs` return an iterator. * Fix: Corrections from Matthew's review - Use `format!` for repr method in `InstructionProperties` - Rename `Variable` variant of `TargetInstruction` to `Variadic`. - Remove `internal_name` attribute from `TargetOperation`. - Remove `VariableOperation` class. - Use `u32` for `granularity`, `pulse_alignment`, and `acquire_alignment`. - Use `Option` to store nullable `concurrent_measurements. - Use `&str` instead of `String` for most function arguments. - Use `swap_remove` to deallocate items from the provided `properties` map in `add_instruction`. - Avoid cloning instructions, use `to_object()` instead. - Avoid using `.to_owned()`, use `.clone()` instead. - Remove mention of `RandomState`, use `ahash::HashSet` instead. - Move parameter check to python in `instruction_supported`. - Avoid exposing private attributes, use the available ones instead. - Filter out `Varidadic` Instructions as they're not supported in rust. - Use peekable iterator to peak at the next qargs in `generate_non_global_op_names`. - Rename `qarg_set` to `deduplicated_qargs` in `generate_non_global_op_names`. - Return iterator instances instead of allocated `Vec`. - Add `python_compare` and `python_is_instance` to perform object comparison with objects that satisfy the `ToPyObject` trait. - Other small tweaks and fixes. * Implement a nullable dict-like structure for IndexMap (#2) * Initial: Implement a nullable dict-like structure for IndexMap * FIx: Erroneous item extraction from Python - Fix error that caused `None` values to be ignored from `None` keys. - Removed mutability from rust function argument in `add_instruction`. - Object is mutably referenced after option unwrapping. - Add missing header in `nullable_index_map.rs`. - Add Clone as a `K` and/or `V` constraint in some of the iterators. - Remove `IntoPy` constraint from `NullableIndexMap<K, V>`. - Add `ToPyObject` trait to `NullableIndexMap<K, V>`. * Fix: inplace modification of Python dict. - Perform `None` extraction from rust. - Revert changes to `Target.py` * Fix: Avoid double iteration by using filter_map. * Docs: Add inline comments. * Fix: More specific error message in `NullableIndexMap` * Fix: Use `Mapping` as the metaclass for `Target` - Minor corrections from Matthew's review. * Fix: Make `Target` crate-private. - Due to the private nature of `NullableIndexMap`, the `Target` has to be made crate private. - Add temporary`allow(dead_code)` flag for the unused `Target` and `NullableIndexMap` methods. - Fix docstring of `Target` struct. - Fix docstring of `add_instruction`. - Make several python-only operations public so they can be used with other `PyClass` instances as long as they own the gil. - Modify `py_instruction_supported` to accept bound objects. - Use rust-native functions for some of the instance properties. - Rewrite `instruction` to return parameters as slice. - `operation_names` returns an `ExactSizeIterator`. - All rust-native methods that return an `OperationType` object, will return a `NormalOperation` instance which includes the `OperationType` and the parameters. * Fix: Comments from Matthew's review - Mention duplication in docstring for rust Target. - Use f"{*:g}" to avoid printing the floating point for 0 in `Target`'s repr method. - Add note mentioning future unit-tests in rust. * Fix: Adapt to Qiskit#12730
Cryoris
added a commit
that referenced
this pull request
Apr 13, 2026
Qiskit#15943) * fix(transpiler): TemplateOptimization drops circuit global_phase on substitution circuit_to_dagdependency did not copy global_phase when converting a template QuantumCircuit to DAGDependency, so template phases were lost before matching. TemplateSubstitution.run_dag_opt also constructed a new DAGDependency for the optimised output without inheriting the original circuit's global_phase, resetting it to zero whenever at least one substitution was applied. Fixed by copying global_phase in circuit_to_dagdependency and seeding dag_dep_opt.global_phase from the circuit DAG at construction time. Also added the per-match phase subtraction (Fix 3) for when templates with nonzero global_phase become accepted via the identity check fix in Qiskit#14538. Fixes Qiskit#14537. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(transpiler): TemplateOptimization drops circuit global_phase on substitution circuit_to_dagdependency did not copy global_phase when converting a template QuantumCircuit to DAGDependency, so template phases were lost before matching. TemplateSubstitution.run_dag_opt also constructed a new DAGDependency for the optimised output without inheriting the original circuit's global_phase, resetting it to zero whenever at least one substitution was applied. Additionally, when a template carries a nonzero global_phase phi_T (gate content implements e^{-i*phi_T} * I while the full operator is I), the per-match phase contribution was not being subtracted from the output circuit. Fixes Qiskit#14537. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * style: black reformat test_template_matching.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: use RST hyperlink for issue reference in release note The :issue: role is not available in this project's Sphinx config. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(transpiler): add combined circuit+template global_phase regression test Covers the case where both the circuit and the template carry a nonzero global_phase simultaneously, confirming that fixes #2 (circuit phase preserved across substitution) and #3 (per-match template phase subtracted) compose correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(transpiler): use assertEqual for Operator comparisons in template tests Replace assertTrue(Operator(x) == Operator(y)) with assertEqual(Operator(x), Operator(y)) so that assertion failures show the actual vs expected values rather than just "False is not True". Also shorten multi-line test docstrings to concise one-liners. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Address review feedback on template optimization global phase fix - Simplify comment on global phase update in template_substitution.py - Split release note into per-bug files; add fix-circuit-to-dagdependency-global-phase-14537.yaml - Update tests: use issue reproducer (4-gate circuit) in test_template_nonzero_global_phase_applied_to_circuit, merge single/multiple match tests, drop modulo from assertAlmostEqual Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix test assertions and remove duplicate test - Fix test_circuit_and_template_both_have_nonzero_global_phase expected value from np.pi/4 to 7*np.pi/12 (pi/3 + pi/4) - Remove duplicate test_circuit_global_phase_preserved_with_multiple_template_matches - Update test_template_nonzero_global_phase_applied_to_circuit to use Operator equivalence instead of phase/count assertions since partial template match does occur Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Update releasenotes/notes/fix-circuit-to-dagdependency-global-phase-14537.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update releasenotes/notes/fix-template-optimization-global-phase-14537.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update test/python/transpiler/test_template_matching.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update test/python/transpiler/test_template_matching.py Actually I removed all reference to "Regression test" in the test descriptions based on this comment Qiskit#15943 (comment) Co-authored-by: Julien Gacon <gaconju@gmail.com> * Remove 'Regression test' from docstring per review feedback Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Julien Gacon <gaconju@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolution of merge conflicts
Summary
Details and comments