Context
Follow-up to #801 (which delivered Goal 1 — consolidating the bloqade.lanes transform APIs — in #822). This issue tracks Goal 2: achieving the layering invariant that only bloqade.gemini imports bloqade.lanes, never the reverse (no lanes → gemini edges, no cycles).
Current state (after #822)
There are 11 remaining bloqade.lanes → bloqade.gemini import edges, all deep/structural (Tier 2), in:
python/bloqade/lanes/rewrite/circuit2place.py — rewrites Gemini logical-dialect statements (Initialize, StarRz, TerminalLogicalMeasurement, NewAt)
python/bloqade/lanes/dialects/move.py, dialects/place.py — call gemini.star.validate_steane_star_support
python/bloqade/lanes/transform/native_to_place.py and transform/pipeline.py — wire in Gemini validations/rewrites (GeminiLogicalValidation, _RewriteU3ToInitialize, RewriteSteaneTransversalCliffordAdjoints, PhysicalTerminalMeasurementValidation, GeminiTerminalMeasurementValidation, DuplicateAddressValidation, gemini qubit dialect)
Approaches to evaluate
Severing these requires either:
- Moving the Gemini-specific dialects/validations/rewrites down into lanes — rejected: violates the layering principle (Gemini-specific statements in the machine-agnostic layer).
- Inverting the dependency — lanes exposes generic rewrite/validation registration hooks;
bloqade.gemini registers its statement-specific rewrites and validations. This is the principled fix and requires redesigning the squin→place stage.
Concrete first step (raised in PR #822 review)
In transform/native_to_place.py, the LogicalNativeToPlace._pre_native_rewrites hook imports a pile of Gemini rewrites/validations directly. As an incremental encapsulation step, package the squin→native lowering rewrites into a single Gemini-side transformation (e.g. bloqade.gemini.logical.transform.<LogicalSquinToNative> — pick a name that does not collide with the existing bloqade.native.upstream.squin2native.SquinToNative), so native_to_place.py imports one thing instead of ~7. This reduces the import surface and is a stepping stone toward the full dependency inversion, though it does not by itself remove the edge.
Also related (separately tracked)
Context
Follow-up to #801 (which delivered Goal 1 — consolidating the
bloqade.lanestransform APIs — in #822). This issue tracks Goal 2: achieving the layering invariant that onlybloqade.geminiimportsbloqade.lanes, never the reverse (nolanes → geminiedges, no cycles).Current state (after #822)
There are 11 remaining
bloqade.lanes → bloqade.geminiimport edges, all deep/structural (Tier 2), in:python/bloqade/lanes/rewrite/circuit2place.py— rewrites Gemini logical-dialect statements (Initialize,StarRz,TerminalLogicalMeasurement,NewAt)python/bloqade/lanes/dialects/move.py,dialects/place.py— callgemini.star.validate_steane_star_supportpython/bloqade/lanes/transform/native_to_place.pyandtransform/pipeline.py— wire in Gemini validations/rewrites (GeminiLogicalValidation,_RewriteU3ToInitialize,RewriteSteaneTransversalCliffordAdjoints,PhysicalTerminalMeasurementValidation,GeminiTerminalMeasurementValidation,DuplicateAddressValidation, geminiqubitdialect)Approaches to evaluate
Severing these requires either:
bloqade.geminiregisters its statement-specific rewrites and validations. This is the principled fix and requires redesigning the squin→place stage.Concrete first step (raised in PR #822 review)
In
transform/native_to_place.py, theLogicalNativeToPlace._pre_native_rewriteshook imports a pile of Gemini rewrites/validations directly. As an incremental encapsulation step, package the squin→native lowering rewrites into a single Gemini-side transformation (e.g.bloqade.gemini.logical.transform.<LogicalSquinToNative>— pick a name that does not collide with the existingbloqade.native.upstream.squin2native.SquinToNative), sonative_to_place.pyimports one thing instead of ~7. This reduces the import surface and is a stepping stone toward the full dependency inversion, though it does not by itself remove the edge.Also related (separately tracked)
bloqade.lanes.metrics.Metricsinto an analysis pass (removes another latentlanes → (to-be-gemini)coupling).AGENT.mdguidance to prevent re-coupling once Goal 2 lands.