Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7717d7c
Add failed example to tests
chmwzc Jul 6, 2026
a3ad067
Add mapping back to original set of qubits
chmwzc Jul 6, 2026
1fc0b22
Apply pylint suggestions
chmwzc Jul 6, 2026
b4dd226
Additional bug fix
chmwzc Jul 24, 2026
b9d934a
Update test code
chmwzc Jul 24, 2026
125c141
Loosen test bounds slightly
chmwzc Jul 24, 2026
73395aa
Minor improvements
chmwzc Jul 29, 2026
d69726c
Tentative fix to Gaussian elimination code
chmwzc Jul 31, 2026
2c7f513
Change symplectic arrays dtype: int -> np.uint8
chmwzc Aug 3, 2026
7b98afa
Refactor some symplectic array-related functions
chmwzc Aug 3, 2026
ec2eee1
Cleanup tests (in-progress)
chmwzc Aug 3, 2026
a5f7260
Finish cleaning up tests for sample stuff
chmwzc Aug 3, 2026
6035d85
Minor tidying edits to code
chmwzc Aug 3, 2026
5f7214a
Adding another test
chmwzc Aug 4, 2026
7b375f2
Still stuck on this...
chmwzc Aug 5, 2026
057f7ff
Fix single test
chmwzc Aug 5, 2026
18381eb
attempt to fix the phase
shangtai Aug 8, 2026
1b64f8a
attempt to fix the phase
shangtai Aug 8, 2026
107250c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 8, 2026
a0875a5
attempt to fix the phase
shangtai Aug 8, 2026
89d394a
attempt to fix the phase
shangtai Aug 8, 2026
a803385
attempt to fix the phase
shangtai Aug 8, 2026
224d65a
attempt to fix the phase
shangtai Aug 9, 2026
9e52c1a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 9, 2026
d801295
attempt to fix the phase
shangtai Aug 9, 2026
70f8da9
Merge remote-tracking branch 'origin/fix-gc' into fix-gc
shangtai Aug 9, 2026
6eda92c
Merge branch 'main' into fix-gc
chmwzc Aug 13, 2026
96e82b4
Minor cleaning of test_molecule
chmwzc Aug 18, 2026
7b8f226
Add array to track phase of basis terms
chmwzc Aug 18, 2026
b58da11
Update test functions
chmwzc Aug 18, 2026
5548252
Fix code coverage
chmwzc Aug 18, 2026
63f5b35
Bugfix: Phase tracking
chmwzc Aug 19, 2026
1716a48
Fix tests
chmwzc Aug 19, 2026
2e3773c
Use bitwise operations for phase tracking
chmwzc Aug 31, 2026
680931f
Update other operations as well
chmwzc Aug 31, 2026
26d3a01
Revert physical SWAPs after circuit synthesis
chmwzc Aug 31, 2026
0496716
Add test for earlier phase bug
chmwzc Aug 31, 2026
15e384b
Minor cleanup
chmwzc Aug 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/qibochem/measurement/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _gc_measurement_mapping(expression: Expr, nqubits: int, method: str) -> tupl
can be used to calculate the expectation values of ALL the terms in expression directly.

Args:
expression (sympy.Expr): Group of Pauli terms that all mutually commute with each other qubitwise
expression (sympy.Expr): Group of Pauli terms that mutually commutes with each other
nqubits (int): Number of qubits of the original Hamiltonian
method (str): Circuit formulation to use, either "chong" (default) or "izmaylov"

Expand All @@ -124,7 +124,7 @@ def _gc_measurement_mapping(expression: Expr, nqubits: int, method: str) -> tupl
]
# Otherwise, expression is a sum of terms
term_list = [_term_to_string(term) for term in expression.args if _term_to_string(term)[0] in ("X", "Y", "Z")]
v_subspace = np.array([_pauli_to_symplectic(terms.split(), nqubits) for terms in term_list])
v_subspace = np.array([_pauli_to_symplectic(terms.split(), nqubits) for terms in term_list], dtype=np.uint8)
v_basis = _binary_gaussian_elimination(v_subspace)

dim_v = v_basis.shape[0]
Expand All @@ -133,15 +133,19 @@ def _gc_measurement_mapping(expression: Expr, nqubits: int, method: str) -> tupl
if dim_v != dim_symplectic:
nullspace = _binary_nullspace(v_basis)
# Interchange the 1st/2nd half of the indices to get nullspace in a symplectic sense
nullspace = np.concatenate((nullspace[:, dim_symplectic:], nullspace[:, :dim_symplectic]), axis=1)
nullspace = nullspace[:, np.r_[dim_symplectic : 2 * dim_symplectic, 0:dim_symplectic]]
nullspace = _binary_gaussian_elimination(nullspace)
v_basis = _lagrangian_subspace(nullspace)

# Different methods of circuit synthesis
if method == "chong":
x_result = _solve_linear_system(v_basis, v_subspace)
# Map the solution onto the original set of qubits
phase_factors = [_phase_factor(v_basis[pauli_op]) for pauli_op in x_result]
u_gates = _synthesise_circuit(v_basis)
u_gates, phases = _synthesise_circuit(v_basis)
mapping = {
term: phase * prod(Z(_i) for _i in soln) for term, phase, soln in zip(term_list, phase_factors, x_result)
term: phase * prod(phases[i] * Z(i) for i in soln)
for term, phase, soln in zip(term_list, phase_factors, x_result)
}
elif method == "izmaylov":
v_basis = _sort_tau_terms(v_basis)
Expand Down
Loading
Loading