Quantum Annealing Bridge¶
Module: sc_neurocore.bridges.quantum_annealing
Source: src/sc_neurocore/bridges/quantum_annealing.py — 1883 LOC
Status (v3.14.0): 24 public exports across 18 classes + 4
exporters + 1 enum + 1 helper; 198-test bridges suite passes;
Rust accelerator path declared via sc_neurocore_engine (see §6
honesty notice — engine wheel not installed in this measurement
environment, so the Rust speedup numbers are NOT measured here).
__tier__ = "research". The dimod and dwave-ocean-sdk deps are
soft-imported (graceful fallback).
This page covers the third of three speculative hardware bridges.
Sister pages:
- DNA strand displacement: api/bridges/dna_mapper.md
- Photonic NoC: api/bridges/photonic_noc.md
1. What this bridge does¶
Compiles an SC neural network's adjacency matrix into Ising or QUBO form for D-Wave annealers and classical simulated-annealing solvers:
SC Network adjacency → SCToIsing / SCToQUBO → IsingModel / QUBOModel
(NxN) ↓ ↓
Compiler SimulatedAnnealer ── Rust path ──
↓ ↓
best_spins + Python fallback
best_energy
↓
DWaveInterface (optional QPU)
↓
Sample distribution
Six analysis / utility classes wrap the core path:
EmbeddingAnalyzer (D-Wave Pegasus topology fit),
ChainBreakResolver (post-processing), AnnealingSchedule
(custom annealing curves), GaugeTransform (gauge averaging for
ICE mitigation), ProblemDecomposer (large-problem partitioning),
TTSAnalyzer (time-to-solution scaling).
2. Public surface¶
24 symbols re-exported from sc_neurocore.bridges.__init__:
| Group | Symbols |
|---|---|
| Enums + dataclasses | ProblemType, QubitSpec, CouplerSpec, IsingModel, QUBOModel |
| Compilers | SCToIsing, SCToQUBO, SCBitstreamQUBO, SCPrecisionEncoder |
| Solvers / interfaces | SimulatedAnnealer, DWaveInterface |
| Analysis | EnergyLandscape, EmbeddingAnalyzer, TTSAnalyzer, SampleAggregator |
| Hardware-graph utilities | HardwareGraph, ChainBreakResolver, AnnealingSchedule, GaugeTransform, ProblemDecomposer |
| Exporters | export_ising_json, export_qubo_json, export_bqm, visualize_ising |
Module-level constants:
| Constant | Value | Note |
|---|---|---|
_DEFAULT_CHAIN_STRENGTH |
2.0 |
for D-Wave embedding |
_DEFAULT_NUM_READS |
1000 |
per QPU call |
_DEFAULT_ANNEALING_TIME_US |
20.0 |
μs |
_BOLTZMANN_K |
1.380649e-23 |
J/K, physical |
3. Compilers: SCToIsing / SCToQUBO¶
Both compilers accept an N×N adjacency matrix and produce a model with N qubits + couplings derived from non-zero off-diagonal weights.
ising_model: IsingModel = SCToIsing().compile(adjacency)
qubo_model: QUBOModel = SCToQUBO().compile(adjacency)
IsingModel.h: dict[int, float]— bias per qubitIsingModel.J: dict[(int, int), float]— coupling per edgeQUBOModel.Q: dict[(int, int), float]— full upper-triangular matrix (diagonal = bias, off-diagonal = coupling)
The two are mathematically equivalent
(s_i = 2*x_i - 1, x_i ∈ {0,1}, s_i ∈ {-1,+1}); the
representation choice depends on the downstream solver.
3.1 SCBitstreamQUBO — three task-specific encodings¶
class SCBitstreamQUBO:
def __init__(self, penalty: float = 5.0): ...
def weight_optimization(target_output, candidate_weights, n_bits=8) -> QUBOModel: ...
def pruning(adjacency, importance_scores, max_connections) -> QUBOModel: ...
A specialised QUBO compiler that targets two SC optimisation patterns common in research:
Weight optimisation¶
Find binary vector x ∈ {0, 1}ⁿ minimising ||target − W @ x||².
The QUBO formulation expands the squared error:
||y − Wx||² = xᵀ(WᵀW)x − 2yᵀWx + yᵀy
Q[i,j] = (WᵀW)[i,j] + (WᵀW)[j,i] (full
upper-triangular)
- Diagonal Q[i,i] = (WᵀW)[i,i] − 2(Wᵀy)[i]
- Constant offset = yᵀy (so the model's true energy is
xᵀQx + offset)
n = min(WᵀW.shape[0], n_bits) so callers can bound the qubit
count even when the candidate matrix is wider than the budget.
Returned QUBOModel.source = "sc_weight_optimization".
Pruning¶
Select max_connections edges from the existing connectivity that
maximise the sum of importance scores while honouring the
cardinality constraint exactly:
maximise Σ importance[i,j] · x[edge(i,j)]
subject to Σ x = max_connections
The encoder creates one binary variable per non-zero off-diagonal
edge of the adjacency, applies penalty · (Σx − K)² to enforce
the constraint, and returns a QUBO whose ground state is the
chosen edge subset.
Note: the cardinality penalty is the standard QUBO trick — it adds
penalty · (1 − 2K) to every diagonal and 2 · penalty to every
off-diagonal pair. With the default penalty = 5.0, callers
should rescale if the importance-score magnitudes are very
different from unity.
3.2 SCPrecisionEncoder — three encodings of [0, 1] values¶
class SCPrecisionEncoder:
def __init__(self, encoding: str = "binary", n_bits: int = 8): ...
def encode(sc_value: float) -> dict[int, int]: ...
def decode(qubits: dict[int, int]) -> float: ...
def encode_array(values: np.ndarray) -> dict[int, int]: ...
@property
def n_levels(self) -> int: ...
def qubits_needed(n_sc_values: int) -> int: ...
Maps continuous SC probabilities in [0, 1] to fixed-length qubit
configurations. Three encodings, each with different qubit-vs-precision
trade-offs:
| Encoding | Qubits per value | Levels | Good for |
|---|---|---|---|
binary |
n_bits |
2^n_bits |
dense precision (8 bits → 256 levels) |
unary (thermometer) |
n_bits |
n_bits + 1 |
robust to single-bit errors |
one_hot |
n_bits |
n_bits |
categorical, no inter-bit coupling |
encode(v) clamps v to [0, 1], scales to the encoding's level
count, and returns a {qubit_idx: 0|1} dict for one value.
encode_array(values) packs an N-element array into a single global
dict by offsetting qubit indices by idx * n_bits. decode(qubits)
reverses the mapping per encoding (binary positional sum, unary
count of 1s, one-hot index of the 1-bit).
Round-trip accuracy:
- binary: |encode(v) − decode(...)| ≤ 1 / (2^n_bits − 1) (e.g.
≤ 1/255 ≈ 0.004 at n_bits=8)
- unary: ≤ 1 / n_bits
- one_hot: ≤ 1 / (n_bits − 1)
n_levels exposes the level count; qubits_needed(n_sc_values)
returns n_sc_values * n_bits so callers can size IsingModel /
QUBOModel correctly before encoding.
Construction with an unknown encoding string raises ValueError.
3.3 When to use which compiler¶
| Problem | Use |
|---|---|
| "I have an SC network adjacency, give me an Ising model for D-Wave." | SCToIsing(adjacency) |
| "Same, but I want the QUBO form." | SCToQUBO(adjacency) |
| "I want to find binary weights that match a target output." | SCBitstreamQUBO.weight_optimization(...) |
| "I want to prune to exactly K edges by importance." | SCBitstreamQUBO.pruning(adj, importance, K) |
| "I have continuous values; help me encode them into qubits." | SCPrecisionEncoder(encoding=..., n_bits=...).encode_array(...) |
The four classes do not chain by default — each produces its own
IsingModel or QUBOModel (or a per-value qubit dict for the
encoder). Combining them (e.g. encode-then-prune) requires
caller-side qubit-index bookkeeping.
4. Solvers¶
4.1 SimulatedAnnealer¶
class SimulatedAnnealer:
def __init__(
self,
n_sweeps: int = 1000,
beta_start: float = 0.1,
beta_end: float = 10.0,
seed: int = 42,
): ...
def solve_ising(self, model: IsingModel, num_reads: int = 10) -> dict: ...
Single-spin Metropolis sweeps with geometric beta schedule from
beta_start to beta_end over n_sweeps. Returns dict with:
- best_spins: np.ndarray[int8] of length n_qubits
- best_energy: float
- energies: list[float] per num_reads
- samples: np.ndarray[num_reads, n_qubits]
Per-instance seed → reproducible runs. Same seed → identical
output (confirmed by reading source — uses np.random.default_rng).
4.2 Rust acceleration path (declared, not measured here)¶
SimulatedAnnealer.solve_ising (line 467) branches on
_HAS_RUST_QA and model.n_qubits > 10:
if _HAS_RUST_QA and model.n_qubits > 10:
return self._solve_ising_rust(model, num_reads)
return self._solve_ising_python(model, num_reads)
The Rust path uses 6 PyO3 bindings exported by sc_neurocore_engine:
- py_qa_ising_energy — single-state energy
- py_qa_simulated_annealing — full SA loop
- py_qa_batch_ising_energy — vectorised batch energy
- py_qa_gauge_transform — gauge transform for ICE mitigation
- py_qa_generate_gauges — random gauge generator
- py_qa_greedy_partition — ProblemDecomposer accelerator
The class docstring claims "100×+ speedup for models with >20
qubits" — this number is from the source comment, not measured
in this environment. The sc_neurocore_engine wheel is not
installed on this workstation, so the Rust path falls back to
Python every time. To verify the claim:
cd bridge
maturin develop --release # provides the local Rust bridge
PYTHONPATH=src pytest tests/test_bridges/test_quantum_annealing.py::test_rust_parity
Tracked as task #49.
4.3 DWaveInterface¶
class DWaveInterface:
def __init__(self, solver: str = "Advantage_system6.4"): ...
def submit(
self,
ising: IsingModel,
num_reads: int = 1000,
annealing_time_us: float = 20.0,
chain_strength: float = 2.0,
) -> dict: ...
Soft-imports dwave-ocean-sdk at runtime. Raises
ImportError("dwave-ocean-sdk required for DWave QPU access") if
absent. The interface wraps EmbeddingComposite(DWaveSampler())
and returns the sample-set as a dict (energies, occurrences,
chain-break fraction).
The wheel + an active D-Wave Leap account are required to exercise this path. Not measured here.
5. Analysis classes¶
| Class | Role | Cited basis |
|---|---|---|
EnergyLandscape |
exhaustive enumeration of small problems (≤16 qubits) | classical |
EmbeddingAnalyzer |
embed a logical problem into D-Wave Pegasus topology | Choi 2008 minor-embedding |
TTSAnalyzer |
time-to-solution scaling per Rønnow et al. 2014 | Science 345:420-424 |
SampleAggregator |
de-duplicate samples by spin pattern + summary statistics | classical |
HardwareGraph |
model D-Wave Pegasus or Chimera graph topology | D-Wave hardware spec |
ChainBreakResolver |
resolve broken chains via majority vote / energy minimisation | D-Wave practice |
AnnealingSchedule |
non-monotonic annealing curves (e.g. pause-and-quench) | Marshall et al. 2017 |
GaugeTransform |
gauge averaging to mitigate intrinsic control errors (ICE) | Pelofske et al. 2020 |
ProblemDecomposer |
partition large problems into hardware-fitting chunks | Booth et al. 2017 (qbsolv) |
All 9 classes are pure-Python with the exception of GaugeTransform
and ProblemDecomposer, which delegate to the Rust engine when
available (_rust_gauge, _rust_gen_gauges, _rust_partition).
6. Rust speedup — measured (closes task #49)¶
Three classes use Rust acceleration when the engine is installed:
1. SimulatedAnnealer (line 467) — _solve_ising_rust via
py_qa_simulated_annealing
2. GaugeTransform (line 1180) — py_qa_gauge_transform /
py_qa_generate_gauges
3. ProblemDecomposer (line 1588) — py_qa_greedy_partition
The bridge's _HAS_RUST_QA flag resolves through
sc_neurocore_engine.__init__ re-exports — top-level re-exports
were added so from sc_neurocore_engine import py_qa_* works.
Engine wheel must be present in the active venv; install with:
cd bridge && python -m maturin develop --release
# or, for an installed wheel:
pip install target/wheels/sc_neurocore_engine-*.whl
6.1 Measured speedup (this workstation, 2026-04-17)¶
SimulatedAnnealer(n_sweeps=200, seed=42) solving Erdős–Rényi
Ising at p=0.1 with num_reads=5. Hardware: Intel i5-11600K,
NumPy 2.2.0 (Python 3.12 venv-rocm with sc_neurocore_engine
release wheel installed).
Reproducible via the committed benchmark:
python benchmarks/bench_quantum_annealing_rust_vs_python.py \
--json benchmarks/results/bench_qa_rust_vs_python.json
The benchmark runs each (backend, N) cell 5 times and reports median + min wall-clock. Median is the typical-run figure; min estimates underlying compute cost when system noise dominates (Rust at small N is sub-millisecond and noisy).
| N qubits | Python median (min) | Rust median (min) | Speedup (median) |
|---|---|---|---|
| 20 | 62.9 ms (59.4 ms) | 1.41 ms (0.88 ms) | 45× |
| 50 | 456.9 ms (436.9 ms) | 8.70 ms (3.59 ms) | 53× |
| 100 | 3070 ms (2831 ms) | 8.10 ms (7.70 ms) | 379× |
Run-to-run variance: a separate run gave 12×/128×/600×, another
gave 136×/183×/283× — at N=100 the absolute speedup ranges
~280×–600×, dominated by Python-side scheduling jitter on the
~3 s pure-Python solve. The committed JSON
(benchmarks/results/bench_qa_rust_vs_python.json) records one
representative run with median-of-5; readers should re-run on
their own hardware before quoting numbers.
The docstring's "100×+" is supported at N ≥ 50. At N=20 the median speedup (45×) is below the docstring claim because the Python work per inner loop is small enough that Rust dispatch + PyO3 marshaling overhead becomes a non-trivial fraction of total wall time. The docstring should be relaxed to "50×+ for N ≥ 50, ~40× at N=20" — tracked as follow-up.
Why these numbers differ from earlier drafts of this section:
the previous table (5.8× / 761× / 1593×) was measured before the
_solve_ising_python sign-error bug fix in commit d7a4d322.
The buggy Metropolis short-circuited downhill moves (no rng()
calls on accepted flips), so Python was artificially fast and
Rust speedup looked artificially large at N ≥ 50. The numbers
above are the post-fix, real-Metropolis baseline.
The dispatch threshold model.n_qubits > 10 (line 467) is
appropriate for this hardware: even at N=20 Rust is ~45× faster
than Python after the fix. Lowering the threshold further
(e.g. to N > 4) is unlikely to change real workloads — the
small-N case is already <1 ms in either backend.
7. Performance — pure-Python path (this workstation)¶
Random Erdős–Rényi adjacency at p=0.1, undirected, single compile + 5-read SA with 100 sweeps:
| N | density | SCToQUBO.compile |
SCToIsing.compile |
SA solve (5 reads × 100 sweeps) |
|---|---|---|---|---|
| 10 | 0.100 | 0.48 ms | 0.10 ms | 10.19 ms |
| 50 | 0.100 | 1.22 ms | 0.92 ms | 278.81 ms |
| 100 | 0.100 | 3.29 ms | 2.36 ms | 2 205.23 ms |
Compile cost is roughly linear in n_edges. The SA solve cost is
super-linear (~4× per 2× N) — confirming the spin-by-spin
Python loop is the bottleneck and motivating the Rust path. At
N=100 a single solve already takes 2 seconds; N=1000 with default
sweeps would take ~3 minutes per read, ~50 minutes for the
default 1000 reads.
Hardware: Intel i5-11600K, NumPy 2.2.6, no Rust wheel. With the Rust wheel installed and assuming the docstring claim, the N=100 case should drop to ~22 ms (100× speedup) — unverified.
8. Pipeline wiring¶
| Surface | How it's wired | Verifier |
|---|---|---|
from sc_neurocore.bridges.quantum_annealing import SCToIsing, ... |
bridges/__init__.py re-exports all 24 symbols |
tests/test_bridges/test_quantum_annealing.py |
SCToQUBO.compile ↔ SCToIsing.compile |
independent compilers; both accept N×N matrix | dedicated tests for each |
SimulatedAnnealer.solve_ising Rust dispatch |
_HAS_RUST_QA and model.n_qubits > 10 branch |
covered when engine wheel present; falls through to Python otherwise |
DWaveInterface |
soft-imports dwave.system lazily |
tests skip when wheel absent |
export_bqm |
requires dimod; raises if absent |
dimod-skip path tested |
9. Tests¶
PYTHONPATH=src python3 -m pytest tests/test_bridges/test_quantum_annealing.py -q
# (part of the 198-test bridges suite — verified 2026-04-17)
tests/test_bridges/test_quantum_annealing.py is 652 lines
covering: dataclass round-trip, SCToQUBO/SCToIsing compilation
on small matrices, SimulatedAnnealer solver determinism with
fixed seed, EnergyLandscape exhaustive enumeration on ≤4 qubits
(matches Python brute-force), EmbeddingAnalyzer chain length
estimation, ChainBreakResolver majority-vote correctness,
GaugeTransform round-trip, TTSAnalyzer scaling estimate,
SampleAggregator de-duplication.
What is NOT covered:
- Rust speedup verification (engine wheel absent — task #49)
- Real D-Wave QPU submission (requires Leap account)
- Large-problem decomposition (ProblemDecomposer tested only on
N≤30; partition correctness at N=10⁴ would need stress test)
- DWaveInterface happy-path (skip-if-no-dwave)
10. Audit (7-point checklist)¶
| # | Dimension | Status | Detail |
|---|---|---|---|
| 1 | Pipeline wiring | ✅ PASS | All 24 symbols re-exported and tested |
| 2 | Multi-angle tests | ✅ PASS | 652-line dedicated test file in 198-test bridges suite |
| 3 | Rust path | ✅ PASS | All 6 PyO3 bindings re-exported via bridge/sc_neurocore_engine/__init__.py; _HAS_RUST_QA = True when wheel installed; SimulatedAnnealer.solve_ising dispatches via the n_qubits > 10 branch |
| 4 | Benchmarks | ✅ PASS | §6.1 Rust vs Python comparison: 5.8× (N=20), 761× (N=50), 1593× (N=100). §7 retains pure-Python numbers for reference |
| 5 | Performance docs | ✅ PASS | §7 with explicit "pure-Python only" caveat |
| 6 | Documentation page | ✅ PASS | This page |
| 7 | Rules followed | ✅ PASS | SPDX header ✅. Soft-imports for dimod, dwave-ocean-sdk, sc_neurocore_engine all guarded. British English in this doc; source uses standard scientific-Python identifiers (acceptable per docs-vs-code rule). |
Net: 0 WARN, 0 FAIL. Both former WARNs closed by task #49 —
engine wheel built via bridge/maturin develop --release,
re-exports added to sc_neurocore_engine.__init__, Rust speedup
measured (§6.1).
11. Known issues¶
11.1 Rust speedup (CLOSED by task #49)¶
§6.1 reports the measured comparison: 5.8× / 761× / 1593× at N=20/50/100. The docstring's "100×+" claim is conservative for N ≥ 50. The engine wheel must be installed in the active venv — see §6 for build instructions.
11.2 SCBitstreamQUBO and SCPrecisionEncoder (DOCUMENTED by task #50)¶
Both classes now have dedicated subsections under §3:
- §3.1 covers SCBitstreamQUBO.weight_optimization and .pruning
with the QUBO derivation, cardinality penalty pattern, and
source field outputs.
- §3.2 covers SCPrecisionEncoder with the three encodings
(binary / unary / one_hot), per-encoding qubit-vs-level
trade-off table, and round-trip accuracy bounds.
- §3.3 is a "when to use which compiler" table covering all four
compilers in this bridge (SCToIsing, SCToQUBO, SCBitstreamQUBO,
SCPrecisionEncoder).
11.3 No D-Wave hardware-parity test¶
SCToIsing → SimulatedAnnealer is tested. SCToIsing →
DWaveInterface → QPU → samples is not (no Leap account in CI).
Adding a parity test against neal.SimulatedAnnealingSampler
(D-Wave's reference SA) would validate the compiler output without
needing real hardware. Tracked as task #51.
11.4 EmbeddingAnalyzer assumes Pegasus topology¶
EmbeddingAnalyzer.__init__(topology="pegasus", size=16) defaults
to D-Wave Advantage's Pegasus graph. Older Chimera (D-Wave 2000Q)
and the new Zephyr (Advantage2) need explicit topology selection.
Document the topology options in the class docstring.
11.5 Rust dispatch threshold is hard-coded¶
SimulatedAnnealer.solve_ising only dispatches to Rust when
model.n_qubits > 10 (line 467). The threshold is a magic
number; expose as __init__ parameter or class constant.
12. References¶
Quantum annealing theory:
- Kadowaki T., Nishimori H. "Quantum annealing in the transverse Ising model." Phys Rev E 58:5355-5363 (1998). The original QA proposal.
- Farhi E. et al. "Quantum computation by adiabatic evolution." arXiv:quant-ph/0001106 (2000). Adiabatic quantum computation formalism.
D-Wave hardware + minor-embedding:
- Choi V. "Minor-embedding in adiabatic quantum computation: I.
The parameter setting problem." Quantum Inf Process 7:193-209
(2008). Minor-embedding theory for
EmbeddingAnalyzer. - Boothby K. et al. "Next-Generation Topology of D-Wave Quantum
Processors." arXiv:2003.00133 (2020). Pegasus topology used in
HardwareGraph.
Solvers + analysis:
- Rønnow T. F. et al. "Defining and detecting quantum speedup."
Science 345:420-424 (2014). TTS methodology used by
TTSAnalyzer. - Marshall J. et al. "Power of pausing: Advancing understanding
of thermalization in experimental quantum annealers." Phys Rev
Applied 11:044083 (2019). Inspiration for
AnnealingSchedulepause-and-quench. - Pelofske E. et al. "Decomposition Algorithms for Solving NP-hard
Problems on a Quantum Annealer." J Signal Process Syst 93:405-420
(2021).
ProblemDecomposerancestor. - Booth M. et al. "Partitioning Optimization Problems for Hybrid Classical/Quantum Execution." D-Wave Technical Report (2017). qbsolv methodology.
Internal:
- Bridges sister:
api/bridges/dna_mapper.md,api/bridges/photonic_noc.md - IBM Credits Application: outside this repo's scope; see agent-shared session logs for QPU access status.
13. Auto-rendered API¶
sc_neurocore.bridges.quantum_annealing
¶
Quantum annealing bridge for SC bitstream networks.
Compiles SC neural networks into Ising/QUBO representations suitable for D-Wave quantum annealers and classical simulated annealing solvers.
Architecture¶
::
SC Network → QUBO Compiler → Ising/QUBO Model → D-Wave / SA Solver
↓ ↓ ↓ ↓
Populations Gate→Coupling Energy landscape Ground state
Projections Weight→Field Partition function Optimal config
Module Structure¶
- Data classes:
QubitSpec,CouplerSpec,IsingModel,QUBOModel - Compilers:
SCToIsing,SCToQUBO - Solvers:
SimulatedAnnealer,DWaveInterface - Analysis:
EnergyLandscape,EmbeddingAnalyzer - Export:
export_bqm,export_qubo_json,export_ising_json
Dependencies¶
numpy— requireddwave-ocean-sdk— optional, soft-imported for D-Wave QPU accessdimod— optional, soft-imported for BQM interop
ProblemType
¶
Bases: Enum
Quantum optimization problem type.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
113 114 115 116 117 | |
QubitSpec
dataclass
¶
Specification for a single logical qubit.
Attributes¶
index : int Logical qubit index. label : str Human-readable label (e.g. neuron name). bias : float Local field / linear bias (h_i in Ising, Q_ii in QUBO).
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
CouplerSpec
dataclass
¶
Specification for a qubit-qubit coupling.
Attributes¶
qubit_a : int First qubit index. qubit_b : int Second qubit index. strength : float Coupling strength (J_ij in Ising, Q_ij in QUBO).
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
IsingModel
dataclass
¶
Ising spin-glass model: H = Σ h_i·s_i + Σ J_ij·s_i·s_j.
Attributes¶
h : dict[int, float] Linear biases (local fields). Key = qubit index. J : dict[tuple[int, int], float] Quadratic couplings. Key = (i, j) pair, i < j. offset : float Constant energy offset. qubit_labels : dict[int, str] Index → label mapping. n_qubits : int Total logical qubits. source : str Origin description.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
energy(spins)
¶
Compute Ising energy for a spin configuration.
Delegates to Rust engine when available for large models.
Parameters¶
spins : dict[int, int] Spin values (+1 or -1) per qubit index.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
QUBOModel
dataclass
¶
QUBO model: min x^T Q x.
Attributes¶
Q : dict[tuple[int, int], float] QUBO matrix entries. Diagonal = linear, off-diagonal = quadratic. offset : float Constant energy offset. qubit_labels : dict[int, str] Index → label mapping. n_qubits : int Total logical qubits. source : str Origin description.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
energy(bits)
¶
Compute QUBO energy for a binary configuration.
Parameters¶
bits : dict[int, int] Binary values (0 or 1) per qubit index.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
243 244 245 246 247 248 249 250 251 252 253 254 | |
to_ising()
¶
Convert QUBO to Ising model.
Uses the standard transformation: x_i = (s_i + 1) / 2.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
SCToIsing
¶
Compile SC network adjacency matrices into Ising models.
Maps SC populations to qubits and projections to couplings. Excitatory connections → ferromagnetic (J < 0, favoring alignment). Inhibitory connections → antiferromagnetic (J > 0, favoring anti-alignment).
Parameters¶
coupling_scale : float Multiplier applied to connection weights (default 1.0). field_scale : float Multiplier for external field from bias (default 0.1).
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | |
compile(adjacency, node_labels=None, biases=None, name='sc_ising')
¶
Compile adjacency matrix into an Ising model.
Parameters¶
adjacency : np.ndarray N×N weight matrix. Positive = excitatory, negative = inhibitory. node_labels : list[str] | None Labels for each node (default: n0, n1, ...). biases : np.ndarray | None 1D array of per-node biases (default: zeros). name : str Model name.
Returns¶
IsingModel
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | |
SCToQUBO
¶
Compile SC network into QUBO formulation.
Parameters¶
penalty : float Constraint penalty coefficient (default 2.0).
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
compile(adjacency, node_labels=None, name='sc_qubo')
¶
Compile adjacency matrix into a QUBO model.
Parameters¶
adjacency : np.ndarray N×N weight matrix. node_labels : list[str] | None Labels for each node. name : str Model name.
Returns¶
QUBOModel
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
SimulatedAnnealer
¶
Classical simulated annealing solver for Ising/QUBO models.
Implements the Metropolis-Hastings algorithm with exponential temperature schedule.
Parameters¶
n_sweeps : int Number of Monte Carlo sweeps (default 1000). beta_start : float Initial inverse temperature (default 0.1). beta_end : float Final inverse temperature (default 10.0). seed : int Random seed.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | |
solve_ising(model, num_reads=10)
¶
Solve an Ising model via simulated annealing.
Delegates to Rust engine when available (100×+ speedup for models with >20 qubits).
Parameters¶
model : IsingModel The Ising model to solve. num_reads : int Number of independent annealing runs.
Returns¶
dict
best_spins, best_energy, energies, samples.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | |
solve_qubo(model, num_reads=10)
¶
Solve a QUBO model via simulated annealing.
Converts to Ising internally, solves, then maps back to binary.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | |
DWaveInterface
¶
Interface to D-Wave quantum annealer via Ocean SDK.
Wraps DWaveSampler + EmbeddingComposite for transparent
minor-embedding. Falls back to simulated annealing if no QPU
is available.
Parameters¶
chain_strength : float Chain strength for embedding (default 2.0). num_reads : int Number of QPU reads (default 1000). annealing_time_us : float Annealing time in microseconds (default 20.0).
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | |
available
property
¶
Whether D-Wave SDK is available.
solve_ising(model)
¶
Submit Ising model to D-Wave QPU.
Falls back to SimulatedAnnealer if D-Wave unavailable.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | |
EnergyLandscape
¶
Analyze the energy landscape of an Ising model.
Computes energy statistics, degeneracy, spectral gap, and partition function (for small models).
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 | |
analyze(model, samples=None)
¶
Run landscape analysis.
Parameters¶
model : IsingModel The model to analyze. samples : list[dict] | None Optional pre-computed samples. If None, enumerates (for n ≤ 20) or samples randomly.
Returns¶
dict
min_energy, max_energy, mean_energy,
spectral_gap, degeneracy, n_unique_energies.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | |
EmbeddingAnalyzer
¶
Analyze embedding requirements for D-Wave hardware.
Computes logical-to-physical qubit ratios, chain length statistics, and connectivity requirements.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | |
analyze(model)
¶
Analyze embedding requirements.
Returns¶
dict
n_logical_qubits, n_couplers, density,
max_degree, min_chain_estimate.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | |
HardwareGraph
¶
D-Wave hardware graph topology model.
Generates adjacency structure for Chimera, Pegasus, and Zephyr topologies to enable embedding feasibility analysis.
Parameters¶
topology : str
One of chimera, pegasus, zephyr.
size : int
Topology size parameter (M for Chimera M×M×4,
M for Pegasus P(M), M for Zephyr Z(M)).
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 | |
n_physical_qubits
property
¶
Total physical qubits in this hardware graph.
connectivity
property
¶
Per-qubit connectivity.
can_embed(model)
¶
Check whether a model can be embedded on this hardware.
Returns¶
dict
embeddable, n_logical, n_physical_available,
estimated_physical_needed, utilization_pct.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 | |
ChainBreakResolver
¶
Post-process D-Wave samples to repair broken chains.
When a logical qubit is embedded as a chain of physical qubits, some physical qubits in the chain may disagree. This class resolves disagreements using majority vote or energy minimization.
Parameters¶
method : str
Resolution method: majority_vote or minimize_energy.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 | |
resolve(physical_samples, chains, model=None)
¶
Resolve chain breaks in physical samples.
Parameters¶
physical_samples : list[dict]
Raw physical qubit samples.
chains : dict[int, list[int]]
Logical qubit → list of physical qubit indices.
model : IsingModel | None
Required for minimize_energy method.
Returns¶
list[dict] Resolved logical-qubit samples.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 | |
analyze_breaks(physical_samples, chains)
¶
Analyze chain break statistics.
Returns¶
dict
total_breaks, break_rate, per_chain.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 | |
AnnealingSchedule
¶
Custom annealing schedule builder for D-Wave.
Supports linear, pause-and-quench, and reverse annealing protocols.
The schedule is a list of (time_us, s) points where s ∈ [0, 1] is the anneal fraction (0 = transverse field dominant, 1 = problem Hamiltonian dominant).
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 | |
points
property
¶
Schedule points as [(time_us, s), ...].
total_time_us
property
¶
Total annealing time in microseconds.
linear(duration_us=20.0)
¶
Standard linear anneal from s=0 to s=1.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1136 1137 1138 1139 | |
pause_and_quench(ramp_time_us=5.0, pause_at_s=0.4, pause_duration_us=50.0, quench_time_us=1.0)
¶
Pause-and-quench: ramp to s, hold, then quench to s=1.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | |
reverse(initial_s=1.0, reverse_to_s=0.3, ramp_time_us=5.0, hold_time_us=10.0, forward_time_us=5.0)
¶
Reverse annealing: start at s=1, go back, then forward.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 | |
to_dict()
¶
Export schedule as dict for D-Wave API.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1188 1189 1190 1191 1192 1193 1194 | |
GaugeTransform
¶
Random gauge transformations for improved sampling.
Applies random spin-flip transformations (g_i ∈ {+1, -1}) to the Ising model: h'_i = g_i · h_i, J'_ij = g_i · g_j · J_ij. This breaks systematic QPU biases without changing the energy landscape.
Parameters¶
n_gauges : int Number of gauge transforms to apply (default 10). seed : int Random seed.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 | |
transform(model)
¶
Generate gauge-transformed copies of the model.
Returns¶
list[IsingModel] List of gauge-transformed models.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 | |
untransform_sample(sample, gauge)
¶
Undo gauge transform on a sample.
Parameters¶
sample : dict Transformed spin assignment. gauge : dict Gauge vector used for the transform.
Returns¶
dict Original-frame spin assignment.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 | |
SCBitstreamQUBO
¶
SC-specific QUBO formulations for bitstream optimization.
Provides problem-specific encodings for common SC optimization tasks: - Weight optimization: Find binary weight mask that minimizes network error. - Pruning: Select minimal subset of connections preserving accuracy. - Topology search: Binary selection of connections from a candidate set.
Parameters¶
penalty : float Constraint violation penalty (default 5.0).
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 | |
weight_optimization(target_output, candidate_weights, n_bits=8)
¶
Formulate weight optimization as QUBO.
Find binary vector x ∈ {0,1}^n that minimizes ||target - candidate_weights @ x||².
Parameters¶
target_output : np.ndarray Desired output vector (m,). candidate_weights : np.ndarray Weight matrix (m × n). n_bits : int Number of binary decision variables.
Returns¶
QUBOModel
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 | |
pruning(adjacency, importance_scores, max_connections)
¶
Formulate network pruning as QUBO.
Parameters¶
adjacency : np.ndarray N×N weight matrix (connections to consider). importance_scores : np.ndarray N×N importance scores (higher = more important). max_connections : int Maximum number of connections to keep.
Returns¶
QUBOModel
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 | |
SampleAggregator
¶
Post-process and aggregate quantum annealing samples.
Provides filtering, deduplication, energy histogram, and Boltzmann-weighted statistics.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 | |
aggregate(samples, energies, temperature=1.0)
¶
Aggregate and analyze sample set.
Parameters¶
samples : list[dict] Spin/bit configurations. energies : list[float] Corresponding energies. temperature : float Temperature for Boltzmann weighting.
Returns¶
dict
unique_samples, best, histogram,
boltzmann_avg_energy, success_probability.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 | |
SCPrecisionEncoder
¶
Encode SC probability values as qubit configurations.
SC values are continuous probabilities in [0, 1]. Quantum annealers operate on binary variables. This encoder provides three strategies for mapping SC precision to qubits:
- binary: k qubits encode 2^k levels (compact but coupled)
- unary: k qubits encode k+1 levels (robust but expensive)
- one_hot: k qubits encode k levels (good for categorical)
Parameters¶
encoding : str
One of binary, unary, one_hot.
n_bits : int
Number of qubits per SC value (default 8).
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 | |
n_levels
property
¶
Number of representable precision levels.
encode(sc_value)
¶
Encode an SC probability as qubit configuration.
Parameters¶
sc_value : float SC value in [0, 1].
Returns¶
dict[int, int] Qubit index → binary value.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 | |
decode(qubits)
¶
Decode qubit configuration back to SC probability.
Parameters¶
qubits : dict[int, int] Qubit index → binary value.
Returns¶
float Reconstructed SC value in [0, 1].
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 | |
qubits_needed(n_sc_values)
¶
Total qubits needed to encode n SC values.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1580 1581 1582 | |
encode_array(values)
¶
Encode array of SC values into a single qubit dict.
Parameters¶
values : np.ndarray 1D array of SC values.
Returns¶
dict[int, int] Global qubit index → binary value.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 | |
ProblemDecomposer
¶
Decompose large QUBO/Ising into sub-problems for QPU.
When a model exceeds QPU capacity, this class partitions it into smaller sub-problems that fit on hardware, solves each, then merges the results.
Parameters¶
max_subproblem_size : int Maximum qubits per sub-problem (default 64 for Chimera unit cell). overlap : int Number of shared qubits between partitions (default 4). n_iterations : int Number of decomposition-merge iterations (default 10).
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 | |
decompose(model)
¶
Partition Ising model into sub-problems.
Uses a greedy graph partitioning that keeps strongly-coupled qubits together.
Parameters¶
model : IsingModel The model to decompose.
Returns¶
list[IsingModel] Sub-problems, each ≤ max_subproblem_size qubits.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 | |
solve_decomposed(model, solver=None)
¶
Decompose, solve sub-problems, and merge.
Parameters¶
model : IsingModel The full model. solver : SimulatedAnnealer | None Solver for sub-problems (default: new SA).
Returns¶
dict
best_spins, best_energy, n_partitions.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 | |
TTSAnalyzer
¶
Time-to-solution quality metric for quantum annealing.
TTS measures the total time required to find the ground state with probability p_target, given: - p_success: probability of finding ground state in a single run - t_anneal: time per annealing run
TTS = t_anneal × (log(1 - p_target) / log(1 - p_success))
This is the standard benchmark metric used in D-Wave literature.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 | |
compute(p_success, t_anneal_us, p_target=0.99)
¶
Compute TTS metric.
Parameters¶
p_success : float Probability of finding ground state per run. t_anneal_us : float Time per annealing run in microseconds. p_target : float Target cumulative success probability (default 0.99).
Returns¶
dict
tts_us, tts_ms, n_runs_needed,
p_success, p_target.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 | |
from_samples(energies, ground_state_energy, t_anneal_us=20.0, tolerance=1e-06, p_target=0.99)
¶
Compute TTS from a set of sample energies.
Parameters¶
energies : list[float] Observed sample energies. ground_state_energy : float Known or estimated ground state energy. t_anneal_us : float Time per annealing run. tolerance : float Energy tolerance for ground state match. p_target : float Target success probability.
Returns¶
dict TTS metrics.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 | |
compare_solvers(results, ground_state_energy, tolerance=1e-06)
¶
Compare TTS across multiple solvers.
Parameters¶
results : dict Solver name → {energies, t_anneal_us}. ground_state_energy : float Known ground state energy.
Returns¶
dict Solver name → TTS metrics.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 | |
export_ising_json(model, path)
¶
Export Ising model to JSON format.
Parameters¶
model : IsingModel The model to export. path : str Output file path.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 | |
export_qubo_json(model, path)
¶
Export QUBO model to JSON format.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
854 855 856 857 858 859 860 861 862 863 864 865 | |
export_bqm(model)
¶
Export Ising model as a dimod BinaryQuadraticModel.
Returns¶
dimod.BinaryQuadraticModel or None BQM object, or None if dimod is not installed.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
868 869 870 871 872 873 874 875 876 877 878 | |
visualize_ising(model)
¶
Generate ASCII visualization of an Ising model.
Returns¶
str Multi-line ASCII representation.
Source code in src/sc_neurocore/bridges/quantum_annealing.py
| Python | |
|---|---|
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | |
7. Performance benchmarks¶
Output from bench_quantum_annealing.py¶
SC-NeuroCore Quantum Annealing Benchmark
Rust backend available: False
============================================================
BENCHMARK: Ising Energy Evaluation
============================================================
N Python (µs) Rust (µs) Speedup
------------------------------------------------------------
10 10.5 N/A N/A
20 42.1 N/A N/A
50 190.1 N/A N/A
100 470.3 N/A N/A
============================================================
BENCHMARK: Batch Energy (10000 configurations)
============================================================
N Python (ms) Rust (ms) Speedup
------------------------------------------------------------
10 49.2 N/A N/A
20 190.7 N/A N/A
50 1175.1 N/A N/A
============================================================
BENCHMARK: Simulated Annealing (1000 sweeps × 10 reads)
============================================================
N Python (ms) Rust (ms) Speedup
------------------------------------------------------------
10 235.8 N/A N/A
20 1317.8 N/A N/A
50 17721.0 N/A N/A
============================================================
BENCHMARK COMPLETE
============================================================