Reference#
Stable interfaces, configuration and support boundaries.
Stable API#
FlagQuantum exposes one curated Python interface, import flagquantum as fq.
The stable names are bounded by a checked manifest, verified by executable
contract tests.
API |
Stability |
|---|---|
|
Stable |
|
Stable |
|
Stable |
|
Stable |
|
Stable |
|
Stable |
|
Stable |
|
Stable |
|
Stable |
|
Stable |
|
Stable |
API map#
Task |
Primary interface |
Result |
|---|---|---|
Build a program |
|
Circuit backed by FlagQuantum IR |
Optimize a program |
|
|
Compile for a selected tool and target |
|
|
Inspect execution |
|
Explainable runtime plan |
Execute locally or remotely |
|
|
Define a trainable quantum layer |
|
PyTorch module |
Train |
|
|
Package for a target |
|
Sealed deployment package |
Runtime configuration#
RuntimeConfig is FlagQuantumβs immutable execution policy: backend, device,
real and complex precision, JAX precision, matrix multiplication policy and
drawing style. A Circuit captures a configuration when constructed and embeds
a versioned manifest in IR and execution plans, so distributed workers rebuild
the same policy.
import flagquantum as fq
from flagquantum.runtime.configuration import RuntimeConfig, runtime_config
config = RuntimeConfig(device="cuda")
circuit = fq.Circuit(4, config=config)
with runtime_config(complex_dtype="complex128"):
circuit = fq.Circuit(2) # captures complex128
Each execution resolves complex precision once: complex64 implies float32
parameters and real components, complex128 implies float64. The resolved value
governs planning bytes, state allocation, parameter tensors, gate matrices and
distributed simulation, and the stages never consult process defaults
independently. Conflicting dtypes fail before gate application.
Operators#
Circuit operations and backend lowering availability derive from one typed operator registry. A registered lowering means the operator can be lowered for that backend β not that it is release evidence. The generated operator table in the repository is authoritative for the registered set, which covers Pauli, Clifford, rotation, controlled, symmetric two-qubit and phase gates, plus the noise channels used by the stable noise model.
Errors#
Category |
Meaning |
|---|---|
|
Invalid semantic input |
|
Stale, tampered or incompatible plan |
|
The requested capability is unavailable |
|
Execution or training failure |
All categories inherit FlagQuantumError and a compatible Python built-in
exception. Wrong Python types and unknown keyword arguments raise TypeError.
Stability boundaries#
fq.experimentalhas no compatibility guarantee.Compatibility imports are migration aids and are not implied stable.
A planner result describes intent and estimates; it is never runtime or benchmark evidence.
Runtime evidence must satisfy the typed, versioned runtime contracts.
New public names must first be importable, snapshot-tested and added to the stable API manifest.
Further reading#
Capability reference β maturity and support boundaries per capability.
Architecture β layers, dependency direction and contracts.