A Q-ISA program is a Quantum Transaction
- Atomic (cannot be preempted mid-execution)
- Linear (no branching in v0.1)
- Deterministic instruction order
- Probabilistic measurement outcome
- Ends permanently on full measurement
- Program loaded
- Header validated
- Logical qubits allocated
- Instruction stream executed sequentially
- Measurement results returned
- All qubits deallocated
- Program state destroyed
| Header (64 Bytes) |
|---|
| Constant Pool |
| Instruction Stream |
| Footer (Checksum) |
(All integers are little-endian)
| Offset | Size | Field | Description |
|---|---|---|---|
| 0x00 | 4 | Magic Bytes | 0x4155544D (“AUTM”) |
| 0x04 | 2 | Version | 0x0001 (v0.1) |
| 0x06 | 2 | Flags | 0 for v0.1 |
| 0x08 | 4 | Logical Qubit Count | u32 |
| 0x0C | 4 | Classical Register Count | u32 |
| 0x10 | 8 | Instruction Count | u64 |
| 0x18 | 8 | Constant Pool Offset | u64 |
| 0x20 | 8 | Instruction Stream Offset | u64 |
| 0x28 | 8 | Constant Pool Size | u64 |
| 0x30 | 8 | Instruction Stream Size | u64 |
| 0x38 | 8 | Header Checksum | u64 |
Validation requires:
- Logical qubits > 0
- Instruction count > 0
- Stream offset valid
- Program must end with QEND
- Logical qubits indexed 0 … (N-1)
- Must not exceed declared count
- No dynamic creation beyond declared count
- Reuse allowed only if explicitly freed
Qubit IDs are u32.
- Classical registers indexed 0 … (M-1)
- Only writable via QMEASURE
- No classical arithmetic allowed in v0.1
- Read-only after write
- Used for parameterized gates.
- Constant pool index is u64.
- Only f64 supported in v0.1.
All instructions begin with:
[u8 opcode]
[operands...]
| Opcode | Mnemonic |
|---|---|
| 0x01 | QINIT |
| Opcode | Mnemonic |
|---|---|
| 0x10 | QH |
| 0x11 | QX |
| 0x12 | QY |
| 0x13 | QZ |
Format:
[u8 opcode]
[u32 qubit_id]
| Opcode | Mnemonic |
|---|---|
| 0x14 | QRX |
| 0x15 | QRY |
| 0x16 | QRZ |
Format:
[u8 opcode]
[u32 qubit_id]
[u64 const_index]
| Opcode | Mnemonic |
|---|---|
| 0x20 | QCNOT |
| 0x21 | QSWAP |
Format:
[u8 opcode]
[u32 q1]
[u32 q2]
| Opcode | Mnemonic |
|---|---|
| 0x22 | QCPHASE |
Format:
[u8 opcode]
[u32 q1]
[u32 q2]
[u64 const_index]
| Opcode | Mnemonic |
|---|---|
| 0x30 | QBARRIER |
| 0x31 | QWAIT |
Format:
[u8 opcode]
[u64 nanoseconds](* For QWAIT only)
| Opcode | Mnemonic |
|---|---|
| 0x40 | QMEASURE |
| 0x41 | QMEASURE_ALL |
Format:
[u8 opcode]
[u32 qubit_id] (* For QMEASURE only)
[u32 classical_reg] (* For QMEASURE only)
| Opcode | Mnemonic |
|---|---|
| 0xF0 | QEND |
Format:
[u8 opcode]
* Must be the final instruction.
AutmOS will reject program if:
- Missing QEND
- Instruction count mismatch
- Qubit index ≥ declared count
- Classical index ≥ declared count
- Invalid opcode
- Constant index out of bounds
- Instructions appear after QMEASURE_ALL
- Header version mismatch