- Moved aqc MPS content into aqc/mps sub-module.#617
Conversation
- Added `aqc/sweep` module, which provides `StateSweepPass` and `UnitarySweepPass` for performing approximate synthesis for both state and unitary using tensor network sweeping. - Added unit tests for `aqc/sweep`. - Added `.mypy_cache/` to .gitignore file.
|
@bachase Here is the sweeping we talked about. I added state to it as well. |
|
Oops, forgot doctest. |
|
Once I finish |
|
@bachase Have you had a chance to review the PR? |
|
Sorry @ACE07-Sev I had lost track of this one. Taking a look now |
There was a problem hiding this comment.
Pull request overview
This PR reorganizes the AQC transpiler by moving existing MPS-based approximate compilation into an aqc/mps submodule and introducing a new aqc/sweep submodule that adds sweeping-based approximate synthesis passes for both states and unitaries (with accompanying tests and docs updates).
Changes:
- Moved MPS AQC implementation into
ucc/transpilers/aqc/mpsand updated imports/docs accordingly. - Added
ucc/transpilers/aqc/sweepwithStateSweepPass/UnitarySweepPassand approximate compilation helpers. - Added tests for the new sweep passes and updated
.gitignorefor.mypy_cache/.
Reviewed changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| ucc/transpilers/aqc/utils.py | New shared helper for memory checks (moved from MPS utils). |
| ucc/transpilers/aqc/sweep/__init__.py | Public sweep API and compile helpers (approx_state_compile, approx_unitary_compile). |
| ucc/transpilers/aqc/sweep/sweep_pass.py | New Qiskit TransformationPass wrappers for sweep compilation. |
| ucc/transpilers/aqc/sweep/approx_state.py | State sweeping approximator implementation (tensor-network based). |
| ucc/transpilers/aqc/sweep/approx_unitary.py | Unitary sweeping approximator implementation + fidelity helper. |
| ucc/transpilers/aqc/sweep/ansatzes.py | Ansatz generators (staircase / brickwall) for sweep methods. |
| ucc/transpilers/aqc/sweep/typing.py | Type aliases for unitary layer/block structures. |
| ucc/transpilers/aqc/mps/utils.py | Removes has_enough_memory after moving to shared AQC utils. |
| ucc/transpilers/aqc/mps/__init__.py | New MPS submodule public API and approx_compile. |
| ucc/transpilers/aqc/mps/mps_pass.py | Imports approx_compile lazily to avoid module import cycles. |
| ucc/transpilers/aqc/mps/mps_sequential.py | Updates slope util import and fixes fidelity computations to use squared magnitude. |
| ucc/transpilers/aqc/mps/qmprs_compiler.py | Updates slope util import and adds typing ignore for optional dependency. |
| ucc/transpilers/aqc/mps/README.md | New documentation describing the MPS approach and qmprs option. |
| ucc/transpilers/aqc/__init__.py | Re-exports passes from the new submodules. |
| ucc/tests/test_compile.py | Adds sweep-pass tests and updates imports. |
| docs/source/user_guide.rst | Updates usage example import path for MPSPass. |
| .gitignore | Ignores .mypy_cache/. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bachase
left a comment
There was a problem hiding this comment.
Left some initial comments on just the tests. Copilot had some good ones too. I'll do another deeper review soon.
| """ | ||
| np.random.seed(seed) | ||
|
|
||
| state = np.random.uniform(-1, 1, 2**N) + 1j * np.random.uniform( |
There was a problem hiding this comment.
Are random states over this distribution equally interesting/exercising the protocol well?
There was a problem hiding this comment.
I believe it's the general random state distribution. I can test on other distributions as well.
|
Saw the review. I will go through them today. |
|
Sorry for the delay. I am going through it now. |
|
@bachase I amended for the review comments. One major thing that needs to be done sometime is finding a good rule for defining the number of layers. Its optimal value very much depends on the state/unitary structure and size. There's a dynamic way I can try. Basically: This will remove the hardcoded values, but in certain cases may take too long to reach the desired fidelity. Although, we can introduce hard stops like if the ansatz generated is more expensive than the original circuit. |
|
Actually, do you want me to do that now before I push? The dynamic approach? |
|
Thanks for investigating @ACE07-Sev . How "big" of a change/exploration is the dynamic approach? If you think its worth doing now, go for it, but ok if you think a followup is better. |
aqc/sweepmodule, which providesStateSweepPassandUnitarySweepPassfor performing approximate synthesis for both state and unitary using tensor network sweeping.aqc/sweep..mypy_cache/to .gitignore file.closes #368 .