Skip to content
lfdPublic

About

QPX: An Open Platform for Cycle-Accurate, Closed-Loop Simulation of Distributed Quantum Control Systems

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

QPX

Quantum Platform eXperiments.

Multi-unit cycle-accurate simulation and FPGA platform for real-time control architectures targeting fault-tolerant quantum computers. An experimentation platform for the system layers. Do not expect anything to work, and keep the reset button in reach. :-)

Documentation of the current reference architecture: see doc/. The engine's own specifications, its instruction set, register window and program format, are under doc/qpx-ee/.

Development shell

direnv allow        # or: nix develop

LiteX is not provided by Nix. Install it editable into .venv, once:

( cd srcs/litex && python litex/litex_setup.py --init --install )

Running a simulation

make sim-tmux

One tmux session: simulator, quantum model and a shell on the left, one console per unit on the right. Consoles are also on TCP 2000 + <unit id>, and with --with-uartbone each unit's bus is on 3000 + <unit id>.

By hand, the model comes first. make sim connects at startup and fails if nothing listens:

export QPX_SYSTEM=configs/demo/system.toml  # the model reads the system too
make qsim && qpx-qsim-libquantum -v     # one terminal
make sim                                # another

The units need host networking before anything can reach them:

make tap-create     # TAPs and the qpxbr bridge, calls sudo ip itself
make check-taps     # what the host side looks like now

What is being simulated

The simulation runs the RTL of the whole system:

  • One complete SoC per unit, that is per [nodes.N] entry of system.toml with a unit, each booting Zephyr out of simulated SDRAM, each taking its identity from its own descriptor.
  • Their QPX engines on one shared, phase-locked clock, counting the same global timebase.
  • The link between them, with the configured publish latency: a change of the global state arrives that many ticks later.
  • The analog side as behavioural models: a fired pulse becomes a gate, a capture becomes a measurement, both at the tick the engine says.

The physics of the control electronics is outside the simulation. A channel is a behavioural model without waveform synthesis, and the qubits live in a separate model service.

What you see

  • sim pane: LiteX and Verilator, then the effective clock rate. A run is far slower than wall clock, expect around 0.03x, reported every 5 s.
  • qsim pane: the model's log
  • unit panes: Zephyr booting, then qpxd saying which unit it is and what port it listens on. From here the unit waits for QCP.

Demo time!

In the free pane at the bottom left. Booting takes a while, which is what the first command is for:

qpx-ctl system wait_online -t 120                    # units answer once booted
qpx-ctl system run -n 32 build/qpx/demos/ghz.qab     # load, arm, 32 shots

ghz.qab is seven qubits across three units: h q0 then a chain of six cx around the ring coupling map, ending in (|0000000> + |1111111>)/sqrt(2). Each cx lowers to h cz h, and the halves can land on different units. Three of the six cz pulses are played by a unit that does not drive the target's XY line at all.

What to expect:

  • Each unit acknowledges its image, then the system starts on one T=0 release.
  • The qsim pane fills with the gates the pulses resolved into.
  • Every unit reads only its own qubits, so the state appears when the host joins the three streams by shot index: 0000000 and 1111111 at half each, the other 126 outcomes empty.
  • The units exchange no bit for this. A gate split across units works because all three count from the same T=0.

Other things to try: qpx-ctl unit <id> stat reports one unit, qpx-ctl system halt ends the simulation. build/qpx/demos/ holds the rest, among them bell.qab, rendezvous.qab and the readback-* feed-forward cases.

Simulation architecture

  tools/qpx-ctl ──────┐  QCP to the units, TCP     tools/qpx-descriptors
                      │                            tools/qpx-net
                   ┌──┴──┐
                   │qpxbr│  host bridge
                   └──┬──┘
       qpx0 ──────────┼────────── qpx1, qpx2    one TAP per unit
                      │
 ╔════════════════════╪══════════════════════════════════════════════╗
 ║ Verilator: flattened model, units in lockstep                     ║
 ║  ┌─ unit 0 ────────┴───────────────────┐  ┌ unit 1 ┐┌ unit 2 ┐    ║
 ║  │ ┌─────────────────────────────────┐ │  │        ││        │    ║
 ║  │ │ VexiiRiscv rv32, M-mode         │ │  │        ││        │    ║
 ║  │ │ Zephyr + qpxd, uart on TCP      │ │  │  ...   ││  ...   │    ║
 ║  │ └───────▲──────────────────┬──────┘ │  │        ││        │    ║
 ║  │       IRQ            Wishbone       │  │        ││        │    ║
 ║  │         │           MMIO  │         │  │        ││        │    ║
 ║  │ ········┼··················┼······· │  │ ·······││······· │    ║
 ║  │ ┌───────┴──────────────────▼──────┐ │  │        ││        │    ║
 ║  │ │ QPX engine                      │ │  │        ││        │    ║
 ║  │ │ dispatch, per-channel delays    │ │  │        ││        │    ║
 ║  │ │ sreg, 64-bit timebase from T=0  │ │  │        ││        │    ║
 ║  │ └───────┬──────────────────┬──────┘ │  └───┬────┘└───┬────┘    ║
 ║  └─────────┼──────────────────┼────────┘      │         │         ║
 ║       fire ports       state segment ─────────┴─────────┘         ║
 ╚══════════╪══════════════════╪═════════════════════════════════════╝
            │                  ▼
            │          qpxlink: state segment, D_pub ticks
            ▼
      qpxsim: copy of the QAB, pulse → gate, capture → measurement
            │  QSIM
            ▼
  qpx-qsim-<model>: replaceable quantum simulator, own process

  On the host's loopback device via vsim:
    qpxhub  the common start of all units' timebases
    qpxsim  the program qpxsim follows

