Commit ccaea70
committed
Split two qubit decomposer file into separate files
This commit takes the single crates/synthesis/src/two_qubit_decompose.rs
file and splits it into a directory that contains several submodule
files. The original file kind of organically mirrored the python
structure which was to have all the two qubit decomposer implementations
in a single giant file. This was an anti-pattern in python and has led
to us missing many details over time because it was impossible to keep
the entire contents of the file in your head or on screen. This has also
translated to the Rust version of this module as I recently discovered
during the development of Qiskit#13419 that there is a duplicated method with
two different names on the two qubit basis decomposer. The
implementations actually are right next to each other in the impl block.
Nobody noticed because the file was too big. This commit doesn't fix
this as I wanted this migration to not change any code if possible. The
new structure of this module is to break out each decomposer
implementation into a standalone file. If we add new decomposers in the
future they will naturally fit into a new file.
The only small changes made to the code in this commit are mostly about
visibility of functions and structs because things need to be at least
pub(super) if they cross a file boundary now. A few places were made
fully pub or pub(crate) depending on how they're used. Python things
were made full pub to indicate that even if pyo3 doesn't require it.
There was one small code change made as part of this in the
`TwoQubitBasisDecomposer::__getnewargs__` method it was previously
accessing the `TwoQubitWeylDecomposer`'s `unitary_matrix` field and then
converting that to a python array and finally a Py<PyAny>. However there
was a dedicated method for that already
`TwoQubitWeylDecomposer::unitary_matrix()`, I switched the
implementation to just use that method instead. I originally did this in
order to avoid changing the visibility on the unitary_matrix field, but
I had to do that for other places, but I decided not to change this back
because it's a more natural fit.1 parent ff2ee35 commit ccaea70
File tree
7 files changed
+3150
-3011
lines changed- crates/synthesis/src
- two_qubit_decompose
7 files changed
+3150
-3011
lines changed
0 commit comments