Feat: Added Verstraete-Cirac fermion-to-qubit encoding (#482)#515
Open
luffy-orf wants to merge 3 commits into
Open
Feat: Added Verstraete-Cirac fermion-to-qubit encoding (#482)#515luffy-orf wants to merge 3 commits into
luffy-orf wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds Verstraete–Cirac (auxiliary-qubit) fermion-to-qubit encoding support, including stabilizer exposure/serialization and a generic mapper-side stabilizer penalty to recover the physical (codespace) spectrum.
Changes:
- Implement
MajoranaMapping::verstraete_cirac(LatticeGraph)and expose it (plusstabilizers) to Python via pybind11. - Add generic stabilizer penalty injection in the mapping engine and extend JSON serialization to persist stabilizers (and explicit qubit count for bilinear-only mappings).
- Add documentation + references and Python tests covering spectrum/locality/round-trips.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| python/tests/test_verstraete_cirac.py | New acceptance tests for VC factory, mapper integration, spectrum match, locality, and serialization round-trips. |
| python/src/pybind11/data/majorana_mapping.cpp | Exposes stabilizers and the verstraete_cirac factory to Python. |
| docs/source/user/comprehensive/algorithms/qubit_mapper.rst | Documents Verstraete–Cirac encoding and its stabilizer penalty behavior. |
| docs/source/references.bib | Adds VC-related citations. |
| cpp/src/qdk/chemistry/data/majorana_mapping_factories.cpp | Implements VC factory and stabilizer construction. |
| cpp/src/qdk/chemistry/data/majorana_mapping.cpp | Adds stabilizers storage + JSON persistence; adjusts without_tapering() and summary. |
| cpp/src/qdk/chemistry/data/majorana_map_engine.cpp | Adds generic stabilizer penalty term merging into the mapped Hamiltonian. |
| cpp/include/qdk/chemistry/data/majorana_mapping.hpp | Adds stabilizers() API and verstraete_cirac() factory declaration/docs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+199
to
+203
| with tempfile.NamedTemporaryFile(suffix=".h5") as f: | ||
| with h5py.File(f.name, "w") as hf: | ||
| mapping.to_hdf5(hf) | ||
| with h5py.File(f.name, "r") as hf: | ||
| reloaded = MajoranaMapping.from_hdf5(hf) |
Comment on lines
+566
to
+571
| std::unordered_map<SparsePauliWord, std::complex<double>, SparsePauliWordHash> | ||
| merged; | ||
| merged.reserve(result.words.size() + stabilizers.size() + 1); | ||
| for (std::size_t i = 0; i < result.words.size(); ++i) { | ||
| merged[result.words[i]] += result.coefficients[i]; | ||
| } |
Comment on lines
+589
to
+597
| MajoranaMapResult penalized; | ||
| penalized.words.reserve(merged.size()); | ||
| penalized.coefficients.reserve(merged.size()); | ||
| for (auto& [word, coeff] : merged) { | ||
| if (protected_words.count(word) || std::abs(coeff) >= threshold) { | ||
| penalized.words.push_back(word); | ||
| penalized.coefficients.push_back(coeff); | ||
| } | ||
| } |
Comment on lines
+569
to
+580
| std::vector<std::pair<std::complex<double>, SparsePauliWord>> bilinears; | ||
| bilinears.reserve(M * (M - 1) / 2); | ||
| for (std::size_t J = 0; J < M; ++J) { | ||
| std::size_t p = J / 2, ap = J % 2; | ||
| std::size_t qp_qubit = 2 * sigma(p); | ||
| auto gamma_J = vc_jw_majorana(qp_qubit, ap == 0 ? op_x : op_y); | ||
| for (std::size_t K = J + 1; K < M; ++K) { | ||
| std::size_t q = K / 2, bq = K % 2; | ||
| std::size_t qq_qubit = 2 * sigma(q); | ||
| auto gamma_K = vc_jw_majorana(qq_qubit, bq == 0 ? op_x : op_y); | ||
|
|
||
| auto bare = PauliTermAccumulator::multiply_uncached(gamma_J, gamma_K); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the Verstraete-Cirac (VC) locality-preserving fermion-to-qubit encoding as a
new
MajoranaMapping.verstraete_cirac(lattice)factory, consumable byQubitMapperwith no special-casing.
MajoranaMapping: introduces a generic, optionalstabilizers_member (a list of Pauli terms) with accessor + JSON/HDF5 serialization. No grid
metadata is stored on the data class.
verstraete_ciracrecovers latticecoordinates directly from a rectangular
LatticeGraph's adjacency, emits one VCblock per spin sector (
num_modes == 2 * n_sites,num_qubits == 4 * n_sites),and produces codespace stabilizers.
λ·(I − S)per stabilizeruniformly — no encoding-name checks, no grid logic — so non-redundant encodings
(Jordan-Wigner, etc.) are completely unaffected.
verstraete_ciracfactory and astabilizersaccessor.Test plan
New module
python/tests/test_verstraete_cirac.pycovering the acceptance criteria:QubitMapperconsumes eachwithout error; non-rectangular lattices are rejected.
match Jordan-Wigner to < 1e-10.
L in {2, 3, 4}.
Closes #482