Skip to content

Gradient-Free Noise Characterization#288

Open
aleramos119 wants to merge 280 commits intomunich-quantum-toolkit:mainfrom
aleramos119:gradient_free_optimization
Open

Gradient-Free Noise Characterization#288
aleramos119 wants to merge 280 commits intomunich-quantum-toolkit:mainfrom
aleramos119:gradient_free_optimization

Conversation

@aleramos119
Copy link
Copy Markdown
Contributor

Description

Noise characterization modules for the optimization of the decay rates in the Lindblad equation. The following gradient-free optimization methods are available: mcmc, cma, bayesian

Checklist:

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

aleramos119 and others added 30 commits March 12, 2025 14:53
aleramos119 and others added 29 commits April 21, 2026 11:20
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
NoiseModel.proccess["name"] accepts directly the BaseGate class and also a string with the name
- Restructure NoiseModel.__init__ process loop: handle 1-site first,
  then adjacent/non-adjacent 2-site with Crosstalk branching
- Move BaseGate to runtime import; get_operator short-circuits on
  BaseGate instances
- Add longrange_crosstalk_* aliases to GateLibrary and _PAULI_STRINGS
- Extend is_pauli to handle BaseGate instances via isinstance check
- Fix pre-commit issues: split compound asserts, add __init__ docstrings
  to Crosstalk subclasses, update test docstring
- Add .claude/ to .gitignore

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add local_dim parameter to BaseGate.__init__ (default 2 preserves
  qubit behaviour); interaction is now computed as log(n)/log(local_dim)
  and validated to be an integer
- Remove power-of-2 restriction from Destroy and Create
- Crosstalk inherits local_dim from constituent gates and raises
  ValueError if they differ

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Forward local_dim in all BaseGate methods that return a new gate
  (dag, conj, trans, __add__, __sub__, __mul__, __matmul__)
- Replace PauliX/Y/Z.matrix with X()/Y()/Z().matrix in tests,
  removing the noise_library import

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Correct Destroy/Create matrix size from 2x2 to d×d
- Fix XX/YY/ZZ: replace stale `mpo` attribute with `mpo_tensors` note
- Add full Attributes section to Crosstalk class
- Correct CZ generator comment (I-X → I-Z)
- Expand set_sites docstrings in two-qubit gates to describe full effect
- Add missing aliases to GateLibrary Attributes section

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Ruff RUF002 flags U+00D7 (×) as ambiguous. Replace d×d and d²×d²
with dxd and (d^2)x(d^2) in Destroy, Create, and Crosstalk docstrings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New tests cover:
- BaseGate: non-power-of-local_dim ValueError, list-input set_sites,
  @ operator, factory classmethods (destroy, zero, crosstalk, p0, p1, pvm)
- mpo_tensors property AttributeError before set_sites is called
- Zero, XX, YY, ZZ, P0, P1, PVM gate constructors
- Crosstalk: matrix/swapped_matrix, mismatched-local_dim ValueError,
  all 13 named subclasses
- Two-qubit gates (cx, cz, swap, rxx, ryy, rzz, cp): list-input set_sites,
  wrong-site-count ValueError, CX reversed-order tensor transpose
- Entropy/SchmidtSpectrum set_sites list-input branch

Remaining 3% (lines 99-114) is dead code in extend_gate's
elif len(tensors) == 3 branch, which split_tensor never triggers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…00%)

Three new tests target the three previously uncovered branches:
- Adjacent two-site non-Crosstalk gate uses name_op.matrix directly (line 113)
- Non-adjacent non-Crosstalk process with pre-supplied factors passes assert (line 120)
- get_operator returns a BaseGate instance unchanged when passed directly (line 213)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers project overview, source layout, key abstractions (BaseGate,
NoiseModel, MPS/MPO), development conventions, and useful commands.
Complements AGENTS.md without duplicating it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace bare Any with Callable[..., BaseGate] and dict[str, list[float]]
  to satisfy ruff ANN401 (no bare Any) and ty call-non-callable checks
- Move Callable import under TYPE_CHECKING per ruff TC003

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Annotations were dropped by a previous hook run. Reapply
Callable[..., BaseGate] and dict[str, list[float]] for gate_factory
and kwargs, with Callable imported under TYPE_CHECKING.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously CompactNoiseModel only accepted 1-site gates, where proc["sites"]
was a flat list of ints. It now also accepts 2-site gates, where proc["sites"]
is a list of [site_a, site_b] pairs. The expansion loop branches on
gate_instance.interaction and delegates the resulting per-pair dicts to
NoiseModel, which already handles adjacent (matrix) and long-range (factors)
2-site processes. Mixed 1-site and 2-site processes in the same model are
supported.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the interaction-level branch with a single loop that detects
whether each element of proc["sites"] is an int (1-site) or a list
(2-site pair), eliminating duplicated append logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

3 participants