Quantum computing
Quantum programming in AEL, the Agent Engineering Language, comes from optional packages. Quantum circuits are typed, with standard and custom gates. Circuits export to OpenQASM and QIR, with circuit lowering and routing, and hybrid agent workflows let an agent propose a circuit, validate it, simulate it, optionally run it on hardware and check the result.
A program that does not use these packages carries none of their code. Building a circuit needs no simulator, no account and no network.
The packages
| Package | What it provides |
|---|---|
quantum/circuit | Circuits: qubit and classical-bit handles, operations, measurements, observables, parameters and validation. |
quantum/gates/standard | Identity, Pauli, Hadamard, phase and rotation gates, their adjoints, controlled gates, swap and common multi-qubit gates. |
quantum/sim/statevector, quantum/sim/density-matrix, quantum/sim/stabilizer, quantum/sim/tensor-network | Simulators, each for the circuits it can handle. |
quantum/compile/openqasm, quantum/compile/qir | Export to OpenQASM and QIR. |
quantum/algorithms/… | Algorithm families, such as variational optimization, search, error mitigation and error correction. |
quantum/control/pulse | Pulse-level control, for hardware that offers it. |
Optional packages cover quantum algorithms, error mitigation and correction, quantum machine learning and quantum chemistry. You add each one on its own with ael pack add:
ael pack add quantum/circuit
ael pack add quantum/sim/statevector
ael pack add quantum/compile/openqasm
Typed circuits
- Qubits are handles. A reference to a released, out-of-range or other circuit's qubit is refused.
- Gates declare themselves. Each gate states its number of targets and controls, its parameters and their units, and its matrix or decomposition. The standard gates follow one published convention for qubit order, phase and angle units.
- Custom gates are checked. A custom gate brings a decomposition or a matrix. A matrix of the wrong shape, one that is not unitary, a non-finite parameter or an endlessly recursive definition is refused.
- Measurement is explicit. Measurement, reset and the mapping of results to classical bits are part of the circuit, and are never treated as reversible gates.
- Parameters are bound before submission. A circuit with an unbound parameter fails before any work is requested.
- Results have kinds. Statevectors, density matrices, samples, counts and expectation estimates are different types. A run on hardware never pretends to return a statevector.
Simulators that state their limits
Quantum simulators (statevector, density-matrix, stabilizer and tensor-network) state their cost and precision limits:
- A statevector needs 2^n complex amplitudes for n qubits, and a density matrix 4^n entries. The memory a simulation needs is computed before it starts, and a simulation that would not fit is refused instead of running out of memory.
- The stabilizer simulator accepts only the gates it can simulate efficiently and refuses the rest unless you select a fallback; it never falls back silently to an exponential method.
- The tensor-network simulator reports the approximation it made.
- Seeds make sampling repeatable where the method allows it.
Export, lowering and routing
Export targets a declared version and subset of OpenQASM and a declared QIR profile; anything outside them is refused unless a declared extension policy keeps it. Lowering for a backend maps logical qubits to physical ones, respects the device's connectivity, decomposes into the gates it accepts, and reports the depth, gates and swaps it added. It never silently replaces a hardware conditional with feedback from the host, drops a measurement, or switches from hardware to a simulator.
Jobs on quantum hardware
Quantum jobs run asynchronously on quantum hardware providers, with budgets, cancellation and tenant-scoped credentials. They use your own account with a quantum hardware provider, an outside system that AEL talks to through its own interface.
- Clear states. A job moves through validated, submitted, queued, running, result available, failed, cancellation requested and cancelled. When the outcome cannot be known, it is reported as unknown.
- No blind resubmission. A submission can be billable. If an acknowledgement is lost, the job is reconciled with the provider, never simply submitted again.
- Separate budgets. Qubits, shots, batch size, device time, simulation time, cost and concurrency each have their own limit, apart from model token budgets.
- Authority stays with you. An agent can choose among the backends you authorized, but a model's answer can never grant a credential, a device or spending.
- Honest usage. Reports give shots, circuits, queue time, simulation time, the device time the provider reports and the cost with its source. Usage a provider does not report stays unknown, never zero.
Adding or installing a package never contacts a provider or submits a job.
Hybrid agent workflows
# agents/circuit_designer.agent.ael
agent circuit_designer(input: Goal) -> CheckedResult {
config {
nodes: [designer = propose_circuit, validator = validate_circuit,
simulator = simulate, checker = check_result];
edges: [proposal_to_validation(designer, validator),
validation_to_simulation(validator, simulator),
counts_to_check(simulator, checker)];
starts: [designer];
completion: checker.result;
}
}
The model-driven propose_circuit suggests a circuit; deterministic nodes validate it, simulate it and check the result against your criteria. A step that runs the circuit on hardware can follow the simulation, within its own budget.
Honest limits
Mitigated results are not error-corrected results, and the packages keep the two apart. Repeating an experiment on hardware need not reproduce the same samples, so comparisons are statistical. A loop in your program that submits one job after another is not fast feedback inside a single hardware run. The quantum machine learning packages do not promise better accuracy or speed. Each package states the circuits, gates and backends it covers.