Skip to main content

compile_clifford_proxy

Function compile_clifford_proxy 

Source
pub fn compile_clifford_proxy(
    config: CompileConfig,
    graph: &BlockGraph,
    pins: &[bool],
) -> Result<CompileArtifacts, CompileError>
Expand description

Compile graph with every dynamic element replaced by a Clifford stand-in.

This is a distance oracle, not a semantics oracle. Exact graph-level ZX maps remain the logical-correctness oracle:

  • Every T block becomes a perfect MPP input port on its escaped-patch footprint: a noiseless preparation of the d×d patch (one MPP record per stabilizer, closing the +Z neighbour’s seam like any memory face) whose passthrough gateway anchors a terminating logical at the past boundary via the ordinary boundary OBSERVABLE_INCLUDE MPP. A logical Y request resolves through the gateway’s X·Z composition — msc-ls’s S-for-T substitution lifted from per-gate to whole-block; the magic state’s phase does not affect circuit distance. The cultivation/escape circuits are dropped wholesale (the standalone harness owns their internal distance).
  • Every selective block is statically pinned to one arm per pins bit (deterministic ordered_blocks order), eliminating the dynamic choice dispatch; sweeping pin combos covers the branch space.
  • Structural Branch actions are rejected: these pins describe selective arms only and cannot choose an authored graph region.
  • The action track (feedback, conditional-S corrections) is dropped — Clifford frame corrections cannot change circuit distance.
  • Hierarchical inputs reuse their composed source certificate; topology is expanded only for this physical oracle.
  • Source stabilizer rows are reused and resolved through the pinned fills, without re-deriving a basis from the rewritten graph. Output frames use those resolved rows without replaying source actions.

The result is a fully determined program the static Stim backend accepts, suitable for shortest_graphlike_error / undetectable-error searches.

§Errors

Returns CompileError::CliffordProxyPinCount unless pins has exactly one bit per selective block in the expanded graph, and any compilation error the rewritten graph provokes. Pins follow expanded (z, x, y) block order.

§Examples

use bloq_compile::{CompileConfig, compile_clifford_proxy};
use bloq_graph::GalleryItem;

// One pin per selective block; the T gallery graph has one.
let proxy = compile_clifford_proxy(CompileConfig::default(), &GalleryItem::T.build(), &[false])?;
// Fully Clifford, so the static Stim backend accepts it.
bloq_stim::emit_bloq_stim(&proxy.bloq).expect("Clifford proxy emits static Stim");