Solvers¶
Combinatorial optimization via SC-native Ising machines.
StochasticIsingGraph— Quantum-inspired Ising solver. Spins S_i in {-1, +1} (mapped to 0/1 for SC). Energy:E = -Sum(J_ij * S_i * S_j) - Sum(h_i * S_i). Finds minimum-energy configuration via simulated annealing with SC arithmetic.
Maps to SC hardware: spin products = AND gates, energy accumulation = popcount.
import numpy as np
from sc_neurocore.solvers import StochasticIsingGraph
J = np.random.randn(10, 10)
J = (J + J.T) / 2
np.fill_diagonal(J, 0)
solver = StochasticIsingGraph(num_spins=10, J=J)
solution = solver.solve(n_steps=1000)
sc_neurocore.solvers.ising
¶
Quantum-inspired Ising machine solver with stochastic Metropolis annealing.
StochasticIsingGraph
dataclass
¶
Quantum-Inspired Ising Machine Solver.
Spins S_i in {-1, 1} (mapped to 0, 1 for SC). Energy E = -Sum(J_ij * S_i * S_j) - Sum(h_i * S_i). Goal: Find configuration that minimizes E.
Source code in src/sc_neurocore/solvers/ising.py
| Python | |
|---|---|
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
__post_init__()
¶
Initialise random spins and their bipolar {-1, 1} representation.
Source code in src/sc_neurocore/solvers/ising.py
| Python | |
|---|---|
33 34 35 36 37 38 | |
step()
¶
Perform one parallel Metropolis-Hastings update and return the energy.
Returns¶
float The global Ising energy after applying the accepted spin flips.
Source code in src/sc_neurocore/solvers/ising.py
| Python | |
|---|---|
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
get_energy()
¶
Calculate global energy.
Source code in src/sc_neurocore/solvers/ising.py
| Python | |
|---|---|
82 83 84 85 86 87 88 | |
get_config()
¶
Return the current spin configuration as a 0/1 int8 array.
Source code in src/sc_neurocore/solvers/ising.py
| Python | |
|---|---|
90 91 92 | |
Exact-current LIF profile¶
ExactCurrentLIFProfile is the versioned semantic contract for the existing
ExactLIFSolver exact-flow, hard-reset current-based LIF model. Its canonical JSON and
SHA-256 bind the equation, model-source bytes, parameters, normalized units,
piecewise-constant input family, analytical crossing solver, inclusive
threshold, hard reset, zero refractory interval, explicit shot reset,
binary64 behavior, and absence of stochastic state. Unknown fields, schema
versions, unit changes, source drift, and digest mismatches fail closed.
ExactCurrentLIFSession preserves voltage and shot-relative time across calls.
Each call returns an immutable packet containing the exact producer commit,
profile digest, input ticks, initial and final state, exact spike events, and an
ordered state trace. Threshold and reset samples share the analytical crossing
timestamp, so downstream consumers do not have to infer event ordering from a
grid-aligned spike count.
from sc_neurocore.solvers import (
CurrentDriveTick,
ExactCurrentLIFProfile,
ExactCurrentLIFSession,
)
profile = ExactCurrentLIFProfile(tau_ms=10.0)
session = ExactCurrentLIFSession(
profile,
producer_commit="0123456789abcdef0123456789abcdef01234567",
shot_id="mif-shot-17",
)
packet = session.execute(
[
CurrentDriveTick(duration_ms=2.0, currents=(10.0, 20.0)),
CurrentDriveTick(duration_ms=3.0, currents=(30.0,)),
]
)
assert packet.profile_digest == profile.digest
checkpoint = session.serialize_state()
validated = type(packet).from_json(
packet.to_json(),
profile=profile,
expected_producer_commit="0123456789abcdef0123456789abcdef01234567",
)
assert validated == packet
The canonical default profile and a four-tick complete-state receipt are shipped
as exact_current_lif_profile_v1.json and
exact_current_lif_multitick_v1.json under
src/sc_neurocore/neurons/reference_trace_data/. The receipt binds its profile
digest and the exact implementation commit and includes three off-grid events.
The profile is a precise software/reference contract. It does not by itself claim fixed-point equivalence, generated RTL parity, synthesis timing, PPA, board/HIL evidence, or biological fidelity. Those remain separate gates.
sc_neurocore.solvers.exact_lif_profile
¶
Digest-bound, stateful execution for the exact-current SC LIF profile.
The profile binds the existing :class:ExactLIFSolver implementation rather
than introducing another neuron model. It makes the solver, units, event
ordering, reset boundary and numerical behaviour explicit for consumers.
ExactCurrentLIFProfile
dataclass
¶
Immutable parameters and semantics for one exact-current LIF instance.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 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 217 218 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 | |
digest
property
¶
Return the SHA-256 of canonical profile JSON.
to_payload()
¶
Return the complete canonical profile payload.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 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 | |
to_json()
¶
Serialize the profile canonically.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
219 220 221 | |
verify_source_binding()
¶
Fail closed if the shipped model source differs from this profile.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
223 224 225 226 227 228 229 230 | |
from_json(serialized)
classmethod
¶
Parse strict canonical semantics; reject versions, fields and units.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
CurrentDriveTick
dataclass
¶
One duration with simultaneous piecewise-constant current inputs.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
total_current
property
¶
Return the order-independent sum delivered at tick start.
ExactLIFState
dataclass
¶
Complete persistent runtime state at a shot-relative instant.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
ExactLIFStateSample
dataclass
¶
One ordered point in the complete execution state trace.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
ExactLIFEvent
dataclass
¶
One exact threshold-crossing event.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
ExactLIFExecutionPacket
dataclass
¶
Immutable complete trace and provenance packet for one execute call.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 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 430 431 432 433 434 435 436 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 | |
to_json()
¶
Serialize the packet canonically for deterministic evidence.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
382 383 384 | |
from_json(serialized, *, profile, expected_producer_commit)
classmethod
¶
Validate a packet by strict parsing and deterministic replay.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
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 430 431 432 433 434 435 436 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 | |
ExactCurrentLIFSession
¶
Stateful, failure-atomic executor for :class:ExactCurrentLIFProfile.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
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 | |
state
property
¶
Return the current immutable persistent state.
reset_shot(shot_id)
¶
Reset voltage and time explicitly at a new shot boundary.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
490 491 492 493 494 | |
serialize_state()
¶
Serialize state with the exact profile digest.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
496 497 498 499 500 501 502 503 504 | |
restore_state(serialized)
¶
Restore compatible state atomically; reject drift and unknown fields.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
execute(ticks)
¶
Execute a complete current sequence and commit state only on success.
Source code in src/sc_neurocore/solvers/exact_lif_profile.py
| Python | |
|---|---|
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 | |