Architecture Dependency Direction

September 11, 2026 ยท View on GitHub

The implementation separates program transformation, execution orchestration, and numerical computation:

flowchart TD
    API[Public facade] --> Compiler
    API --> Runtime
    API --> Workflows[Domain workflows]
    Compiler --> Core
    Runtime --> Core
    Runtime --> Simulation
    Runtime --> Compute
    Runtime --> Remote
    Simulation --> Core
    Ecosystem[External object adapters] --> Core
    Collectors --> Records[Execution records]
    Audit[Audit and release policy] --> Records

This is an ownership overview, not an exhaustive import graph. The exact forbidden imports and bounded exceptions are in architecture.toml and checked by tools/check_architecture.py.

Reverse edges into IR/core are forbidden. Executors emit backend-neutral records and cannot import audit/release classification. Importing the stable root API is lazy and does not load runtime, provider, drawing, distributed, or optional-kernel modules.

architecture.toml owns module-size budgets, import allowlists, and bounded accelerator-call exceptions. Compatibility exceptions, when introduced, must name an owner and removal version. Run python tools/check_architecture.py locally and in CI.

Enforced Package Surfaces

ResponsibilityPackage/module
Stable APIflagquantum.__init__, flagquantum.circuit
Maintained extension APIsExplicit domain packages such as flagquantum.compiler, flagquantum.noise, and flagquantum.deployment
IR and parametersflagquantum.core
Compilerflagquantum.compiler
Runtime execution planningflagquantum.runtime.planner
Runtime API and contractsflagquantum.runtime
Distributed executor protocolsflagquantum.runtime.distributed.protocols
Backend boundariesflagquantum.runtime.executors
Distributed orchestrationflagquantum.runtime.distributed
Numerical kernelsflagquantum.simulation, including optional simulation.jax
Directly controlled resourcesflagquantum.compute
Measurement contractsflagquantum.core.ir, flagquantum.runtime.measurements
Deployment packagesflagquantum.deployment
External compute and QPU providersflagquantum.remote.compute, flagquantum.remote.qpu
External framework adapter contractflagquantum.ecosystem
External framework conversionflagquantum.ecosystem.<framework>
Evidence and audit policyflagquantum.runtime.audit

flagquantum.runtime is the sole runtime implementation namespace. New application, plugin, and backend code must use its explicit contracts, executors, distributed, and audit subpackages.

The circuit implementation lives at flagquantum.circuit; flagquantum.core contains backend-neutral IR, operator schemas, parameters, configuration, and versioned contracts only.

External framework objects stop at flagquantum.ecosystem. Its immutable lazy registry and framework-neutral conversion contracts are the shared control-plane boundary; concrete implementations live under flagquantum.ecosystem.<framework>. The Qiskit and PennyLane adapters convert to or from versioned FlagQuantum IR, report semantic loss explicitly, and load their external framework only when conversion is called. PennyLane v1 stops specifically at immutable QuantumScript; QNodes, devices, execution, and autograd remain outside it. Runtime kernels, distributed worker contracts, CUDA, and FlagOS never receive external framework objects.