Home · ASPLOS 2022 · Compilers & Programming Languages

Paulihedral: a generalized block-wise compiler optimization framework for Quantum simulation kernels

Gushu Li, Anbang Wu, Yunong Shi, Ali Javadi-Abhari, Yufei Ding and Yuan Xie

Conference
ASPLOS 2022
Published
2022
Pages
554-569
Citations
61

Quantum simulation kernels compile into enormous gate sequences, and gate-level compilers can no longer see the physics inside them — Paulihedral keeps the program as a sum of Pauli strings, where reordering is provably harmless, then schedules, synthesizes, and maps whole blocks at once, cutting gate counts and circuit depth by roughly half.

The argument in one glance

  1. Problem

    One subroutine dominates quantum programs, and it compiles to a monster

    Simulating a quantum system — applying exp(iHt) for a Hamiltonian H — is the core of quantum chemistry (VQE), combinatorial optimization (QAOA), linear-system solvers, and more. Compilers decompose H into a sum of simple terms (Pauli strings) and emit a small template circuit per term. Thousands of terms make the kernel the vast majority of the compiled program.

  2. What people did

    Optimize the gate sequence with general-purpose compiler passes

    Qiskit, t|ket⟩, and Quilc apply circuit rewriting, gate cancellation, template matching, and qubit mapping — local transformations on the flattened gate list. Algorithm-specific tricks (term ordering for chemistry, QAOA-only compilers) exist but do not generalize.

  3. Why it fell short

    Flattening destroys exactly the structure the big optimizations need

    Once the kernel is a sea of gates, the compiler no longer knows which gates came from which term, that terms may be freely reordered, that each term’s circuit could have been synthesized in many shapes, or that algorithmic constraints tie groups of terms together. Local passes recover crumbs; the large-scale cancellations, parallelism, and mapping-aware synthesis stay invisible — and gate-level global optimization scales terribly.

  4. This paper's idea

    Compile at the level of the algebra, not the gates

    Paulihedral’s Pauli IR represents the kernel as weighted Pauli strings grouped into blocks, with semantics defined by matrix addition — which commutes, so reordering blocks is semantics-preserving by construction. Two scheduling passes (gate-count- or depth-oriented) and two backend passes (fault-tolerant, superconducting) then exploit that freedom: 53.1% fewer gates and 53.3% lower depth than t|ket⟩ on superconducting targets, at ~5% extra compilation time, and 1.24× higher average success probability for QAOA on a real IBM device.

Why this problem is worth solving

Quantum computing’s founding purpose — Feynman’s original argument — was simulating quantum physics. The machinery for it, applying the operator exp(iHt) where H is the system’s

the operator describing a quantum system’s energy; simulating the system means applying its time evolution exp(iHt)
, turned out to be the shared skeleton of much more: chemistry via VQE, optimization via QAOA, linear algebra subroutines, quantum machine learning. Whatever the application, this quantum simulation kernel appears — and dominates the compiled program.

The compilation recipe is standard. H is decomposed into a weighted sum of

a tensor product of single-qubit Pauli operators (I, X, Y, Z), one per qubit — e.g., YZIXZ on five qubits. Each term exp(iP·θ/2) compiles to a fixed template: a layer of single-qubit basis-change gates, a chain (“tree”) of CNOT gates converging on one qubit, a single rotation Rz(θ), and the mirror of the tree and layer
s. A molecule or model easily produces thousands of strings (the paper’s stress tests use 5n² strings for n qubits, up to 80 qubits), each emitting its template — so the kernel becomes an enormous gate sequence.

Why care about shaving gates? Because on near-term hardware every two-qubit gate is error-prone and every layer of depth spends scarce coherence time — gate count and depth translate directly into whether the answer survives. On future fault-tolerant machines, gates are costly in error-correction resources instead. Either way, the kernel’s size makes it the highest-leverage optimization target in quantum compilation.

What people did before, and where it broke

Generic gate-level compilers. Qiskit and t|ket⟩ take the flattened circuit and apply local rewriting: cancel adjacent inverse gates, match small templates, remap qubits to satisfy hardware connectivity. These passes are designed for arbitrary circuits, so they cannot assume what is true here: that the circuit is a product of per-term templates whose order was a free choice, whose synthesis shape was a free choice (any CNOT tree connecting the active qubits, any root), and whose terms obey algorithm-level constraints. t|ket⟩‘s strongest simulation-specific technique (simultaneous diagonalization) works at the operator level but scales poorly — on large benchmarks it ran past 72 hours in the paper’s experiments.

Algorithm-specific compilers. Term-ordering heuristics for chemistry, dedicated QAOA compilers — effective in their niches, but each hard-codes one algorithm’s constraints, precisely because no shared IR existed that could express “these strings must stay together” or “these share a parameter” in general.

The missed structure, concretely. Two adjacent templates whose strings share non-identity operators on many qubits can cancel most of their boundary gates — if the compiler orders them adjacently and synthesizes their trees to match. Blocks touching disjoint qubits can run in parallel — if scheduled into one layer. On superconducting chips, the CNOT tree can be embedded directly into the hardware’s connectivity graph — if synthesis and mapping talk to each other instead of running as separate stages. All three are invisible at gate level.

Paulihedral's compilation flow

  1. Pauli IR new

    The kernel as a list of pauli_blocks: each block holds weighted Pauli strings plus a shared parameter. Semantics are defined as the SUM of the weighted strings (the Hamiltonian itself) — and matrix addition commutes, so reordering blocks or strings provably preserves meaning. Blocks encode algorithmic constraints (symmetry preservation, parameter sharing): strings in a block are always scheduled together.

  2. Instruction scheduling (technology-independent) new

    Two alternative passes. Gate-count-oriented: lexicographic ordering of strings/blocks so neighbors share operators, maximizing cancellation potential. Depth-oriented: sort blocks by active length, then pack each layer with one large block plus small blocks on disjoint qubits, maximizing parallelism.

  3. Backend pass: fault-tolerant (FT) new

    Pairs adjacent layers with maximal operator overlap and adaptively chooses each string’s CNOT-tree shape so boundary gates cancel — mapping overhead is negligible under error correction, so cancellation is everything.

  4. Backend pass: superconducting (SC) new

    Reconciles synthesis with qubit mapping: finds a tree embedding of each layer’s largest block directly in the device coupling graph (roots and paths chosen by connectivity and error rates), folds SWAP insertion into the tree construction, and fits disjoint small blocks around it.

  5. Gate sequence → generic compiler

    The output circuit still passes through Qiskit or t|ket⟩ generic backends for final polishing — Paulihedral adds only ~5% to total compilation time.

Two scheduling passes × two backend passes = a retargetable framework: the same IR serves fault-tolerant and near-term machines with different objectives (total gates vs depth vs mapping overhead).

The idea

Choose an IR whose algebra makes the hard transformations trivially legal. At gate level, reordering operations is dangerous — quantum gates are matrix products, and products do not commute. But the kernel’s meaning is the Hamiltonian, a matrix sum — and sums always commute. Pauli IR defines its formal semantics as that sum, so any reordering of blocks or of strings within blocks is semantics-preserving by the definition of the IR. The entire optimization space that gate-level compilers must painstakingly prove safe, term by term, Paulihedral gets by construction. (Different orderings do change the higher-order approximation error of

approximating exp(iHt) by a repeated product of each term’s small evolutions — the standard decomposition whose term order the algorithm treats as free
, which the algorithms themselves already accept as an ordering-independent budget.)

Blocks carry the algorithm’s rules. UCCSD chemistry requires certain string groups to stay together (symmetry, shared parameters); QAOA shares one parameter across all strings. The pauli_block is the unit of scheduling, so constraints ride along through every pass — this is what makes one framework serve algorithms that previously needed bespoke compilers.

Schedule for your objective. Gate-count-oriented scheduling sorts strings lexicographically so consecutive strings share operator prefixes — shared operators become cancellable gates. Depth-oriented scheduling instead treats blocks as jobs in layers: place the largest block, then greedily add blocks whose active qubits are disjoint; these execute simultaneously. The ablation shows they are genuinely different tools: on QAOA-style benchmarks, depth-oriented wins by 84.2% depth reduction where gate-count-oriented finds nothing.

Synthesize with the freedom the template offers. Each string’s CNOT tree may connect its active qubits in any shape, rooted anywhere. The FT pass exploits this by pairing layers with maximal operator overlap and choosing tree shapes so that a string’s right tree mirrors its successor’s left tree — whole subtrees and basis layers annihilate. The SC pass exploits it differently: rather than synthesizing an ideal circuit and then paying SWAP gates to fit the chip, it embeds the tree in the chip’s coupling graph from the start — core qubits (active in every string of the block) anchor the tree, paths are chosen by error rate, and when a tree edge meets an inactive qubit, the SWAP that would have been overhead becomes part of the construction.

A chemistry kernel through Paulihedral, end to end

Pauli string = one term like YZIXZ (letters = per-qubit operators; I = identity = qubit unused). Template per string: basis layer (H/Y gates) + left CNOT tree + Rz(θ) + right tree + basis layer. Block = strings sharing a parameter/constraint. FT/SC = fault-tolerant / superconducting backends. The walkthrough mirrors the paper's Figures 8–10; small examples are illustrative.

Step 1 of 6

The program arrives as algebra, not gates

A UCCSD ansatz for a molecule: dozens of pauli_blocks, each holding a few mutually-commuting Pauli strings sharing one variational parameter θ. Nothing is flattened yet — the compiler sees terms, weights, and block boundaries, exactly the information Qiskit or t|ket⟩ would have destroyed on entry.

program = [ (strings, θ₁), (strings, θ₂), … ]
semantics = Σ weight × string (a Hamiltonian)

Why it works

  • The kernel’s meaning is a sum, and sums commute → reordering blocks is legal by the IR’s semantics, not by case-by-case proof → the scheduler explores a space gate-level compilers cannot even represent safely.
  • Cancellation between templates depends on adjacency and on tree shape → scheduling (who is adjacent) and synthesis (which tree) are decided together, both aware of operator overlap → boundary gates annihilate at scale instead of by lucky local pattern-match.
  • Blocks preserve algorithmic constraints through every pass → one framework serves UCCSD, QAOA, and Hamiltonian simulation without bespoke compilers → generality and deep optimization stop being a trade-off.
  • On hardware, the template’s flexible tree meets the chip’s fixed graph → embedding the tree in the coupling map merges synthesis with mapping → SWAP overhead (the dominant near-term cost) is largely designed away rather than minimized after the fact.
  • All passes work on strings and blocks (sorting, pairwise overlap), not on the exploded gate list → near-linear practical scaling → ~5% compile-time overhead where operator-level baselines time out beyond 72 hours.

What it costs

  • Scope. The framework optimizes simulation kernels; programs outside that structure (arbitrary circuits) see no benefit — the IR’s power comes precisely from its restriction.
  • Trotter-order effects. Reordering preserves the represented Hamiltonian, but different orders give (bounded, algorithmically accepted) different Trotter approximation errors — fidelity of the final answer is governed by that budget, not bit-identical output.
  • Heuristic passes. Scheduling and embedding are greedy heuristics with no optimality guarantee; objectives (gates vs depth) must be chosen per backend by the user.
  • A second compiler still runs. Output circuits pass through Qiskit/t|ket⟩ generic backends; Paulihedral replaces the simulation-specific stage, not the whole toolchain.
  • Evaluation-scale hardware. The real-system study is a 16-qubit device and 1-level QAOA — meaningful end-to-end evidence, small relative to the 80-qubit compilation benchmarks.

The evaluation

Thirty-one benchmarks span the kernel’s habitats: UCCSD chemistry ansatzes (8–28 qubits), QAOA MaxCut on regular and random graphs plus traveling-salesman encodings, five molecular Hamiltonians from PySCF (N₂, H₂S, MgO, CO₂, NaCl), Ising and Heisenberg models in 1D/2D/3D, and random Hamiltonians of 30–80 qubits with 5n² Pauli strings. The superconducting target is IBM’s 65-qubit Manhattan; the fault-tolerant target follows standard gate-count/depth accounting. Baselines: t|ket⟩ with simultaneous diagonalization (‘TK’) and an algorithm-specific QAOA compiler for the first stage, with Qiskit L3 and t|ket⟩ O2 as generic second stages.

Simulation-kernel compilation: three approaches

PropertyGeneric gate-level (Qiskit L3 / t|ket⟩ O2)Operator-aware baseline (TK: simultaneous diagonalization; QAOA compiler)Paulihedral
What the compiler sees
Superconducting backend (65-qubit Manhattan model)Baseline second stageReference for first stage
Fault-tolerant backend—Reference
Scalability (compile time)
Real hardware (IBM 16-qubit Melbourne, 8 QAOA MaxCut programs)—
31 benchmarks; first-stage comparison vs t|ket⟩ (TK) and an algorithm-specific QAOA compiler, second stage via Qiskit L3 / t|ket⟩ O2; compilation on a 28-core Xeon server. TK's algorithmic constraints were relaxed to give it a larger optimization space (favoring the baseline). Real-system: 1-level QAOA, regular and random graphs of 7–10 nodes.Underlined values explain themselves when clicked.

Check your understanding

  1. 1. Gate-level compilers must prove every reordering safe, yet Paulihedral reorders blocks freely. What makes the difference?

  2. 2. Two adjacent Pauli strings share non-identity operators on five qubits. Predict where the gate savings come from when they are synthesized consecutively.

  3. 3. On superconducting chips, prior compilers synthesize the circuit first and insert SWAP gates afterward to satisfy connectivity. Why does Paulihedral instead grow each CNOT tree inside the device’s coupling graph?

  4. 4. Paulihedral adds only ~5% compilation time while t|ket⟩ exceeded 72 hours on large benchmarks. What explains the gap?

Related papers on Compilers & Programming Languages

See all 162 →