Skip to content

Commit 20b7637

Browse files
david-plclaudeCopilot
authored
feat(ppvm-vihaco): add the composite machine and VM (#174)
## Merge order Part of the #168 split. This PR targets **#173** (`david/42.2-circuit-component`) and sits at the top of the vihaco line: 1. RotXY / R gate (#170) → `main` ✅ merged 2. tableau expectation/reset (#172) → `main` ✅ merged 3. vihaco-circuit-isa (#169) → `main` (open; carries #170 + #172 via a `main` merge) 4. native `.pyi` stubs (#171) → `main` (open; independent) 5. circuit component (#173) → #169 6. **composite machine + VM (this PR)** → #173 7. CLI + TUI (#166) → this PR ## Summary Completes the `ppvm-vihaco` crate on top of the circuit component (#173) — the composite machine that drives it plus the surrounding VM. | File | What | |------|------| | `composite.rs` | the `PPVM` composite: vihaco machine (CPU + program loader) driving the circuit component, measurement/trace observers, backend selection from the device header, reset, single-instruction stepping | | `syntax.rs` | `.sst` header parse / lower (`PPVMHeader`, `PPVMResolver`) | | `bytecode.rs` | `.ssb` bytecode emit / load (magic-tagged) | | `observable.rs` | observable-header parsing for the PauliSum backends | | `shots.rs` | multi-shot execution (serial + optional `rayon`) | | `lib.rs` | full module wiring + `load`/`run`/`dump`/`compile`/`parse` helpers + `PPVMModule` | | `Cargo.toml` | adds `vihaco-cpu`, `log`, optional `rayon` feature | | `tests/*.sst` + `sst_fixtures.rs` | 28 integration fixtures | ## `device_info` relocation resolves here `composite.rs` no longer defines `PPVM_MAGIC` / `BackendKind` / `PPVMDeviceInfo` — it imports them from `device_info` (introduced in #173) and `pub use`-re-exports them, so the existing `crate::composite::{…}` paths in `lib.rs` / `bytecode.rs` / `syntax.rs` keep resolving with no other edits. The machete-ignore added in #173 is dropped here — the full crate uses `chumsky` / `vihaco-parser-core` directly. ## Testing `cargo test -p ppvm-vihaco` — **111 unit + 28 integration** tests, green with and without `--features rayon`. Full workspace builds; clippy + machete clean. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 8d50344 commit 20b7637

27 files changed

Lines changed: 4267 additions & 14 deletions

Cargo.lock

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ppvm-vihaco/Cargo.toml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@ name = "ppvm-vihaco"
33
version = "0.1.0"
44
edition = "2024"
55

6+
[features]
7+
# Parallelism via rayon: shot-level (`run_shots`) and tableau-internal. Off by
8+
# default; enable with `features = ["rayon"]` (native only — wasm has no thread
9+
# support, so keeping it off by default keeps the default build wasm-safe).
10+
rayon = ["dep:rayon", "ppvm-tableau/rayon"]
11+
612
[dependencies]
713
bitvec = "1.0.1"
814
bnum = { version = "0.13.0", features = ["num-traits"] }
915
chumsky = "0.10.0"
1016
eyre = "0.6.12"
17+
log = "0.4.29"
1118
num = "0.4.3"
12-
smallvec = "1.15.1"
13-
ppvm-pauli-sum = { version = "0.1.0", path = "../ppvm-pauli-sum" }
19+
rayon = { version = "1.10", optional = true }
1420
ppvm-tableau = { version = "0.1.0", path = "../ppvm-tableau" }
21+
smallvec = "1.15.1"
1522
vihaco = "0.1.1"
23+
vihaco-cpu = "0.1.1"
1624
vihaco-parser = "0.1.1"
1725
vihaco-parser-core = "0.1.1"
1826
vihaco-circuit-isa = { version = "0.1.0", path = "../vihaco-circuit-isa" }
19-
20-
# chumsky and vihaco-parser-core are pulled in by the vihaco_parser::Parse
21-
# derive on BackendKind; machete can't see macro-expanded usage.
22-
[package.metadata.cargo-machete]
23-
ignored = ["chumsky", "vihaco-parser-core"]
27+
ppvm-pauli-sum = { version = "0.1.0", path = "../ppvm-pauli-sum" }

0 commit comments

Comments
 (0)