uniqc.noise_bridge.exchange module

Consumer side of the versioned noise-model exchange (nlearn.noise-model.v1).

This module imports the offline noise-model exchange files produced by the noise-learning product (schema nlearn.noise-model.v1, consumer binding uniqc.noisy_simulator.v1) and wires them into UniQC’s frozen noisy simulation stack — uniqc.simulator.NoisySimulator (density-operator backend) and uniqc.backend_adapter.task.adapters.dummy_adapter.DummyAdapter.

The exchange is data-only: UniQC never imports the private nlearn package; everything needed to rebuild the channels is inside the JSON file (Pauli probabilities, readout pairs, topology, layout) and integrity is guarded by the file’s canonical model_sha256. Model files declare new_hardware_run: false — importing one performs no new hardware run.

Capabilities exposed on top of the imported model:

exception uniqc.noise_bridge.exchange.ExchangeModelError[source]

Bases: ValueError

Raised when a noise-model exchange file fails validation.

class uniqc.noise_bridge.exchange.ImportedNoiseModel(payload, path)[source]

Bases: object

A validated nlearn.noise-model.v1 file wired for UniQC execution.

Local qubit i of the model maps to physical qubit physical_chain[i]; error channels, topology, and readout rates are addressed in local indices so the simulator can run on a compact register.

apply_edge_flips(outcome, rng)[source]

Apply the post-measurement XOR mixture to one outcome integer.

property data_class
edge_flip_entries()[source]

Post-measurement stochastic XOR-mixture entries (already local).

error_loader()[source]

Build the per-gate-instance error loader from the uniqc binding.

property generator
property local_edges
property model_sha256
property num_qubits
path
payload
property physical_chain
readout_error()[source]

Per-local-qubit readout error {q: [p01, p10]}.

simulate_counts(circuit, *, shots, seed, qram_data=None)[source]

Execute circuit on the learned noisy VM and sample shot counts.

Parameters:
  • circuit – Circuit object or OriginIR string. Gates must live on local qubits 0..n-1; use RPhi/CZ to exercise the learned channels (RZ is virtual and noiseless per the model).

  • shots – Number of shots.

  • seed – Seed for shot sampling and the edge-flip mixture.

  • qram_data – Optional {qram_name: {address: value}} preloaded into the simulator’s QRAM objects before execution.

Returns:

Counts keyed by bitstring with local qubit i = character n-1-i (c[i] rightmost, the UniQC endianness convention).

to_adapter(backend_id='dummy:noise-model')[source]

A DummyAdapter wired with the learned channels (unified pipeline).

to_simulator()[source]

A density-operator NoisySimulator carrying the learned channels.

uniqc.noise_bridge.exchange.load_noise_model(path)[source]

Load and validate a nlearn.noise-model.v1 exchange file.

uniqc.noise_bridge.exchange.validate_exchange_payload(payload)[source]

Structural + integrity validation (mirrors the producer’s own checks).