quchip.chip.retarget¶
Retarget registry: convert control lines stranded by eliminate() (spec §6.4).
A control line whose target has no image in the reduced model — its device
was eliminated, or its coupling touched the eliminated mode — would
otherwise force the user to unwire it. A per-(drive type, target type,
result kind) registry lets a converter replace such a line with equivalent
lines wired to the reduced chip instead, e.g. a
FluxDrive on an eliminated coupler becomes a
ParametricDrive pumping each emitted edge.
Extending this registry never touches
eliminate() itself; a target with no
registered rule still raises the fail-fast unwire/keep error.
Functions
|
MRO-aware registry lookup: the most specific |
|
Register a converter for |
Classes
|
Everything a converter may consult; built by |
|
A converter's replacement lines, extra signal-chain transforms, and fold note. |
- class quchip.chip.retarget.RetargetContext(chip, reduced_chip, mode_label, result_kind, edges)[source]¶
Bases:
objectEverything a converter may consult; built by
eliminate()after the fold.- Parameters:
- chip¶
The original chip (read-only; pre-elimination).
- Type:
Any
- reduced_chip¶
The final reduced chip. Every emitted or upgraded edge already exists on it; control equipment is not yet attached.
- Type:
Any
- result_kind¶
Structure of what the reduction produced:
"edge"when the eliminated device mediated exchange between two or more survivors (one effective edge per survivor pair),"leaf-fold"for a single-survivor leaf,"crosskerr"for a coupling target.- Type:
- edges¶
For
"edge"and"crosskerr": the per-pair reduction entries, keyed(label_a, label_b)in emission order, each carrying at least"folded_into"(the edge’s label on the reduced chip) and — for"edge"— the exchange bookkeeping ("j_eff","dJ_domega_c", …). Always pair-keyed regardless of how many pairs there are: one entry is simply the two-survivor case, not a different shape.Nonefor"leaf-fold".
- class quchip.chip.retarget.RetargetResult(lines, transforms=(), note='')[source]¶
Bases:
objectA converter’s replacement lines, extra signal-chain transforms, and fold note.
- lines¶
Replacement control lines. Exactly one of them must keep the original line’s label, so existing
Crosstalk/Delayentries keyed by it — and replayedschedule()calls — stay valid; any further lines carry derived labels.- Type:
tuple[Any, …]
- quchip.chip.retarget.register_retarget_rule(drive_type, target_type, result_kind, rule)[source]¶
Register a converter for
(drive type, eliminated-target type, result kind).Lookup (
lookup_retarget_rule()) walks both types’ MROs, so a rule registered for a base type also covers its subclasses;result_kindmatches exactly. This is the extension point for teachingeliminate()to carry a new kind of stranded control line without modifying it.- Parameters:
drive_type (type) – Control-line class the rule handles.
target_type (type) – Eliminated-target class the rule handles: a device type (the eliminated mode itself) for
"edge"/"leaf-fold".result_kind (str) –
"edge","leaf-fold", or"crosskerr".rule (callable) –
rule(line, ctx: RetargetContext) -> RetargetResult.
- Return type:
None