torch_sci_solver.shots¶
Load measured shots (bitstring -> weight) into a Qiskit BitArray for the SQD loop.
load_shots
¶
load_shots(path: str) -> dict
Load shots from pickle (.pkl) or NumPy (.npz) format.
Each key is a '0'/'1' string of length 2 * norb (spin-down in
the right half, spin-up in the left half, as produced by Qiskit sampling).
Values may be integer counts or floating-point probabilities; only their
relative magnitudes matter.
Supports: - .pkl: pickled dict mapping bitstring -> weight - .npz: NumPy archive with 'packed' bitstrings and 'L' (total bits)
shots_to_bit_array
¶
shots_to_bit_array(shots: dict, *, max_total_shots: int = 2000000)
Build a Qiskit BitArray from a bitstring -> weight mapping.
Weights are converted to integer counts scaled so the smallest positive
weight maps to 1 (preserving relative frequencies); uniform weights give one
shot per unique bitstring. If the resulting total would exceed
max_total_shots, the counts are rescaled down to stay within that bound.
load_shots_bit_array
¶
load_shots_bit_array(path: str, *, max_total_shots: int = 2000000)
Load shots and return a Qiskit BitArray.
For .npz files (packed bitstrings) this uses a fast path that builds
the BitArray directly from the packed uint8 data — bypassing the
intermediate shots dict entirely. At 2 M shots this takes ~0.4 s
instead of ~60 s for the dict roundtrip.
For .pkl files the original load_shots → shots_to_bit_array
path is used unchanged.