Dotted line: clock domain boundary, sys above, system-wide qpx below.

Program

  • .qgs gate schedule, lowered against the bundle's layout and calibration into .qas, assembled into a .qab container.
  • One container covers the system: one image per unit.
  • make demos builds them into build/qpx/demos/.

Unit, instantiated once per [nodes.N] entry with a unit

  • VexiiRiscv rv32, M-mode only. No firmware below it; Zephyr boots directly out of simulated SDRAM.
  • One zephyr.bin for the whole system. Identity comes from a descriptor in the last page of SDRAM, which the devicetree withholds from the kernel.
  • The devicetree declares qpx, which is how the operating system discovers underlying hardware parameters.
  • UART on TCP. Ethernet on a TAP per unit, bridged on the host by qpxbr.

qpxd, under Zephyr

  • QCP over TCP on the network side to MMIO and IRQs on device side.
  • Loads the unit's image, arms the engine, streams shots and status back.
  • Hardware uses the same path.

Engine

  • Own SpinalHDL project, generated to build/qpx/verilog/, one netlist per variant of unit, and instantiated by LiteX as a Verilog blackbox. The core is generated separately, also from SpinalHDL; the two are wired at the Verilog level and are not elaborated together.
  • Wishbone MMIO window on the SoC bus for control, one interrupt line back.
  • Dispatch, per-channel delay lines, state register, 64-bit timebase counting from the system's T=0.
  • Fire ports to the channels, committed state segment to the link.

System timing

  • qpxlink publishes a unit's state segment to every unit, D_pub ticks later. Set at run time, and programs are written against it.
  • One shared phase-locked qpx clock. The units run in lockstep, and runs are reproducible.
  • Timebase is the GCD of all half-periods and phase shifts, so the fastest clock sets the cost of every simulated second.
  • All sys clocks run in phase, so the GCD stays as large as the system's frequencies allow.

Quantum model

  • qpxsim holds a copy of the loaded QAB, and resolves a fired pulse into a gate on specific qubits.
  • Gates go from the Verilated simulation, synchronously, over a line protocol to the model service (doc/QSIM.md).
  • The service is a separate process; replacing it replaces the physics without a rebuild.
  • Measurements return into the engine's state register, so feed-forward acts on the results of the model.

Targets

make on its own builds and runs the simulation.

target what it does
sim build the SoC, Zephyr, the demos and the model, then run Verilator
sim-tmux the same in one tmux session, with a pane per unit console
bitstream build the FPGA bitstream (needs TARGET=<board> and Vivado)
load load the bitstream onto the board
qpx build the QPX tools into build/qpx/stage/bin
qpx-verilog generate the engine Verilog into build/qpx/verilog
demos assemble the bundle's demo programs into build/qpx/demos
descriptors per-unit device trees and boot images
zephyr build the control-plane kernel and its overlay
libquantum build the state vector library
qsim build the quantum model services (doc/QSIM.md)
tap-create/tap-destroy host TAPs and the qpxbr bridge (root)
check-taps report what the host network looks like
clean remove build/

make qpx stages five launchers; each takes --help.

tool what it does
qpx-asm assemble, disassemble, lower a .qgs against a machine
qpx-gen the engine Verilog, the C headers, qpx_qab.py, a dts
qpx-sim the whole engine against the golden model
qpx-test every suite in one run
qpx-repl step a program on the golden model, no simulator needed

Variables

variable default meaning
TARGET sim sim or a board (vcu118)
VARIANT 2q2c variant of unit a bitstream is for; boards only
QPX_CONFIG demo configuration bundle under configs/<name>/
QPX_SYSTEM configs/<name>/system.toml the system; follows from QPX_CONFIG, set it for a system outside configs/
QPX_QSIM build/qsim/qpx-qsim-libquantum the quantum model that sim-tmux starts
CORES 1 harts per unit
SIM_THREADS 1 Verilator threads
QPX_CLK_RATIO 1 QPX clock as a multiple of the sys clock
ZEPHYR_CPU_HZ 1000000 the clock the kernel is told it has, so its timeouts pass at about wall speed; sim only, empty leaves the SoC's rate
EXTRA_ARGS extra SoC generator flags, e.g. --non-interactive --trace
BUILD_DIR build where everything lands

Unit count, wiring and publish latency belong to the configuration bundle, not the build: configs/<name>/system.toml, described in doc/CONFIG.md.

A bitstream is built for one variant of unit and lands in build/<target>-<variant>/. The descriptor in the SDRAM of a board decides which node of the system the board is, so two boards of the same variant run the same bitstream.

License

GPL-2.0-only, see COPYING.

This project ships no binaries; everyone builds their own.

Use of generative AI

The source code and the documentation were developed with the assistance of Claude Opus and Claude Fable (Anthropic).

About

QPX: An Open Platform for Cycle-Accurate, Closed-Loop Simulation of Distributed Quantum Control Systems

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages