quri_parts.qsub.eval.subwiseprofile module

class QubitCounts(data, auxiliary, total)

Bases: object

Qubits a sub occupies during one invocation.

data are the qubits the caller passes in. auxiliary are the sub’s own ancillas (its aux_qubits) plus the largest auxiliary among the subs it calls: sequential callees reuse the same ancilla space, so they contribute a maximum rather than a sum. The sub’s own ancillas stay live across those calls, so they add to that maximum.

Parameters:
  • data (int)

  • auxiliary (int)

  • total (int)

data: int
auxiliary: int
total: int
class GateCounts(per_call, all_calls)

Bases: object

Primitive-gate counts of one scope.

Keys are gate Idents, op parameters included, so RZ<0.1> and RZ<0.2> are counted apart; this is finer than GateCountEvaluatorHooks, which keys by BaseIdent and merges them. per_call is for a single invocation of the sub, all_calls for all call_count of them.

Parameters:
  • per_call (Mapping[Ident, int])

  • all_calls (Mapping[Ident, int])

per_call: Mapping[Ident, int]
all_calls: Mapping[Ident, int]
class GateCountBreakdown(own, descendants, cumulative)

Bases: object

Primitive-gate counts of a sub, split by where the gates come from.

own covers the sub’s own instructions, descendants those contributed transitively by everything it calls, and cumulative their sum.

Parameters:
own: GateCounts
descendants: GateCounts
cumulative: GateCounts
class SubwiseProfileEntry(source_op, call_count, qubit_counts, gate_counts)

Bases: object

Per-sub profiling row produced by SubwiseProfileEvaluatorHooks.

source_op identifies the op this sub implements, parameters included; use Ident.to_str() for a display name. It is None when the op is unknown (the entry sub of compile_sub, which receives a Sub rather than an Op).

Parameters:
source_op: Ident | None
call_count: int
qubit_counts: QubitCounts
gate_counts: GateCountBreakdown
class SubwiseProfileEvaluatorHooks(gates=())

Bases: EvaluatorHooks[list[SubwiseProfileEntry]]

Report, per distinct sub, how often it is called and the gate/qubit counts attributable to it.

Takes the same arguments as GateCountEvaluatorHooks: pass the ops to break down, or nothing to count every primitive. A row’s source_op carries the op parameters, so parametric subs are reported separately per parameter (MCX<5> and MCX<6> are distinct rows).

Parameters:

gates (Iterable[AbstractOp])

reset()
Return type:

None

result()
Return type:

list[SubwiseProfileEntry]

enter_sub(sub, qubits, regs, call_stack)
Parameters:
Return type:

bool

primitive(mop, qubits, regs, call_stack)
Parameters:
  • mop (Primitive)

  • qubits (Sequence[Qubit])

  • regs (Sequence[Register])

  • call_stack (list[qsub.machineinst.SubId])

Return type:

None

exit_sub(sub, enter_sub, call_stack)
Parameters:
  • sub (MachineSub)

  • enter_sub (bool)

  • call_stack (list[qsub.machineinst.SubId])

Return type:

None