Skip to content

- Moved aqc MPS content into aqc/mps sub-module.#617

Open
ACE07-Sev wants to merge 3 commits into
unitaryfoundation:mainfrom
ACE07-Sev:sweep
Open

- Moved aqc MPS content into aqc/mps sub-module.#617
ACE07-Sev wants to merge 3 commits into
unitaryfoundation:mainfrom
ACE07-Sev:sweep

Conversation

@ACE07-Sev
Copy link
Copy Markdown
Contributor

  • 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.

closes #368 .

- 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.
@ACE07-Sev
Copy link
Copy Markdown
Contributor Author

@bachase Here is the sweeping we talked about. I added state to it as well.

@ACE07-Sev
Copy link
Copy Markdown
Contributor Author

Oops, forgot doctest.

@ACE07-Sev
Copy link
Copy Markdown
Contributor Author

Once I finish qmprs PR to incorporate bond 2 compression optimization, you can then use that MPS version + SweepStateApproximator to get the performance improvement I mentioned for MPS.

@ACE07-Sev
Copy link
Copy Markdown
Contributor Author

@bachase Have you had a chance to review the PR?

@bachase
Copy link
Copy Markdown
Collaborator

bachase commented Mar 10, 2026

Sorry @ACE07-Sev I had lost track of this one. Taking a look now

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/mps and updated imports/docs accordingly.
  • Added ucc/transpilers/aqc/sweep with StateSweepPass / UnitarySweepPass and approximate compilation helpers.
  • Added tests for the new sweep passes and updated .gitignore for .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.

Comment thread ucc/transpilers/aqc/sweep/approx_unitary.py
Comment thread ucc/tests/test_compile.py
Comment thread ucc/transpilers/aqc/utils.py
Comment thread ucc/transpilers/aqc/sweep/__init__.py
Comment thread ucc/transpilers/aqc/sweep/approx_state.py
Copy link
Copy Markdown
Collaborator

@bachase bachase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some initial comments on just the tests. Copilot had some good ones too. I'll do another deeper review soon.

Comment thread ucc/tests/test_compile.py
Comment thread ucc/tests/test_compile.py
"""
np.random.seed(seed)

state = np.random.uniform(-1, 1, 2**N) + 1j * np.random.uniform(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are random states over this distribution equally interesting/exercising the protocol well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's the general random state distribution. I can test on other distributions as well.

@ACE07-Sev
Copy link
Copy Markdown
Contributor Author

Saw the review. I will go through them today.

@ACE07-Sev
Copy link
Copy Markdown
Contributor Author

Sorry for the delay. I am going through it now.

@ACE07-Sev
Copy link
Copy Markdown
Contributor Author

@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:

- Add layer
- Perform sweeps until plateau
- If plateau is lower than desired lowerbound then repeat, else stop

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.

@ACE07-Sev
Copy link
Copy Markdown
Contributor Author

Actually, do you want me to do that now before I push? The dynamic approach?

@bachase
Copy link
Copy Markdown
Collaborator

bachase commented Apr 16, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NEW PASS] Consider adding Optimization Driven Quantum Circuit Reduction pass

3 participants