Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port HighLevelSynthesis pass to rust (#13813)
* Moving all internal fields into a separate class * making all the inner functions to be global * moving handling annotated operations to plugin The interface is now quite ugly, and we also have an extra isinstance check for each gate, we will see if it can be removed. * improving control-modified synthesis plugin * Changing internal functions to work with QuantumCircuits instead of DAGCircuits * renaming * Removing unnecessary argument use_ancillas This argument is not needed as the qubit tracker already restricts allowed ancilla qubits. * progress * minor * removing context * minor * removing unused argument * removing an obsolete statement * minor cleanup * minor * improvements to run method * cleanup * another pass over the run method + black * minor cleanup * pass over synthesize_operation * more cleanup * pass over HLS::run * cleanup * pass over annotated plugin * cleanup * improving comment * fixing pylint * remove print statements in tests * fmt * fix + test for controlling circuits with nontrivial phase * adding release notes * adding test function docstring * minor * Finalizing data class contruction * adding error message * Adding method op_names to HighLevelSynthesisPluginManager This is used to simplify the check whether a given node/operation can be skipped. * updating old usages of equiv library * fixing lint errors after merge * slightly simplifying the arguments to instruction_supported method * Fixing definition method for PyGate and PyInstruction * docstring fixes * applying Julien's suggestion * adding intern * replacing data by _data (accidentally removed in cleanup) * porting main functionality to rust * Adding missing functionality * passing empty dict to dag_to_circuit when None * Adding definition for UnitaryGate Even when HighLevelSynthesis runs directly after UnitarySynthesis, it may happen that certain definitions involve UnitaryGates (for instance, this is the case for Isometry), in which case the default behavior of HighLevelSynthesis should be to query the definition of UnitaryGates if they are not in the basis. * Replacing from_circuit_data by clone_empty_like Going from QuantumCircuit/DAGCircuit to CircuitData discards information, such as information about registers, input variables and more. The previously tried approach of constructing DAGCircuit/QuantumCircuitData in rust space by calling _from_circuit_data and manually fixing registers was not complete. Instead we now call clone_empty_like both on DAGCircuit and QuantumCircuit. * making target of type Option<Py<Target>> and avoiding expensive cloning * changing type of equivalence library as well * adding pickling support this actually requires dill since HLSConfig includes a lambda function for comparing circuits obtained with different synthesis plugins, but fortunately it's all already supported * Passing Bound<HighLevelSynthesisData> to functions This avoids cloning data when calling Python * Using Bound<QubitTracker> in functions This avoid having to clone it when calling the Python space * Removing the pub keywork in front of HLS structs, members and internal functions * Adding function to return a definition for a given operation. The main functionality is to create some default definition for unitary gates, for all other operation types we can simply use the definition method. * pylint * clippy * Adding tests for HLS tracking global phase. With various conversions of DAGCircuit to QuantumCircuitData to CircuitData in Rust, it's best to make sure that the global phases appearing in circuits/control-flow subcircuits are tracked correctly * cleanup * removing unnecessary changes to other files * improving Rust HLS interface; skipping synthesis of already supported ops when calls from annotated plugin * clippy * updating code after merging with main * finalize merge with main * using pyo3 get/set * avoding extra casts u32 -> usize when possible * avoiding multiple calls to data.borrow() * changing QubitTracker from being a Python class * applying Eli's review comments * also applying renames on the python side * Applying more of Eli's comments * renaming use_qubit_indices to use_physical_indices * Changing hls_op_names to a set for further efficiency * adding an even faster check whether HLS can be skipped * improving transpiler errors (with user in mind) * improving comment * further improving all_instructions_supported * addressing more review comments * include the upgrade reno comment * adding a comment with detailed explanation on how we track qubits when synthesizing the base operation of an annotated operation
- Loading branch information