bloq
CLI and Python bindings for the bloq workspace: compile block graphs for fault-tolerant lattice-surgery quantum circuits, emit Stim circuits, and verify dynamic programs with a simple simulation VM.
Requires Python 3.10 or later. The PyPI distribution is bloq-py; the import
and CLI are bloq.
Install
Install the CLI from a released wheel with uv:
uv tool install "bloq-py==0.1.1"
bloq --help
bloq compile --gallery cnot -d 3 -o cnot.stim
For the Python API, use uv add "bloq-py==0.1.1" in your project or
pip install "bloq-py==0.1.1".
Wheels include the same Rust CLI used by
cargo install bloq-cli --version 0.1.1 --locked. No Rust installation is needed
on platforms with a matching wheel. Source installs
require the workspace Rust toolchain.
Install from source
From the repository root, with the workspace Rust toolchain installed:
uv tool install ./bloq_py # CLI in an isolated environment
pip install ./bloq_py # CLI and API in the current environment
Development recipes use uv and just:
just py-develop # uv-managed editable install in bloq_py/.venv
just py-test # pytest suite
just py-build # release wheel
Quick example
import bloq
graph = bloq.GalleryItem.CNOT.load()
program = bloq.compile(graph, distance=3) # Bloq IR
circuit = bloq.emit_stim(program) # returns stim.Circuit
circuit.to_file("cnot.stim")
assert circuit == bloq.compile_to_stim(graph, 3)
vm = bloq.lower_vm(program)
shot = vm.run(seed=94)
print(shot.trace)
Compiler options such as prepare_t_with_mpps and limits are keyword-only.
compile_to_stim(graph, noise=0.001) handles the common noisy Stim workflow.
For an explicit full IR audit, use compile(graph, validate=True) or
context.compile(graph, validate=True); both return the audited program and
apply the compilation's Boolean limits to the audit.
Programs, graphs, and Pauli strings support copying and pickling for
multiprocessing workers.
BlockGraph.load(path) reads .blog files and resolves relative module imports.
Like from_text, it retains module definitions, instances, and interfaces in
the graph. save(path) preserves that hierarchy. module_names lists the
definitions; module(name) returns an independent graph rooted at that
definition, with its reachable helpers and an executable main root. Local block
accessors inspect the owning definition. Use flatten() to assemble a separate
flat graph for geometry inspection. The same compile API accepts both forms.
Symbolic Expr and ClassicalExpr objects reject Python truth testing. Build
source expressions with &, |, ^, and ~. Use program.classical_value(...)
to evaluate IR nodes.
Dynamic quantum choices use QuantumNode.guards. Retry regions use
RepeatUntilSuccess. program.selection_seams() locates incoming
selection seams. Pass their bloq.ir.MemoryRoundTarget.Edge targets to
program.insert_memory_rounds_batch(targets, rounds) to add memory atomically.
Import detailed inspection types from bloq.ir, for example
from bloq.ir import CircuitOp, RegionKind. Custom backends use
program.emission_plan(node, path=None, noise=0.001) and
emit_plan_stim(plan, layout, dialect="stim"); noise is optional and dialects
are strings. See Bloq IR for inspection and editing APIs.
VM decoding uses a mock policy model. Its traces do not estimate calibrated
logical error rates. Graph-level and physical verification remain Rust-only.
Python callers can check emitted Clifford circuits with the PyPI stim package.
Domain failures derive from BloqError. Python protocols and I/O retain
standard exceptions such as IndexError, TypeError, and OSError.
See the Python guide for the API and limits, and the VM contract for timing and decoding semantics.
Metadata
Release files for bloq-py 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bloq_py-0.1.1.tar.gz | 2.3 MB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bloq_py-0.1.1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| bloq_py-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| bloq_py-0.1.1-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 21.5 MB
Release files / bloq_py-0.1.1.tar.gz
| Download URL | bloq_py-0.1.1.tar.gz |
|---|---|
| Size | 2.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1432f59710576cdd5fcc24fe7c37f2d990fcbbcc1044fb1783ee8278b8c74a80
|
|
BLAKE2b-256 checksum How to use checksums |
cb3cd56d1b30e9c772e8de68f9977c5c09d553897f4caf77f671b92c1a32dc9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / bloq_py-0.1.1-cp310-abi3-win_amd64.whl
| Download URL | bloq_py-0.1.1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 6.6 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
16c26a33a88bc1debaff9e7f61512716b076c437fe48d666973f9fc1ad792ccd
|
|
BLAKE2b-256 checksum How to use checksums |
d4bfd82415b0ee748ec68eb94536b49e5b0da1e2a07860ddf551ce14350ab34f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / bloq_py-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | bloq_py-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 6.7 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
a77b5973d2cc72f606bf0500ed05f1f42587bf028821614f76432f0509025889
|
|
BLAKE2b-256 checksum How to use checksums |
709df67f45bc891c92bed4deb0d08f54fc556a167cfa3b47d245ea7283000e12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / bloq_py-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | bloq_py-0.1.1-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e55033e2f067f5bcdadcfd15eb6f34f05be4c0b7b413894b72ce69f1a17541b7
|
|
BLAKE2b-256 checksum How to use checksums |
8f4d96d01ce0ae735d21c6e81b383a7d92552e8270e888928e39b5711bdfc18d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|