quchip.chip.retarget¶
Retarget registry for control lines stranded by eliminate().
A control line’s target has no image in the reduced model when its device was
eliminated or its coupling touched the eliminated mode. Without this registry,
the user must unwire such a line. A per-(drive type, target type, result kind)
registry lets a converter replace the line with equivalent lines wired to the
reduced chip. For example, a FluxDrive on an
eliminated coupler becomes a ParametricDrive
that pumps each emitted edge. Extensions of this registry never touch
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 can 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 can consult, built by
eliminate()after the fold.- Variables:
chip (Any) – The original chip (read-only; pre-elimination).
reduced_chip (Any) – The final reduced chip. Every emitted or upgraded edge already exists on it; control equipment is not yet attached.
mode_label (str) – Label of the eliminated device (or coupling, for
"crosskerr").result_kind (str) – Structure of what the reduction produced. The value is
"edge"when the eliminated device mediated exchange between two or more survivors (one effective edge per survivor pair). The value is"leaf-fold"for a single-survivor leaf and"crosskerr"for a coupling target.edges (dict[tuple[str, str], dict[str, Any]] | None) – For
"edge"and"crosskerr": the per-pair reduction entries, keyed(label_a, label_b)in emission order. Each entry has at least"coupling"(the edge’s label on the reduced chip). For"edge", each entry also has the exchange bookkeeping ("j_eff","dJ_domega_c", …). The entries are always pair-keyed for any number of pairs, so one entry is 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.
- Variables:
lines (tuple[Any, ...]) – Replacement control lines. Exactly one of them must keep the original line’s label, so existing
Crosstalk/Delayentries keyed by that label, and replayedschedule()calls, stay valid. All other lines carry derived labels.transforms (tuple[Any, ...]) – Signal-chain transforms to append, in application order. The equipment applies its chain front to back, so a transform that feeds a line must come before a transform that scales it.
note (str) – One fold-report line, appended to
EliminationResult.notes.
- 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. Use this extension point to teacheliminate()to carry a new kind of stranded control line without changingeliminate().- 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.