QuantumOS is a Python discrete-event simulator for exploring operating-system resource management in a Photonic-style, entanglement-first quantum computer.
The simulator is intended as a sensitivity instrument, not a point predictor. It models how systems-level behavior changes as physics-facing parameters vary: heralding probability, entanglement freshness, memory access cost, decoder service time, switch-fabric contention, and deadline slack.
The working hypothesis is that a quantum OS for this architecture must treat entanglement leases, syndrome rounds, decoder capacity, switch paths, and calibration epochs as first-class schedulable resources. This repository is the executable counterpart to that design argument.
The methodological stance is deliberate: this is not a place that accumulates
concepts, but "a place that tests whether concepts deserve to exist" (external
methods review, 2026-07-07). No quantity enters the object model merely for
being physically meaningful — it must name the decision that reads it, the lead
time it is read at, and why it is not derivable from cheaper represented state.
The governing rule and the pre-registered experiments that enforce it live in
docs/superpowers/specs/2026-07-06-field-battery-prereg.md.
This is an M0 research simulator. The core package and tests are implemented, with a small experimental CLI for running checked-in configs and summarizing run traces.
At a high level, one simulated syndrome round flows through:
- A closed-loop workload generator emits a round request.
- A scheduler admits, defers, or rejects work.
- Lease requests reserve switch-fabric paths.
- Heralding attempts stochastically produce entanglement.
- Freshness and memory-access models update effective fidelity.
- A decoder job enters a single-server backlog.
- Round success is sampled and all state transitions are traced.
The current implementation includes:
S0: baseline scheduler without explicit freshness-aware admission.S1: scheduler with admission-control and pre-generation hooks.- Pluggable model surfaces for decay, heralding, memory access, round success, and decoder service.
- Keyed random-number draws for deterministic paired-policy comparisons.
- JSONL trace output plus post-hoc observability views.
qsim/
core/ DES engine, event heap, keyed RNG, trace bus, invariants
entities/ Inert dataclass object model: leases, rounds, modules, qubits
experiments/ Run configuration and single-run driver
models/ Physics/model Protocols and analytic M0 implementations
observe/ Run-directory writer, metric views, work accounting
policies/ Scheduler protocol and S0/S1 policies
workload/ Closed-loop synthetic workload generator
docs/
quantum_os.md Constraint-first OS argument
superpowers/specs/...design.md Simulator design spec
references/ Supporting reference material
examples/ CLI-ready experiment configs
tests/ Unit and integration tests
timestamps/ OpenTimestamps artifacts
scripts/ Repository helper scripts
- Python 3.14 or newer, as declared in
pyproject.toml uvfor dependency management, or another tool that can install frompyproject.toml
Runtime dependencies are intentionally small. The only declared dependency is
opentimestamps-client, used by repository timestamp tooling rather than the
simulator core.
uv syncIf you are not using uv, create a Python 3.14 environment and install the
project dependencies from pyproject.toml.
uv run pytestThe test suite covers the object model, model surfaces, scheduler behavior, engine lifecycle, observability views, workload generation, and deterministic trace behavior.
The CLI runs TOML or JSON experiment configs:
uv run quantumos validate-config examples/s0-baseline.toml
uv run quantumos run examples/s0-baseline.toml --out runs --summary
uv run quantumos summarize runs/<run-id>
uv run quantumos compare examples/s0-baseline.toml examples/s1-admission.toml --out runs/compare --seed 42The TOML config format keeps path calibration entries as records:
run_seed = 42
scheduler = "S0"
arrival_rate_hz = 1.0
leases_per_round = 1
deadline_slack_s = 5.0
switch_capacity_c = 1
reconfig_delay_s = 0.01
max_sim_time_s = 20.0
[epoch]
epoch_id = "example-s0"
memory_access_channel_s = 0.001
memory_access_wear_rate = 0.01
round_success_logistic_midpoint = 0.5
round_success_logistic_slope = 10.0
round_success_slack_penalty_per_s = 1.0
decoder_service_rate = 5.0
[epoch.decay_rate_per_class]
messenger = 0.01
memory = 0.001
[[epoch.paths]]
a = "M0:0"
b = "M1:0"
heralding_p = 0.7
heralded_fidelity = 0.95Experiments can also be launched from Python:
from pathlib import Path
from qsim.entities import CalibrationEpoch, CoherenceClass, PortId, make_path_id
from qsim.experiments.config import RunConfig
from qsim.experiments.run import run
a = PortId(module_id="M0", port_index=0)
b = PortId(module_id="M1", port_index=0)
path = make_path_id(a, b)
epoch = CalibrationEpoch(
epoch_id="example",
decay_rate_per_class={
CoherenceClass.MESSENGER: 0.01,
CoherenceClass.MEMORY: 0.001,
},
memory_access_channel_s=0.001,
memory_access_wear_rate=0.01,
heralding_p_per_path={path: 0.7},
heralded_fidelity_per_path={path: 0.95},
round_success_logistic_midpoint=0.5,
round_success_logistic_slope=10.0,
round_success_slack_penalty_per_s=1.0,
decoder_service_rate=5.0,
)
config = RunConfig(
run_seed=42,
scheduler="S0",
epoch=epoch,
arrival_rate_hz=1.0,
leases_per_round=1,
deadline_slack_s=5.0,
switch_capacity_c=1,
reconfig_delay_s=0.01,
max_sim_time_s=20.0,
)
run_dir = run(config, Path("runs"))
print(run_dir)Each run creates a directory containing:
header.json: configuration, seed, git provenance, filtering declarations, and steady-state verdict.events.jsonl: the full event trace emitted by the simulation.
Post-hoc metric functions live in qsim.observe.views and operate on an
events.jsonl path:
goodputfreshness_at_consumptionfidelity_at_outcomedecoder_backlog_seriesdeadline_complianceresource_utilizationlogical_error_proxyshared_key_fraction
Example:
from qsim.observe import views
events = run_dir / "events.jsonl"
print(views.goodput(events))
print(views.deadline_compliance(events))Start with:
docs/quantum_os.mdfor the constraint-first quantum OS framing.docs/superpowers/specs/2026-07-04-quantum-os-simulator-design.mdfor the simulator architecture and M0 design contract.docs/superpowers/specs/2026-07-06-field-battery-prereg.mdfor the pre-registered field battery and the object-model admission rule.
The simulator intentionally keeps physics details behind Protocol-based model surfaces so analytic M0 implementations can later be replaced by richer physicist-supplied or stabilizer-backed models.