quri_parts.qsub.eval package¶
- class AuxQubitCountEvaluatorHooks¶
Bases:
EvaluatorHooks[int]- reset()¶
- Return type:
None
- result()¶
- Return type:
int
- enter_sub(sub, qubits, regs, call_stack)¶
- Parameters:
sub (MachineSub)
qubits (Sequence[Qubit])
regs (Sequence[Register])
call_stack (list[qsub.machineinst.SubId])
- Return type:
bool
- exit_sub(sub, enter_sub, call_stack)¶
- Parameters:
sub (MachineSub)
enter_sub (bool)
call_stack (list[qsub.machineinst.SubId])
- Return type:
None
- class CallGraphEvaluatorHooks¶
Bases:
EvaluatorHooks[dict[Ident|None,dict[Ident,int]]]Report the call graph of a sub.
The result maps each sub to the subs it calls directly. Each callee maps to the number of calls in one invocation of the caller. Callees appear in the order of the first call. A sub that calls no sub maps to an empty dict.
Each sub appears as the
Identof the op it implements, the same valueSubwiseProfileEntryreports assource_op. Parametric subs are distinct per parameter:MCX<5>andMCX<6>are two subs. Only the entry sub ofcompile_subhas no op; its key isNone.- reset()¶
- Return type:
None
- enter_sub(sub, qubits, regs, call_stack)¶
- Parameters:
sub (MachineSub)
qubits (Sequence[Qubit])
regs (Sequence[Register])
call_stack (list[qsub.machineinst.SubId])
- Return type:
bool
- primitive(mop, qubits, regs, call_stack)¶
- exit_sub(sub, enter_sub, call_stack)¶
- Parameters:
sub (MachineSub)
enter_sub (bool)
call_stack (list[qsub.machineinst.SubId])
- Return type:
None
- class TotalQubitCountEvaluatorHooks¶
Bases:
AuxQubitCountEvaluatorHooksEvaluate the peak total qubit requirement of a machine subroutine.
- class GateCountBreakdown(own, descendants, cumulative)¶
Bases:
objectPrimitive-gate counts of a sub, split by where the gates come from.
owncovers the sub’s own instructions,descendantsthose contributed transitively by everything it calls, andcumulativetheir sum.- Parameters:
own (GateCounts)
descendants (GateCounts)
cumulative (GateCounts)
- own: GateCounts¶
- descendants: GateCounts¶
- cumulative: GateCounts¶
- class GateCountEvaluatorHooks(ops=())¶
Bases:
EvaluatorHooks[dict[tuple[NameSpace,str],int]]- Parameters:
ops (Iterable[AbstractOp])
- reset()¶
- Return type:
None
- result()¶
- Return type:
dict[qsub.op.BaseIdent, int]
- enter_sub(sub, qubits, regs, call_stack)¶
- Parameters:
sub (MachineSub)
qubits (Sequence[Qubit])
regs (Sequence[Register])
call_stack (list[qsub.machineinst.SubId])
- Return type:
bool
- exit_sub(sub, enter_sub, call_stack)¶
- Parameters:
sub (MachineSub)
enter_sub (bool)
call_stack (list[qsub.machineinst.SubId])
- Return type:
None
- class GateCounts(per_call, all_calls)¶
Bases:
objectPrimitive-gate counts of one scope.
Keys are gate
Idents, op parameters included, soRZ<0.1>andRZ<0.2>are counted apart; this is finer thanGateCountEvaluatorHooks, which keys byBaseIdentand merges them.per_callis for a single invocation of the sub,all_callsfor allcall_countof them.
- class QubitCounts(data, auxiliary, total)¶
Bases:
objectQubits a sub occupies during one invocation.
dataare the qubits the caller passes in.auxiliaryare the sub’s own ancillas (itsaux_qubits) plus the largestauxiliaryamong 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 QURIPartsEvaluatorHooks¶
Bases:
EvaluatorHooks[QuantumCircuit]- reset()¶
- Return type:
None
- result()¶
- Return type:
- enter_sub(sub, qubits, regs, call_stack)¶
- Parameters:
sub (MachineSub)
qubits (Sequence[Qubit])
regs (Sequence[Register])
call_stack (list[qsub.machineinst.SubId])
- Return type:
bool
- exit_sub(sub, enter_sub, call_stack)¶
- Parameters:
sub (MachineSub)
enter_sub (bool)
call_stack (list[qsub.machineinst.SubId])
- Return type:
None
- class SubwiseProfileEntry(source_op, call_count, qubit_counts, gate_counts)¶
Bases:
objectPer-sub profiling row produced by
SubwiseProfileEvaluatorHooks.source_opidentifies the op this sub implements, parameters included; useIdent.to_str()for a display name. It isNonewhen the op is unknown (the entry sub ofcompile_sub, which receives aSubrather than anOp).- Parameters:
source_op (Ident | None)
call_count (int)
qubit_counts (QubitCounts)
gate_counts (GateCountBreakdown)
- 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’ssource_opcarries the op parameters, so parametric subs are reported separately per parameter (MCX<5>andMCX<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:
sub (MachineSub)
qubits (Sequence[Qubit])
regs (Sequence[Register])
call_stack (list[qsub.machineinst.SubId])
- Return type:
bool
- primitive(mop, qubits, regs, call_stack)¶
- exit_sub(sub, enter_sub, call_stack)¶
- Parameters:
sub (MachineSub)
enter_sub (bool)
call_stack (list[qsub.machineinst.SubId])
- Return type:
None