Skip to content

Goal 2: fully decouple bloqade.lanes from bloqade.gemini (remove upward imports) #823

Description

@weinbe58

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:

  1. Moving the Gemini-specific dialects/validations/rewrites down into lanes — rejected: violates the layering principle (Gemini-specific statements in the machine-agnostic layer).
  2. 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)

Metadata

Metadata

Assignees

Labels

category: enhancementCategory: this is an enhancement of an existing feature.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions