All examples
Quantum computing

Inspect experimental quantum backends

Query backend availability and run a GHZ circuit on the supported CPU simulator while reserved accelerators and physical quantum hardware remain unavailable.

Experimental module
quantum_backends.aner
// Experimental: the circuit is independent of the selected backend.
// Only quantum.cpu() executes today. Other descriptors report unavailable.
import aner.quantum

let backend = quantum.cpu()
// Future alternatives, once compatible adapters are implemented:
// let backend = quantum.gpu()
// let backend = quantum.cluster()
// let backend = quantum.hardware(target: "configured-device")

let program = quantum.circuit(qubits: 3).h(0).cx(0, 1).cx(1, 2)
let result = program.run(backend: backend, shots: 2048, seed: 42)
print(result.counts())
print(result.count("000") + result.count("111") == result.shots())

print("Backend availability in this development runtime")
print(quantum.cpu().available())
print(quantum.gpu().available())
print(quantum.cluster().available())
print(quantum.hardware(target: "configured-device").available())
// Running with an unavailable descriptor raises E_QUANTUM_BACKEND.
// No connection or remote job is created by constructing a descriptor.

Make it your experiment.

With a compatible development runtime installed, save this program as examples/quantum_backends.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/quantum_backends.aner
aner run examples/quantum_backends.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Use the updated native Aner development runtime with the experimental aner.quantum CPU simulator. Earlier packaged executables may not recognize this module. The complete examples run locally with no external service, credential or quantum hardware. Reserved GPU, cluster and physical hardware descriptors report unavailable; requested execution fails explicitly without fallback.

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner