Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

xqvm_py

Status -- transitional. xqvm_py is the executable conformance oracle for the XQuad toolchain: every vector under conformance/ must produce identical observable state on both this Python reference and the Rust xqvm production runtime. The arrangement is explicitly transitional. Once the Rust runtime is fully battle-tested, xqvm_py may be dropped entirely (with conformance vectors graduating to "Rust must produce exactly these outputs" reference data) or demoted to a prototyping sandbox for trying out new opcodes / VM features in Python before they earn a spec slot. Do not build infrastructure that hard-depends on xqvm_py's existence.

Python reference implementation of the X-Quadratic Virtual Machine. See spec/xqvm/SPEC.md for the authoritative technical specification.

Scope

  • Pure-Python executor, state model, opcodes, xqmx (sparse quadratic matrix), vector, and tracer.
  • No assembler or disassembler: the Rust xqasm crate is the only implementation, exposed to Python via xqffi.asm (pyo3). Tests and the CLI shim call xqvm_py.program_from_xqasm to turn .xqasm text into an executable Program.

Layout

xqvm_py/                  <-- this directory IS the package (flat layout)
  __init__.py             re-exports the public surface (Executor, Program, ...)
  __main__.py             entry point for `python -m xqvm_py`
  executor.py             fetch-decode-execute loop
  state.py                stack, registers, loop control, jump table
  opcodes.py              Opcode enum + operand metadata
  program.py              Program dataclass + program_from_xqasm()
  xqmx.py                 sparse quadratic matrix (model + sample modes)
  vector.py               typed vec<int> / vec<xqmx>
  errors.py               typed runtime errors
  tracer.py               step-by-step execution tracer
  cli/                    python -m xqvm_py run ...
  tests/                  pytest suite (wheel-excluded)

Quick start

From the xquad workspace root:

uv sync                                       # installs xqvm_py editable + xqffi via maturin
uv run pytest xqvm_py/tests                   # run the full test suite
echo "PUSH 5
PUSH 3
ADD
HALT" > /tmp/prog.xqasm
uv run python -m xqvm_py run /tmp/prog.xqasm  # CLI shim

Programmatic use:

from xqvm_py import Executor, program_from_xqasm

prog = program_from_xqasm("PUSH 10\nPUSH 5\nADD\nSTOW r0\nHALT\n")
executor = Executor()
executor.execute(prog)
print(executor.state.get_register(0))  # 15

Conformance

Behavioural parity with the Rust xqvm crate is enforced by the xquad-conformance Rust test harness at conformance/. New VM semantics require a new vector. Divergence between implementations fails CI with no "drift tracking" middle ground.

Release files for xqvm-py 0.4.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xqvm-py 0.4.0rc1
File Size Uploaded
xqvm_py-0.4.0rc1.tar.gz 86.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xqvm-py 0.4.0rc1
File Interpreter ABI Platform
xqvm_py-0.4.0rc1-py3-none-any.whl Python 3 none any Details

Total release size: 142.2 kB

Release files / xqvm_py-0.4.0rc1.tar.gz

Download URL xqvm_py-0.4.0rc1.tar.gz
Size 86.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9a2350fadc31e4afd70dc4256f192c49df9495e5bf03b13b5617b846e8350e7f
BLAKE2b-256 checksum
How to use checksums
769e23c875a0c8f367138907eb101e1c9b5af9e86c3cd73ca3384afb5e4c31bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / xqvm_py-0.4.0rc1-py3-none-any.whl

Download URL xqvm_py-0.4.0rc1-py3-none-any.whl
Size 55.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da241ab9ee1cb2b913ea33643846c35511707056b7acac1ba1f35eb3992e95ec
BLAKE2b-256 checksum
How to use checksums
37283f72d9f4a044814b6aae4e06653330553ed68935427ebc40c74bf29b026b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.5
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page