qiskit_noise_learning.experiment_builder.Experiment
class qiskit_noise_learning.experiment_builder.Experiment(*, fidelity_model: LinearMap[Hashable, FidelityIndex] | ModelGateSet | None = None, paths: list[Path] | None = None, instruction_sequences: list[InstructionSequence] | None = None, relations: set[tuple[int, int]] | None = None, shots: int = 20, randomizations: int = 50, randomization_multipliers: list[int] | None = None, validate: bool = True)
Bases: object
A learning experiment specification.
An Experiment collects all the data needed to define a noise-learning experiment: a fidelity model, analysis paths, instruction sequences, their relations, and execution parameters (shots and randomizations).
All fields are optional and may be progressively populated via ExperimentBuilderStage instances.
Parameters
- fidelity_model – A fidelity model or a model gate set (which is wrapped in an
IdentityFidelityModel). - paths – Paths to analyze.
- instruction_sequences – Instruction sequences (may include both bound and unbound).
- relations – Set of
(path_idx, sequence_idx)tuples indicating which paths are traversed by which instruction sequences. - shots – Global number of shots (default 20).
- randomizations – Global number of randomizations (default 50).
- randomization_multipliers – Per-sequence randomization multiplier (parallel to instruction_sequences).
- validate – If
True(default), enforce the same validation checks asreplace()(co-replacement, length consistency, relations bounds).
__init__
__init__(*, fidelity_model: LinearMap[Hashable, FidelityIndex] | ModelGateSet | None = None, paths: list[Path] | None = None, instruction_sequences: list[InstructionSequence] | None = None, relations: set[tuple[int, int]] | None = None, shots: int = 20, randomizations: int = 50, randomization_multipliers: list[int] | None = None, validate: bool = True)
Methods
Column 1 | Column 2 |
|---|---|
__init__(*[, fidelity_model, paths, ...]) | |
replace(*[, validate]) | Return a shallow copy with the given fields overridden. |
Attributes
Column 1 | Column 2 |
|---|---|
design_matrix | The design matrix, lazily computed from the fidelity model and paths. |
fidelity_model | The fidelity model. |
gate_set | The model gate set. |
instruction_sequences | The instruction sequences. |
is_executable | Whether this experiment has all the information required to be run. |
paths | The analysis paths. |
randomization_multipliers | Per-sequence randomization multipliers. |
randomizations | Global number of randomizations. |
relations | The set of path and sequence relations. |
shots | Global number of shots. |
fidelity_model
Type: LinearMap[Hashable, FidelityIndex] | None
The fidelity model.
gate_set
Type: ModelGateSet | None
The model gate set.
paths
instruction_sequences
Type: list[InstructionSequence] | None
The instruction sequences.
relations
shots
Type: int
Global number of shots.
randomizations
Type: int
Global number of randomizations.
randomization_multipliers
design_matrix
Type: IndexedMatrix
The design matrix, lazily computed from the fidelity model and paths.
Raises
ValueError – If fidelity_model or paths is None.
is_executable
Type: bool
Whether this experiment has all the information required to be run.
Requires: instruction_sequences is set, all sequences are bound and complete, and randomization_multipliers is set.
replace
replace(*, validate: bool = True, **kwargs) → Experiment
Return a shallow copy with the given fields overridden.
When validate=True (default), the following checks are enforced:
- Co-replacement:
instruction_sequencesandrandomization_multipliersmust always both beNoneor both be non-None. Replacing one without the other is only allowed if it preserves this invariant. - Length consistency:
randomization_multipliersmust have the same length asinstruction_sequences. - Relations bounds: Setting
relationsrequirespathsandinstruction_sequencesto be present, and all indices must be in bounds. - Soft invalidation: Replacing
pathsorinstruction_sequenceswithout providing newrelationswill setrelationstoNonewith a warning.
Parameters
- validate – If
True, enforce the above checks. IfFalse, fields are set as-is with no validation. - **kwargs – Field names and their new values.
Raises
- TypeError – If an unrecognized field name is given.
- ValueError – If a validation constraint is violated.