LIFT v0.5 — Development Plan

Status: Active development target Scope: Execution engine, functional importers, real LLVM lowering Version bump: 0.5.0 (minor — new features, no breaking IR changes)

This plan breaks down the v0.5 milestone into concrete, independently mergeable work items. Each item lists the crates and files involved, the deliverable, and the acceptance criteria.


Overview

v0.5 moves LIFT from a static analysis compiler to an execution-capable compiler:

flowchart LR
    A["Static analysis (v0.4)"] --> B["State-vector simulation (v0.5)"]
    B --> C["Tensor interpreter (v0.5)"]
    C --> D["Real LLVM lowering (v0.5)"]
    D --> E["Functional importers (v0.5)"]

The four work streams are independent and can be developed in parallel.


Workstream 1 — State-vector quantum simulator

Target: simulate quantum circuits on CPU (up to ~25 qubits) to validate circuits before deploying to real QPUs.

Status today: crates/lift-sim/src/quantum_sim.rs performs static analysis only (gate counts, depth, fidelity estimates). There is no numerical simulation.

Tasks

#TaskFile(s)Acceptance
1.1Amplitude vector type Vec<Complex64> with 2^N layoutcrates/lift-sim/src/state.rsState::new(num_qubits) allocates 2^N amplitudes
1.2Gate matrix kernels (Pauli, Clifford, H, T, RX/RY/RZ, CNOT, SWAP)crates/lift-sim/src/kernels.rsEach gate applies correctly to an amplitude vector
1.3Circuit executor — walk LIFT IR ops, apply gates in ordercrates/lift-sim/src/executor.rsExecutes any quantum circuit expressed in lift-quantum dialect
1.4Measurement with probability samplingcrates/lift-sim/src/measure.rsmeasure(qubit) collapses state per Born rule
1.5Noise channel application (depolarising, amplitude damping)crates/lift-sim/src/noise.rsKraus operators applied to density matrix (mixed state mode)
1.6CLI subcommand lift sim --quantum file.lifcrates/lift-cli/src/main.rsPrints final state amplitudes + measurement counts

Deliverable

lift sim --quantum examples/quantum_bell.lif prints:

Qubits: 2
State:  |00⟩: 0.7071  |11⟩: 0.7071
Measurements (1024 shots): 00: 512, 11: 512

Workstream 2 — Tensor interpreter

Target: execute tensor ops with real values (numpy-like), enabling in-compiler evaluation of constant subgraphs.

Status today: no runtime values; the IR holds shapes/types only.

Tasks

#TaskFile(s)Acceptance
2.1Runtime tensor value Tensor { data: Vec<f64>, shape: Vec<usize> }crates/lift-sim/src/tensor.rsBasic constructors and indexing
2.2Core arithmetic kernels — add, sub, mul, div, matmul, broadcastcrates/lift-sim/src/tensor_ops.rsMatches numpy semantics on shape mismatch
2.3Reduction + reshape ops — sum, mean, max, reshape, transposecrates/lift-sim/src/tensor_ops.rsCorrect output shapes
2.4Dialect op → kernel dispatchercrates/lift-sim/src/interp.rsEvery lift-tensor op maps to a kernel or errors clearly
2.5CLI subcommand lift sim --tensor file.lifcrates/lift-cli/src/main.rsPrints output tensors

Deliverable

lift sim --tensor examples/tensor_mlp.lif evaluates the MLP forward pass and prints each layer's output tensor.


Workstream 3 — Real LLVM IR lowering

Target: emit executable LLVM IR with cuBLAS/cuDNN runtime calls (GPU) and a fallback CPU path.

Status today: lift-export/src/llvm.rs emits a textual skeleton — module declarations and function signatures, without real code generation.

Tasks

#TaskFile(s)Acceptance
3.1Map LIFT tensor ops to cuBLAS calls (gemm, bias, relu fusion)crates/lift-export/src/llvm.rsmatmul emits cublasSgemm
3.2Map quantum measurement/shots to a runtime harnesscrates/lift-export/src/llvm.rsQPU bridge stubs generated
3.3CPU fallback path (no GPU required to run)crates/lift-export/src/llvm.rsEmitted .ll compiles with clang
3.4Verify emitted IR with llvm-as / lli in CI.github/workflows/ci.ymllli executes a trivial kernel

Deliverable

lift export --backend llvm examples/phi3_mini.lif produces an .ll file that compiles with clang and runs on CPU without a GPU.


Workstream 4 — Functional importers

Target: import ONNX, PyTorch FX, and OpenQASM 3 files into LIFT IR.

Status today: crates/lift-import/src/{onnx,pytorch,qasm}.rs are stubs — error types and importer structs exist, but no parsing.

Tasks

#TaskFile(s)Acceptance
4.1ONNX protobuf decoding (opset ≤ 21)crates/lift-import/src/onnx.rsLoads a real .onnx from examples/
4.2ONNX op → LIFT tensor op mappingcrates/lift-import/src/onnx.rsConv, Gemm, Relu, Softmax map correctly
4.3OpenQASM 3 parser (grammar subset)crates/lift-import/src/qasm.rsParses quantum_bell.lif-equivalent QASM
4.4QASM gate → LIFT quantum op mappingcrates/lift-import/src/qasm.rsH, CNOT, measure round-trip
4.5PyTorch FX graph export ingestioncrates/lift-import/src/pytorch.rsReads a .fx.json graph
4.6CLI subcommand lift import <file>crates/lift-cli/src/main.rsImports and prints the IR

Deliverable

lift import examples/phi3_generated.onnx produces a valid LIFT IR that passes lift verify.


Testing strategy

  • Every new kernel/simulator function gets unit tests in-crate.
  • Round-trip tests: export .qasm/.onnx → import → verify.
  • examples/validate_all.sh extended with sim and import steps.
  • CI keeps cargo fmt --check, clippy -D warnings, cargo test --workspace.

Suggested PR sequence

  1. feat(sim): state-vector simulator — Workstream 1 (items 1.1–1.5)
  2. feat(cli): sim subcommands — items 1.6 + 2.5
  3. feat(sim): tensor interpreter — Workstream 2 (2.1–2.4)
  4. feat(import): ONNX importer — Workstream 4 (4.1–4.2)
  5. feat(import): OpenQASM importer — Workstream 4 (4.3–4.4)
  6. feat(export): real LLVM lowering — Workstream 3
  7. feat(import): PyTorch FX — Workstream 4 (4.5–4.6)

Each PR is independently mergeable and keeps main green.