added MPO zip-up as default long-range gate application method#449
Conversation
|
@CodeRabbit review |
✅ Action performedReview finished.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR establishes MPO zip-up as the default long-range two-qubit gate application method. It introduces low-level tensor utilities for MPO/MPS contraction, extends the MPO and MPS classes with new operations, refactors the digital gate dispatcher, and provides comprehensive test validation across all scenarios. ChangesMPO-based Long-Range Two-Qubit Gate Application
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/examples/simulation_parameters.md`:
- Around line 178-184: Reword the three consecutive sentences that start with
"Set `gate_mode=...` to avoid repetition: instead of repeating "Set", vary
phrasing by using alternatives like "Use `gate_mode=\"swaps\"` to ...", "Choose
`gate_mode=\"tdvp\"` for ...", or restructure into a single sentence that lists
the options and behaviors (e.g., "For long-range gates use `gate_mode=\"mpo\"`
(generic MPO–MPS), `gate_mode=\"swaps\"` inserts SWAPs, `gate_mode=\"tdvp\"`
mixes local TEBD with generator MPO + two-site TDVP, and
`gate_mode=\"full-tdvp\"` applies TDVP to every two-qubit gate"). Ensure the
descriptions for `gate_mode="mpo"`, `gate_mode="swaps"`, `gate_mode="tdvp"`, and
`gate_mode="full-tdvp"` remain accurate and preserve mentions of TEBD/SVD, MPO
contraction/compression (`svd_threshold`, `max_bond_dim`), and swap insertion
semantics.
In `@src/mqt/yaqs/core/data_structures/mps.py`:
- Around line 641-696: The compress() and truncate() functions duplicate the
same two-sweep SVD logic; remove the copy in truncate by delegating to
compress(): update truncate() to call self.compress(threshold,
trunc_mode="discarded_weight", min_bond_dim=2, max_bond_dim=...) (passing
through max_bond_dim/threshold args as appropriate) and remove the duplicated
sweep code from truncate; ensure symbols referenced are truncate and compress
and that truncate no longer directly indexes self.check_canonical_form()[0] so
it inherits compress()'s canonical fallback behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1ff68710-0cf1-4061-927d-1923a56692cb
📒 Files selected for processing (16)
CHANGELOG.mddocs/examples/simulation_parameters.mdsrc/mqt/yaqs/core/data_structures/mpo.pysrc/mqt/yaqs/core/data_structures/mpo_utils.pysrc/mqt/yaqs/core/data_structures/mps.pysrc/mqt/yaqs/core/data_structures/simulation_parameters.pysrc/mqt/yaqs/digital/digital_tjm.pysrc/mqt/yaqs/digital/utils/contraction_utils.pysrc/mqt/yaqs/equivalence_checker.pytests/core/data_structures/test_mpo.pytests/core/data_structures/test_mpo_utils.pytests/core/data_structures/test_simulation_parameters.pytests/digital/test_digital_tjm.pytests/digital/test_mps_utils.pytests/digital/utils/test_contraction_utils.pytests/test_equivalence_checker.py
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Description
This PR adds the MPO zip-up method (direct MPO-MPS multiplication) as the default long-range circuit simulation method.
This also adds several helpers such as MPO.multiply(MPS | MPO) which are now used throughout the code.
Additionally, the long-range gate settings have been changed from "tebd" to "swaps", "hybrid" to "tdvp" and "tdvp" to "full-tdvp" (all gates including nearest-neighbor gates).
Checklist
If PR contains AI-assisted content:
Assisted-by: [Model Name] via [Tool Name]footer.