Skip to content

Analysis

AtomInterpreter dataclass

AtomInterpreter(
    *,
    arch_spec: ArchSpec,
    best_state_cost: Callable[
        [AtomState], float
    ] = _default_best_state_cost
)

Bases: Forward[MoveExecution]


              flowchart TD
              bloqade.lanes.analysis.atom.analysis.AtomInterpreter[AtomInterpreter]

              

              click bloqade.lanes.analysis.atom.analysis.AtomInterpreter href "" "bloqade.lanes.analysis.atom.analysis.AtomInterpreter"
            

get_shot_remapping

get_shot_remapping(
    method: Method, *, no_raise: bool = True
) -> (
    _shot_remapping.ShotRemappingOk
    | _shot_remapping.ShotRemappingErr
)

Run the analysis on method and return the flat Zone-0 bitstring index list (in row-major order over the nested IListResult[IListResult[MeasureResult]] return shape) as a ShotRemappingOk. On failure, returns ShotRemappingErr carrying a ShotRemappingDiagnostic.

Convenience wrapper around the standalone bloqade.lanes.analysis.atom._shot_remapping.get_shot_remapping; see that function's docstring for the contract on the analysis output shape, the meaning of the returned indices, and the diagnostic emitted on failure.

method's return value is expected to refine to IListResult[IListResult[MeasureResult]] — the shape produced by lowering a logical terminal_measure (or any kernel that returns a nested ilist of measurement results) through the atom-analysis chain. Callers (typically the compiler service) are responsible for surfacing the diagnostic in the failure case; a failure here is a compiler-pipeline regression, not a user error.

Parameters:

Name Type Description Default
method Method

kirin method to analyse.

required
no_raise bool

when True (default), an analysis crash is caught by Forward.run_no_raise and falls through into the standard ShotRemappingErr path with the Bottom lattice as the offending value, so callers see a single failure shape. Flip to False when debugging an analysis-side bug to let the original exception propagate.

True
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/analysis/atom/analysis.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
def get_shot_remapping(
    self, method: ir.Method, *, no_raise: bool = True
) -> _shot_remapping.ShotRemappingOk | _shot_remapping.ShotRemappingErr:
    """Run the analysis on ``method`` and return the flat Zone-0
    bitstring index list (in row-major order over the nested
    ``IListResult[IListResult[MeasureResult]]`` return shape) as a
    ``ShotRemappingOk``. On failure, returns ``ShotRemappingErr``
    carrying a ``ShotRemappingDiagnostic``.

    Convenience wrapper around the standalone
    ``bloqade.lanes.analysis.atom._shot_remapping.get_shot_remapping``;
    see that function's docstring for the contract on the analysis
    output shape, the meaning of the returned indices, and the
    diagnostic emitted on failure.

    ``method``'s return value is expected to refine to
    ``IListResult[IListResult[MeasureResult]]`` — the shape produced
    by lowering a logical ``terminal_measure`` (or any kernel that
    returns a nested ilist of measurement results) through the
    atom-analysis chain. Callers (typically the compiler service)
    are responsible for surfacing the diagnostic in the failure
    case; a failure here is a compiler-pipeline regression, not a
    user error.

    Args:
        method: kirin method to analyse.
        no_raise: when ``True`` (default), an analysis crash is
            caught by ``Forward.run_no_raise`` and falls through
            into the standard ``ShotRemappingErr`` path with the
            ``Bottom`` lattice as the offending value, so callers
            see a single failure shape. Flip to ``False`` when
            debugging an analysis-side bug to let the original
            exception propagate.
    """
    run_method = self.run_no_raise if no_raise else self.run
    _, output = run_method(method)
    return _shot_remapping.get_shot_remapping(output, self.arch_spec)