diff --git a/docs/addons/qiskit-noise-learning/_toc.json b/docs/addons/qiskit-noise-learning/_toc.json new file mode 100644 index 000000000000..37e71f5b9c83 --- /dev/null +++ b/docs/addons/qiskit-noise-learning/_toc.json @@ -0,0 +1,53 @@ +{ + "parentUrl": "/docs/guides/addons", + "parentLabel": "Documentation", + "title": "Qiskit noise learning 0.1", + "collapsed": true, + "children": [ + { + "title": "", + "children": [ + { + "title": "Documentation home", + "url": "/docs/addons/qiskit-noise-learning" + }, + { + "title": "Installation instructions", + "url": "/docs/addons/qiskit-noise-learning/install" + }, + { + "title": "Guides", + "children": [ + { + "title": "Mathematical formalism", + "url": "/docs/addons/qiskit-noise-learning/guides/formalism" + }, + { + "title": "Build a learning experiment", + "url": "/docs/addons/qiskit-noise-learning/guides/workflow" + }, + { + "title": "Learn the noise model of a gate with NoiseLearner", + "url": "/docs/addons/qiskit-noise-learning/guides/noise-learner" + } + ] + }, + { + "title": "GitHub", + "url": "https://github.com/Qiskit/qiskit-noise-learning" + } + ], + "collapsible": false + }, + { + "title": "API reference", + "collapsible": false, + "children": [ + { + "title": "Python API reference", + "url": "/docs/api/qiskit-noise-learning" + } + ] + } + ] +} diff --git a/docs/addons/qiskit-noise-learning/guides/formalism.mdx b/docs/addons/qiskit-noise-learning/guides/formalism.mdx new file mode 100644 index 000000000000..6b68a7c47e9a --- /dev/null +++ b/docs/addons/qiskit-noise-learning/guides/formalism.mdx @@ -0,0 +1,180 @@ +--- +title: "Mathematical formalism" +description: "Mathematical formalism for the latest version of Qiskit noise learning" +--- + +# Mathematical formalism + +Given the task of learning Pauli noise for a set of Clifford gates, a common analysis technique is to track how individual Pauli operators are transformed through a sequence of gate applications (under the assumption that the gates are Clifford and the noise is a Pauli channel, a single Pauli will always be mapped to another Pauli up to a scalar that is a function of the noise). Obviously, the evolution of *any* state under such a sequence can be captured by a linear combination of such trajectories, but under the assumption that we always prepare the state in a Pauli eigenstate, and always measure and post-process the results to compute the expectation value of a Pauli operator, the relationship between the expectation value and the noise model parameters will *always* depend on only a single such trajectory. This follows from the simple fact that the initial state is a linear combination of Pauli operators, each gate and noise model maps Paulis to Paulis and preserves their orthogonality, and the final expectation value “selects” only one of the Paulis in the final decomposition before measurement. + +This type of reasoning appears in many parallel research tracks in noise learning, including in the Pauli gate-set learning literature [\[3\]](#references), [\[4\]](#references), the ACES literature [\[6\]](#references), and the cycle benchmarking literature [\[5\]](#references). This reasoning was further generalized in [\[7\]](#references) to include Clifford-MCM gates (a Clifford gate followed by a projective mid-circuit measurement). This package most closely follows [\[4\]](#references), [\[7\]](#references). While not explicitly named, we adopt the *Pattern Transfer Graph* (PTG) formalism for describing how Pauli operators evolve through learning circuits, providing a direct data representation of *paths* through the graph. + +The following is a review of some core mathematical concepts from the literature. It is primarily meant to consolidate notation, and to serve as a conceptual documentation reference for the rest of the package. + + + +## 1. Background + + + +### 1.1 Notation + +For $K \in \mathbb{N}$, let $[K] = \{0, 1, \dots, K - 1\}$. For a finite set $S \subset \mathbb{N}$ of qubit indices, let $\mathcal{P}^S$ denote the set of *unphased* Pauli operators acting on those qubits. Note that we think of elements of $\mathcal{P}^S$ as functions mapping $S \rightarrow \{I, X, Y, Z\}$, so that for any $P \in \mathcal{P}^S$ and $T \subseteq S$, $P|_T$ denotes the restriction of $P$ to the qubit subset $T$. Along these lines, for disjoint sets $S, T$, and $P \in \mathcal{P}^S$ and $Q \in \mathcal{P}^T$, $P \otimes Q$ denotes the element of $\mathcal{P}^{S \cup T}$ such that $P \otimes Q |_S = P$ and $P \otimes Q |_T = Q$. This notation is helpful to avoid explicitly dealing with subsystem orderings, and to make it easy to describe restrictions. + +For finite subsets $M \subset \mathbb{N}$, we denote $\mathbb{Z}_2^M$ as the set of the bit strings whose elements are indexed by $M$. Similarly to the above, we think of elements as functions mapping $M \rightarrow \mathbb{Z}_2$, so that we may easily describe substrings in terms of restrictions of the index set. + +Lastly, for a matrix $X$, we use $| X \rangle\!\rangle$ to denote its vectorization. Based on the limited way in which we use this notation, it is not actually necessary to choose a specific vectorization convention. For a classical bit string $m$, we use the shorthand $| m \rangle\!\rangle = | | m \rangle\langle m | \rangle\!\rangle$. + + + +### 1.2 Quantum instruments + +A quantum operation producing classical bits $m \in \mathbb{Z}_2^M$ (for example, the result of measurement) is generally modeled as a linear map of the form: + +$$ + \rho \mapsto \sum_{m \in \mathbb{Z}_2^M} \mathcal{E}_m(\rho) \otimes | m \rangle\langle m |, +$$ + +where the set $\{\mathcal{E}_m: m \in \mathbb{Z}_2^M\}$ are completely positive, and $\sum_m \mathcal{E}_m$ is trace-preserving. A set of completely positive maps $\{\mathcal{E}_m\}$ satisfying these properties is called a *quantum instrument*. A unitary gate is a special case of an instrument with only one element that is a unitary operation. + + + +## 2. Noisy Clifford-MCM-reset gates + +The formalism utilized in this package assumes every gate in the gate set to be characterized consists of the following sequence of operations on $K$ qubits: + +1. A Clifford operation on all qubits. +2. A mid-circuit projective measurement along $Z$ on some subset of qubits $M \subseteq [K]$. +3. A mid-circuit reset to the $Z$ ground state on some subset of qubits $R \subseteq [K]$. + +This is a general class of operations that includes unitary Clifford gates, measurement, state preparation, and any combination of the above. Note that we assume measurement and reset are always along the $Z$-axis for each qubit. While this is not strictly required, it is a common feature of many quantum computing modalities, and enables simplified representations and analysis. + +As outlined in [\[1\]](#references), [\[7\]](#references) for the no-reset case, if a specific twirling strategy is applied to a noisy instance of such a gate, then the action of the resulting operation can be modeled mathematically as a *uniform Pauli instrument*. That is, within the quantum instrument notation, $\mathcal{E}_m = \mathcal{U}_mG$, where $G$ is the Clifford unitary, and: + +$$ + \mathcal{U}_m = \sum_{a,b \in \mathbb{Z}_2^M} \Lambda_{a,b} \otimes | m + a \rangle\!\rangle\langle\!\langle m + b |, +$$ + +where each $\Lambda_{a,b}$ is a sub-normalized Pauli channel on the unmeasured qubits $N = [K] \setminus M$. It is implied by this being a quantum instrument that $\sum_{a,b} \Lambda_{a,b}$ is also trace-preserving. Some notes: + +* The initial untwirled noise is modeled to include both “quantum” and “classical” errors: erroneous operations on the quantum registers, as well as mistakes in the measurement value reporting. +* The noise map $\Lambda_{a,b}$ is *independent* of the measurement outcome $m$. + +In words, a single term in the above sum represents observing a measurement outcome of $m$ when the measured state was $| m + b \rangle$ (a misclassification if $b \neq 0$), and when the output state on the measurement register is $| m + a \rangle$ (the “wrong” state when $a \neq 0$). The map $\Lambda_{a,b}$ simultaneously encodes the action on the unmeasured qubits (conditioned on the measurement behavior) and the *probability* of the specific measurement behavior (through the normalization). + +Note that we are not concerned here with the specifics of the twirling strategy: that such a strategy exists to put the channel into the above form is enough. Note that “finer” twirling strategies exist which can further restrict the form of the Pauli channels [\[2\]](#references); however, we take the above form as the most general mathematical representation under consideration. + +In Lemma 1 of [\[7\]](#references), it is shown that $\mathcal{E}_m = \mathcal{U}_mG$ can be rewritten as: + + + +$$ + \mathcal{E}_m = \frac{1}{2^{2|M| + |N|}}\sum_{x, y \in \mathbb{Z}_2^M, Q \in \mathcal{P}^N} (-1)^{m \cdot (x + y)} +\lambda^Q_{x, y}| Q \otimes Z^y \rangle\!\rangle\langle\!\langle G^\dagger(Q \otimes Z^x) |. +$$ + +for some real numbers $\lambda_{x,y}^Q$, which are called the *fidelities* of the instrument. + +Adding reset to this picture is relatively straightforward. A noisy reset operation on qubits $R \subset [K]$ can be modeled according to the decomposition: + + + +$$ + \frac{1}{2^{|R|}}\sum_{r \in \mathbb{Z}_2^{R}} \lambda_r | Z^r \rangle\!\rangle\langle\!\langle I_R |. +$$ + +The above form explicitly utilizes the assumption that the reset is along the $Z$-axis for each qubit. Noise in the operation is encoded in the reset fidelities $\lambda_r$, which are simply indexed by qubit subsets. + +An analog to Equation [(1)](#equation-clifford-mcm-form) that includes a reset operation at the end can be attained by simply composing it with Equation [(2)](#equation-reset-form). This composition, after some simplification, yields: + + + +$$ +\begin{split} \frac{1}{2^{2|M|+|N|}} \sum_{\substack{x \in \mathbb{Z}_2^M, y \in \mathbb{Z}_2^{M \cup R} \\ Q \in +\mathcal{P}^{N\setminus R}}} (-1)^{m \cdot (x + y|_M)} \lambda^Q_{x,y} | Q \otimes +Z^y \rangle\!\rangle\langle\!\langle G^\dagger(Q \otimes I_{N \cap R} \otimes Z^x) |. \end{split} +$$ + +This decomposition indicates that the number of fidelities $\lambda^Q_{x, y}$ is + + + +$$ +4^{|N \setminus R|} 2^{|M|}2^{|M \cup R|} = 4^{K}2^{|M|}2^{-|M \cup R|} = 4^K 2^{-|R \setminus M|}. +$$ + +Consider limiting cases: (1) For no measurement or reset, $M = R = \emptyset$, and the expression yields $4^K$, the number of phase-less Pauli operators on $K$ qubits. (2) For $M = \emptyset$ and $R=[K]$, this yields $2^K$, which is the number of subsets of $[K]$. Lastly, (3) for $M = [K]$ and $R = \emptyset$, this yields $4^K$. Note that this may initially seem surprising: for standard learning, measurement and reset are typically considered to have the same number of fidelities: $2^K$. However, here the all-measurement gate in this context is understood not as a *terminal* measurement, but as an MCM, and as such fidelities corresponding to non-identity *outputs* of the measurement are also included (such as $y \neq 0$ in Equation [(3)](#equation-clifford-mcm-reset-form)). + +Finally, it is important to note that any twirling strategy yielding the form in Equation [(1)](#equation-clifford-mcm-form) in the non-reset case still applies equally well to the non-trivial reset case with a simple modification. The potential problem is that such a twirling strategy may require operations on measured qubits *after* the measurement. Therefore, if a qubit is measured *and* reset, implementing the strategy seemingly requires inserting operations *within* the gate between the measurement and reset. However, given the nature of reset, any such operations have no effect, and can simply be skipped while still yielding the same desired structure. + + + +## 3. Path formalism + +As described in the introduction, all learning algorithms for Pauli-type noise on Clifford gates are based around tracking how individual Paulis evolve through a circuit, picking up noise fidelity factors along the way. The expectation values of a circuit composed of such gates are therefore related simply to products of the underlying fidelities of the individual gates, and in this way model parameters can be inferred by *inverting* whatever sparse parameter-to-fidelity mapping is being assumed. + +In [\[4\]](#references), in the context of unitary gate sets, this is formalized into the *Pattern Transfer Graph* (PTG): a directed graph describing all possible experiments consisting of elements of the gate set and layers of single-qubit Clifford gates (assumed to be perfect, or “free”, operations). This was generalized in [\[7\]](#references) to include gate sets with mid-circuit measurements. In both cases, each experiment is described by tracking a single Pauli operator through the circuit, under the assumption of a particular observable being computed at each measurement site. Here we do not directly review the graph or path constructions; however, we present the required facts for justifying them within our own notation and with resets included. + +While the tracking of a single Pauli operator through the circuit may be intuitive in the unitary gate set case, it does not so obviously hold in the more general Clifford-MCM-reset case, due to the non-deterministic nature of measurement. The following proposition recovers this picture even in the more general case [\[7\]](#references): + + + + + For any $x \in \mathbb{Z}_2^M$, $y \in \mathbb{Z}_2^{M \cup R}$, and $Q\in \mathcal{P}^{N \setminus R}$, it holds that: + +$$ + +\langle\!\langle Q \otimes Z^y |\otimes \langle\!\langle Z^{x + y|_M} |_M \left(\sum_{m\in \mathbb{Z}_2^M} \mathcal{E}_m \otimes | m \rangle\!\rangle\right) += \lambda_{x,y}^Q\langle\!\langle G^\dagger(Q \otimes I_{N \cap R} \otimes Z^x) | + +$$ + + +In other words, if we compute the expectation value $Z^{x + y|_M}$ on the classical register output by the MCM, then the “Heisenberg picture” evolution of an observable through the Clifford-MCM-reset gate maps $Q \otimes Z^y \rightarrow Q \otimes I_{N \cap R} \otimes Z^x$. This fact alone enables recovery of PTG-like analysis beyond the unitary gate set case: with a particular post-processing of the measurement results, even gates with measurements and resets can be viewed as deterministically mapping one Pauli operator to another. + +Before proving this, we write Equation [(3)](#equation-clifford-mcm-reset-form) in a more suggestive way. Note that for $x, y \in \mathbb{Z}_2^M$, it holds that $Z^{x+y} = \sum_{m \in \mathbb{Z}_2^M} (-1)^{m \cdot (x + y)}| m \rangle\langle m |$, and as such (in super operator notation) we have: + +$$ +\begin{split} \begin{aligned} \sum_{m \in \mathbb{Z}_2^M} \mathcal{E}_m \otimes | m \rangle\!\rangle_M = \frac{1}{2^{2|M|+|N|}}\sum_{\substack{x \in +\mathbb{Z}_2^M, y \in \mathbb{Z}_2^{M \cup R} \\ Q \in \mathcal{P}^{N\setminus R}}} \lambda^Q_{x,y} | Q \otimes Z^y \rangle\!\rangle +\langle\!\langle G^\dagger(Q \otimes I_{N \cap R} \otimes Z^x) | \otimes | Z^{x + y|_M} \rangle\!\rangle_M, \end{aligned} \end{split} +$$ + +where we have applied Equation [(3)](#equation-clifford-mcm-reset-form) and collected terms, and we use the subscript $M$ to indicate the classical measurement result register, which we treat above in a similar notation to the quantum registers. + + + Proof. It holds that: + +$$ +\begin{split} +\begin{aligned} +&\langle\!\langle Q \otimes Z^y | \otimes \langle\!\langle Z^{x + y|_M} | \left(\sum_{m\in \mathbb{Z}_2^M} \mathcal{E}_m \otimes | m \rangle\!\rangle\right)\\ +&= \langle\!\langle Q \otimes Z^y | \otimes \langle\!\langle Z^{x + y|_M} | \left( \frac{1}{2^{2|M|+|N|}} \sum_{\substack{a \in \mathbb{Z}_2^M, b \in \mathbb{Z}_2^{M \cup R} \\ P \in \mathcal{P}^{N\setminus R}}} \lambda^P_{a,b} | P \otimes Z^b \rangle\!\rangle\langle\!\langle G^\dagger(P \otimes I_{N \cap R} \otimes Z^a) | \otimes | Z^{a + b|_M} \rangle\!\rangle \right) \\ +&=\frac{1}{2^{2|M| + |N|}}\sum_{\substack{a \in \mathbb{Z}_2^M, b \in \mathbb{Z}_2^{M \cup R} \\ P \in \mathcal{P}^{N \setminus R}}} \lambda^P_{a, b}\underbrace{\langle Q \otimes Z^y, P \otimes Z^b \rangle}_{2^{|M| + |N|} \delta_{P, Q}\delta_{y,b}} \underbrace{\langle Z^{x + y|_M}, Z^{a + b|_M} \rangle}_{2^{|M|}\delta_{x+y|_M,a+b|_M}}\langle\!\langle G^\dagger(P \otimes I_{N \cap R} \otimes Z^a) | +\end{aligned} +\end{split} +$$ + + Lastly, observe that $\delta_{y,b}\delta_{x+y|_M,a+b|_M} = \delta_{y,b}\delta_{x,a}$, and hence the final term above collapses down to the single term $\lambda^Q_{x,y} \opbra{G^\dagger(Q \otimes I_{N \cap R} \otimes Z^x)}$, yielding the desired result. + + +See [\[7\]](#references) for development beyond this point: the definition of the PTG, paths through the PTG, and the proof that any properly-defined path corresponds to an experiment. + + + +## References + +\[1] Stefanie J. Beale and Joel J. Wallman. Randomized compiling for subsystem measurements. 2023. URL: [http://arxiv.org/abs/2304.06599](http://arxiv.org/abs/2304.06599), doi:10.48550/arXiv.2304.06599. + +\[2] Ewout van den Berg and Pawel Wocjan. Techniques for learning sparse Pauli-Lindblad noise models. *Quantum*, 8:1556, 2024. URL: [https://quantum-journal.org/papers/q-2024-12-10-1556/](https://quantum-journal.org/papers/q-2024-12-10-1556/), doi:10.22331/q-2024-12-10-1556. + +\[3] Edward H. Chen, Senrui Chen, Laurin E. Fischer, Andrew Eddins, Luke C. G. Govia, Brad Mitchell, Andre He, Youngseok Kim, Liang Jiang, and Alireza Seif. Disambiguating pauli noise in quantum computers. *PRX Quantum*, pages, 2026. doi:10.1103/69wc-gzl6. + +\[4] Senrui Chen, Zhihan Zhang, Liang Jiang, and Steven T. Flammia. Efficient Self-Consistent Learning of Gate Set Pauli Noise. *PRX Quantum*, 7(1):010305, 2026. URL: [https://link.aps.org/doi/10.1103/1pnv-t9px](https://link.aps.org/doi/10.1103/1pnv-t9px), doi:10.1103/1pnv-t9px. + +\[5] Alexander Erhard, Joel J. Wallman, Lukas Postler, Michael Meth, Roman Stricker, Esteban A. Martinez, Philipp Schindler, Thomas Monz, Joseph Emerson, and Rainer Blatt. Characterizing large-scale quantum computers via cycle benchmarking. *Nature Communications*, 10(1):5347, 2019. doi:10.1038/s41467-019-13068-7. + +\[6] Steven T. Flammia. Averaged Circuit Eigenvalue Sampling. In 17th Conference on the Theory of Quantum Computation, Communication and Cryptography (TQC 2022), volume 232 of *Leibniz International Proceedings in Informatics* (LIPIcs), 4:1–4:10. Dagstuhl, Germany, 2022. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.TQC.2022.4. + +\[7] Zhihan Zhang, Senrui Chen, Yunchao Liu, and Liang Jiang. Generalized Cycle Benchmarking Algorithm for Characterizing Midcircuit Measurements. *PRX Quantum*, 6(1):010310, 2025. URL: [https://link.aps.org/doi/10.1103/PRXQuantum.6.010310](https://link.aps.org/doi/10.1103/PRXQuantum.6.010310), doi:10.1103/PRXQuantum.6.010310. + diff --git a/docs/addons/qiskit-noise-learning/guides/index.mdx b/docs/addons/qiskit-noise-learning/guides/index.mdx new file mode 100644 index 000000000000..77480609e7f0 --- /dev/null +++ b/docs/addons/qiskit-noise-learning/guides/index.mdx @@ -0,0 +1,7 @@ +--- +title: "Guides" +description: "Guides for the latest version of Qiskit noise learning" +--- + +# Guides + diff --git a/docs/addons/qiskit-noise-learning/guides/noise-learner.mdx b/docs/addons/qiskit-noise-learning/guides/noise-learner.mdx new file mode 100644 index 000000000000..f129e2427647 --- /dev/null +++ b/docs/addons/qiskit-noise-learning/guides/noise-learner.mdx @@ -0,0 +1,169 @@ +--- +title: "Learn the noise model of a gate with NoiseLearner" +description: "Learn the noise model of a gate with NoiseLearner for the latest version of Qiskit noise learning" +--- + +# Learn the noise model of a gate with NoiseLearner + +This guide demonstrates using [`NoiseLearner`](/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner#qiskit_noise_learning.noise_learner.NoiseLearner "qiskit_noise_learning.noise_learner.NoiseLearner") to learn a noise model for a unitary gate. + +1. Define the gate +2. Set up local simulation +3. Run the learner +4. Read the results + + + The circuits below are simulated locally, so this walkthrough needs no IBM Quantum® credentials. Two changes take it to a real device, each flagged again where it applies: + + * **Step 1**: replace [`FakeMarrakesh`](/docs/api/qiskit-ibm-runtime/fake-provider-fake-marrakesh "(in Qiskit Runtime IBM Client)") with a real backend. + * **Step 2**: skip it, and drop the `executor` argument in step 3. + + + + +## 1. Define the gate + +The gate whose noise we will learn is a [`BoxOp`](/docs/api/qiskit/qiskit.circuit.BoxOp) holding a layer of six disjoint `CZ` gates, with two Samplomatic annotations: `Twirl()` marks the box for Pauli twirling, and `InjectNoise("cz_gate")` names it. That name is the key under which the learned noise map is reported — and, because this guide simulates the gate, also the key under which noise is injected. + +```python +from qiskit.circuit import QuantumCircuit +from qiskit_ibm_runtime.fake_provider import FakeMarrakesh +from samplomatic import InjectNoise, Twirl + +backend = FakeMarrakesh() + +cz_pairs = [(91, 92), (93, 94), (95, 99), (98, 111), (112, 113), (114, 115)] + +circuit = QuantumCircuit(backend.num_qubits) +with circuit.box([Twirl(), InjectNoise("cz_gate")]): + for pair in cz_pairs: + circuit.cz(*pair) +``` + + + ```python + from qiskit_ibm_runtime import QiskitRuntimeService + + backend = QiskitRuntimeService().backend("ibm_marrakesh") + ``` + + + + +## 2. Set up local simulation + +An [`AerExecutor`](/docs/api/qiskit-noise-learning/generated/aer-executor-aer-executor#qiskit_noise_learning.aer_executor.AerExecutor "qiskit_noise_learning.aer_executor.AerExecutor") runs a program on a local Aer simulator, injecting Pauli-Lindblad noise at the barriers Samplomatic places around each twirled gate. + +The Pauli indices inside each map are local to the gate, in ascending physical-qubit order: + +```python +cz_qubits = sorted({qubit for pair in cz_pairs for qubit in pair}) +local = {qubit: index for index, qubit in enumerate(cz_qubits)} +local +``` + +```myst +{91: 0, + 92: 1, + 93: 2, + 94: 3, + 95: 4, + 98: 5, + 99: 6, + 111: 7, + 112: 8, + 113: 9, + 114: 10, + 115: 11} +``` + +The gate gets a correlated `ZZ` term and a weaker `XX` term on each `CZ` pair, plus a single-qubit `Z` term everywhere; preparation and measurement each get a bit-flip term per qubit. + +```python +from qiskit.quantum_info import PauliLindbladMap + +num_qubits = len(cz_qubits) + +cz_noise = PauliLindbladMap.from_sparse_list( + [("ZZ", [local[a], local[b]], 8e-4) for a, b in cz_pairs] + + [("XX", [local[a], local[b]], 4e-4) for a, b in cz_pairs] + + [("Z", [index], 3e-4) for index in range(num_qubits)], + num_qubits=num_qubits, +) + +spam_noise = PauliLindbladMap.from_sparse_list( + [("X", [index], 5e-3) for index in range(num_qubits)], num_qubits=num_qubits +) + +noise_dict = {"cz_gate": cz_noise, "P": spam_noise, "M": spam_noise} +``` + +Instantiate [`AerExecutor`](/docs/api/qiskit-noise-learning/generated/aer-executor-aer-executor#qiskit_noise_learning.aer_executor.AerExecutor "qiskit_noise_learning.aer_executor.AerExecutor") with the stabilizer method. Set `root_seed` to make the simulated data reproducible. + +```python +from qiskit_aer import AerSimulator + +from qiskit_noise_learning.aer_executor import AerExecutor + +executor = AerExecutor( + AerSimulator(method="stabilizer"), noise_dict=noise_dict, root_seed=1234 +) +``` + + + Skip this step entirely. + + + + +## 3. Run the learner + +[`LearningOptions`](/docs/api/qiskit-noise-learning/generated/noise-learner-learning-options#qiskit_noise_learning.noise_learner.LearningOptions "qiskit_noise_learning.noise_learner.LearningOptions") controls the shape of the experiment: how deep the twirled gate is repeated, and how many randomizations and shots are spent at each depth. Passing `executor` diverts the generated program to the simulator; leave it out and [`NoiseLearner`](/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner#qiskit_noise_learning.noise_learner.NoiseLearner "qiskit_noise_learning.noise_learner.NoiseLearner") submits to `backend` through IBM Quantum instead. + +```python +from qiskit_noise_learning.noise_learner import LearningOptions, NoiseLearner + +options = LearningOptions( + fragment_depths=[2, 16, 64, 128], + num_randomizations=50, + shots_per_randomizations=20, +) + +learner = NoiseLearner(backend, options=options, executor=executor) + +job = learner.run([circuit[0]]) +result = job.result() +``` + + + ```python + learner = NoiseLearner(backend, options=options) + ``` + + + + +## 4. Read the results + +Everything the analysis pipeline produced is reachable through [`fit`](/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner-result#qiskit_noise_learning.noise_learner.NoiseLearnerResult.fit "qiskit_noise_learning.noise_learner.NoiseLearnerResult.fit"). Use the fit to plot per-qubit-pair fidelity decays: both the data and the exponential fit. + +```python +result.fit.plot_qubit_pair_decays( + pairs=cz_pairs, + observable_type="means", + exponential_fit=True, +) +``` + +Extract the learned noise from [`to_dict()`](/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner-result#qiskit_noise_learning.noise_learner.NoiseLearnerResult.to_dict "qiskit_noise_learning.noise_learner.NoiseLearnerResult.to_dict"): one [`PauliLindbladMap`](/docs/api/qiskit/qiskit.quantum_info.PauliLindbladMap) per learned gate, keyed by the name from the `InjectNoise` annotation, and expressed in the backend’s own qubit indexing rather than that of the gate. + +```python +learned = result.to_dict()["cz_gate"] +learned.num_terms +``` + +```myst +144 +``` + +By default [`NoiseLearner`](/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner#qiskit_noise_learning.noise_learner.NoiseLearner "qiskit_noise_learning.noise_learner.NoiseLearner") fits a 2-local model, so the map carries a term for every Pauli supported on a connected pair of the gate’s qubits — 144 of them, of which only 24 were given a nonzero rate in step 2. diff --git a/docs/addons/qiskit-noise-learning/guides/workflow.mdx b/docs/addons/qiskit-noise-learning/guides/workflow.mdx new file mode 100644 index 000000000000..4966dd3d9e63 --- /dev/null +++ b/docs/addons/qiskit-noise-learning/guides/workflow.mdx @@ -0,0 +1,293 @@ +--- +title: "Build a learning experiment" +description: "Build a learning experiment for the latest version of Qiskit noise learning" +--- + +# Build a learning experiment + +This guide demonstrates how to build a standard learning experiment from scratch, and use it to learn a model from simulated noisy data. + +1. Define a gate set on a ring of qubits +2. Choose a 2-local Pauli-Lindblad model +3. Build the learning experiment +4. Generate circuits +5. Set up local simulation +6. Run the program +7. Analyze the data + + + The circuits below are simulated locally, so this walkthrough needs no IBM Quantum® credentials. Three changes take it to a real device, each flagged again where it applies: + + * **Step 1**: replace [`FakeMarrakesh`](/docs/api/qiskit-ibm-runtime/fake-provider-fake-marrakesh "(in Qiskit Runtime IBM Client)") with a real backend. + * **Step 5**: skip it. + * **Step 6**: submit through [`Executor`](/docs/api/qiskit-ibm-runtime/executor "(in Qiskit Runtime IBM Client)"). + + + + +## 1. Define a gate set on a ring of qubits + +Build a [`QiskitGateSet`](/docs/api/qiskit-noise-learning/generated/gate-sets-qiskit-gate-set#qiskit_noise_learning.gate_sets.QiskitGateSet "qiskit_noise_learning.gate_sets.QiskitGateSet") from a backend [`Target`](/docs/api/qiskit/qiskit.transpiler.Target) and a subset of its qubits — here a twelve-qubit ring of [`FakeMarrakesh`](/docs/api/qiskit-ibm-runtime/fake-provider-fake-marrakesh "(in Qiskit Runtime IBM Client)") — then add one gate to it: a layer of six `CZ` gates covering that ring. By default the gate set is initialized with a preparation gate `P` and a measurement gate `M`. + +```python +from qiskit_ibm_runtime.fake_provider import FakeMarrakesh + +from qiskit_noise_learning.gate_sets import QiskitGateSet + +backend = FakeMarrakesh() + +qubit_subset = [*range(25, 30), *range(37, 39), *range(45, 50)] +cz_pairs = [(25, 26), (27, 28), (29, 38), (37, 45), (46, 47), (48, 49)] + +gate_set = QiskitGateSet(backend.num_qubits, target=backend.target, qubit_subset=qubit_subset) + +with gate_set.build_new_gate("cz_gate", latex_str=r"\mathrm{CZ}") as builder: + for pair in cz_pairs: + builder.circuit.cz(*pair) + +list(gate_set) +``` + +```myst +['M', 'P', 'cz_gate'] +``` + + + ```python + from qiskit_ibm_runtime import QiskitRuntimeService + + backend = QiskitRuntimeService().backend("ibm_marrakesh") + ``` + + +Call [`draw()`](/docs/api/qiskit-noise-learning/generated/gate-sets-gate-set#qiskit_noise_learning.gate_sets.GateSet.draw "qiskit_noise_learning.gate_sets.GateSet.draw") to see the gate on the device topology: the ring of qubits in the gate set, and which pairs of them the gate entangles. + +```python +gate_set.draw() +``` + + + +## 2. Choose a 2-local Pauli-Lindblad model + +Decide which Pauli-Lindblad generators the noise is allowed to have with a [`PauliLindbladModel`](/docs/api/qiskit-noise-learning/generated/models-pauli-lindblad-model#qiskit_noise_learning.models.PauliLindbladModel "qiskit_noise_learning.models.PauliLindbladModel"). Build that generator set from the gate set’s connectivity with [`k_local()`](/docs/api/qiskit-noise-learning/generated/models-pauli-lindblad-model#qiskit_noise_learning.models.PauliLindbladModel.k_local "qiskit_noise_learning.models.PauliLindbladModel.k_local") — here every 2-local Pauli on connected qubit pairs of the unitary gate, and single-qubit Paulis for preparation and measurement. + +```python +from qiskit_noise_learning.models import PauliLindbladModel + +model = PauliLindbladModel.k_local(gate_set, gate_k={"cz_gate": 2, "M": 1, "P": 1}) +``` + +Display the unknown parameter count for the noise model of each gate. + +```python +{name: len(generators) for name, generators in model.generators.items()} +``` + +```myst +{'M': 12, 'P': 12, 'cz_gate': 144} +``` + + + +## 3. Build the learning experiment + +Assemble an [`Experiment`](/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment#qiskit_noise_learning.experiment_builder.Experiment "qiskit_noise_learning.experiment_builder.Experiment") by composing builder stages. Each stage reads what earlier stages wrote, so order matters: + +```python +from qiskit_noise_learning.experiment_builder import ( + BindFragmentDepths, + CompleteSequences, + EvenDepthVanillaPaths, + Experiment, + GenerateInstructionSequences, + IdentifyRelations, + MergeInstructionSequences, + SPAMPaths, + VanillaInstructionSequences, +) + +experiment_builder = ( + # Add standard vanilla learning paths and instruction sequences, and identify relations + EvenDepthVanillaPaths() + + VanillaInstructionSequences() + + IdentifyRelations() + # Add paths for learning SPAM, then generate and merge instruction sequences for measuring them + + SPAMPaths() + + GenerateInstructionSequences() + + MergeInstructionSequences() + # Finalize by completing the instruction sequences and setting experiment depths + + CompleteSequences() + + BindFragmentDepths([2, 16, 32, 64]) +) + +experiment = experiment_builder.run( + Experiment(fidelity_model=model, shots=20, randomizations=50) +) + +print(f"Number of paths: {len(experiment.paths)}") +print(f"Number of instruction sequences: {len(experiment.instruction_sequences)}") +``` + +```myst +Number of paths: 156 +Number of instruction sequences: 37 +``` + +Observe design matrix rank: + +```python +print(f"Design matrix rank: {experiment.design_matrix.rank}") +``` + +```myst +Design matrix rank: 120 +``` + + + +## 4. Generate circuits + +Compile the experiment with an [`ExecutorCircuitGenerator`](/docs/api/qiskit-noise-learning/generated/circuit-generator-executor-circuit-generator#qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator "qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator"), generating a [`QuantumProgram`](/docs/api/qiskit-ibm-runtime/quantum-program-quantum-program "(in Qiskit Runtime IBM Client)") — one parameterized template circuit per fragment depth — together with a data mapper that records how to interpret results. + +```python +from qiskit_noise_learning.circuit_generator import ExecutorCircuitGenerator + +circuit_generator = ExecutorCircuitGenerator(gate_set) +quantum_program, data_mapper = circuit_generator.generate(experiment) + +print(f"Number of template circuits: {len(quantum_program.items)}") +``` + +```myst +Number of template circuits: 5 +``` + +Draw a template circuit to inspect. + +```python +quantum_program.items[0].circuit.draw("mpl", idle_wires=False, fold=False) +``` + +![../\_images/cbfeb7989573772757ac81e9b3a0665f8a0513450d76bfc5ab63e24f40c6b8f6.png](/docs/images/addons/qiskit-noise-learning/cbfeb7989573772757ac81e9b3a0665f8a0513450d76bfc5ab63e24f40c6b8f6.avif) + + + +## 5. Set up local simulation + +An [`AerExecutor`](/docs/api/qiskit-noise-learning/generated/aer-executor-aer-executor#qiskit_noise_learning.aer_executor.AerExecutor "qiskit_noise_learning.aer_executor.AerExecutor") runs a program on a local Aer simulator, injecting Pauli-Lindblad noise at the barriers Samplomatic places around each twirled gate. + +Unlike the hand-picked noise of the [`NoiseLearner`](/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner#qiskit_noise_learning.noise_learner.NoiseLearner "qiskit_noise_learning.noise_learner.NoiseLearner") guide, give *every one* of the model’s 168 generators an independent random rate. The model’s generators are already exactly the Paulis to put in a [`PauliLindbladMap`](/docs/api/qiskit/qiskit.quantum_info.PauliLindbladMap), so pair each one with a rate and build the map per gate directly: + +```python +import numpy as np +from qiskit.quantum_info import PauliLindbladMap + +rng = np.random.default_rng(1234) + +true_maps = { + name: PauliLindbladMap.from_terms( + [ + PauliLindbladMap.GeneratorTerm(rate, generator) + for generator, rate in zip(generators, rng.uniform(2e-4, 1.5e-3, len(generators))) + ] + ) + for name, generators in model.generators.items() +} +{name: noise_map.num_qubits for name, noise_map in true_maps.items()} +``` + +```myst +{'M': 156, 'P': 156, 'cz_gate': 156} +``` + +Those maps are as wide as the device, since the model is expressed in `backend`’s qubit indexing, but [`AerExecutor`](/docs/api/qiskit-noise-learning/generated/aer-executor-aer-executor#qiskit_noise_learning.aer_executor.AerExecutor "qiskit_noise_learning.aer_executor.AerExecutor") wants each map to be as wide as the gate it applies to, with Pauli indices running over the gate’s qubits in ascending physical order. Narrow them with [`keep_qubits()`](/docs/api/qiskit/qiskit.quantum_info.PauliLindbladMap#keep_qubits), which traces out everything off the ring: + +```python +noise_dict = { + name: noise_map.keep_qubits(qubit_subset) for name, noise_map in true_maps.items() +} +{name: noise_map.num_qubits for name, noise_map in noise_dict.items()} +``` + +```myst +{'M': 12, 'P': 12, 'cz_gate': 12} +``` + +Instantiate [`AerExecutor`](/docs/api/qiskit-noise-learning/generated/aer-executor-aer-executor#qiskit_noise_learning.aer_executor.AerExecutor "qiskit_noise_learning.aer_executor.AerExecutor") with the stabilizer method. Set `root_seed` to make the simulated data reproducible. + +```python +from qiskit_aer import AerSimulator + +from qiskit_noise_learning.aer_executor import AerExecutor + +executor = AerExecutor( + AerSimulator(method="stabilizer"), noise_dict=noise_dict, root_seed=42 +) +``` + + + Skip this step entirely. + + + + +## 6. Run the program + +Run the program, then pair the returned bitstrings with the data mapper using [`collect()`](/docs/api/qiskit-noise-learning/generated/circuit-generator-executor-circuit-generator#qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.collect "qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.collect"), which produces a [`Fit`](/docs/api/qiskit-noise-learning/generated/analysis-fit#qiskit_noise_learning.analysis.Fit "qiskit_noise_learning.analysis.Fit") — the container the analysis stages read from and write to. + +```python +job = executor.run(quantum_program) +fit = circuit_generator.collect(job.result(), data_mapper) +``` + + + ```python + from qiskit_ibm_runtime import Executor + + executor = Executor(mode=backend) + ``` + + + + +## 7. Analyze the data + +Build an analysis pipeline around nonnegative least squares fitting of the model. + +```python +from qiskit_noise_learning.analysis import ( + ComputeObservables, # computes observables from raw data + CurveFitObservables, # performs exponential fitting + NNLSSolve, # solves model with nonnegative least squares +) + +analyzer = ComputeObservables() + CurveFitObservables() + NNLSSolve() + +fit = analyzer.run(fit) +``` + +```myst +/opt/hostedtoolcache/Python/3.12.14/x64/lib/python3.12/site-packages/qiskit_noise_learning/analysis/model_solve.py:244: UserWarning: 3 of 156 row(s) of the linear system have a non-positive or non-finite uncertainty, so they carry no usable statistical weight. Positions in LinearSystemData.row_labels: 145, 146, 147. + system = LinearSystemData.from_fit(fit) +``` + +Plot the measured observable means against their fitted exponentials, one subplot per `CZ` pair, to see whether the decays being fitted are exponential at all. + +```python +fit.plot_qubit_pair_decays( + pairs=cz_pairs, + observable_type="means", + exponential_fit=True, +) +``` + +Swap `exponential_fit` for `model_prediction` to compare the same data against the decays implied by the rates that came out of the non-negative least squares solve. + +```python +fit.plot_qubit_pair_decays( + pairs=cz_pairs, + observable_type="means", + model_prediction=True, +) +``` diff --git a/docs/addons/qiskit-noise-learning/index.mdx b/docs/addons/qiskit-noise-learning/index.mdx new file mode 100644 index 000000000000..204184c3e929 --- /dev/null +++ b/docs/addons/qiskit-noise-learning/index.mdx @@ -0,0 +1,13 @@ +--- +title: "Qiskit noise learning" +description: "Documentation for the latest version of Qiskit noise learning" +--- + +# Qiskit noise learning + +A Python toolkit for randomization-based quantum noise characterization. + + + This library is in the 0.x stage of development and under active development. No part of the public interface is yet stable: while the major version is 0, expect breaking changes between releases and pin your dependency accordingly (for example, qiskit-noise-learning==0.1.\*). We do not currently issue deprecation warnings, but all changes are recorded in the changelog. See the \[deprecation policy]\(DEPRECATION.md) for details. All feedback is appreciated. + + diff --git a/docs/addons/qiskit-noise-learning/install.mdx b/docs/addons/qiskit-noise-learning/install.mdx new file mode 100644 index 000000000000..6e6a4a913401 --- /dev/null +++ b/docs/addons/qiskit-noise-learning/install.mdx @@ -0,0 +1,21 @@ +--- +title: "Installation" +description: "Installation for the latest version of Qiskit noise learning" +--- + +# Installation + +You can install `qiskit-noise-learning` via pip from the GitHub repository (`main` branch): + +```bash +pip install "git+https://github.com/Qiskit/qiskit-noise-learning@main" +``` + +For visualization support, include the visualization dependencies: + +```bash +pip install "qiskit-noise-learning[vis] @ git+https://github.com/Qiskit/qiskit-noise-learning@main" +``` + +See the [contribution guidelines](https://github.com/Qiskit/qiskit-noise-learning/blob/main/CONTRIBUTING.md) for developer dependencies and editable installations. + diff --git a/docs/api/qiskit-noise-learning/_package.json b/docs/api/qiskit-noise-learning/_package.json new file mode 100644 index 000000000000..f4ee5149b7ba --- /dev/null +++ b/docs/api/qiskit-noise-learning/_package.json @@ -0,0 +1,4 @@ +{ + "name": "qiskit-noise-learning", + "version": "0.1.0" +} diff --git a/docs/api/qiskit-noise-learning/_toc.json b/docs/api/qiskit-noise-learning/_toc.json new file mode 100644 index 000000000000..31ec4363280a --- /dev/null +++ b/docs/api/qiskit-noise-learning/_toc.json @@ -0,0 +1,526 @@ +{ + "title": "Qiskit noise learning", + "children": [ + { + "title": "API index", + "url": "/docs/api/qiskit-noise-learning" + }, + { + "title": "Release notes", + "useDivider": true, + "url": "/docs/api/qiskit-noise-learning/release-notes" + }, + { + "title": "qiskit_noise_learning.aer_executor", + "untranslatable": true, + "children": [ + { + "title": "Module overview", + "url": "/docs/api/qiskit-noise-learning/aer-executor" + }, + { + "title": "AerExecutor", + "url": "/docs/api/qiskit-noise-learning/generated/aer-executor-aer-executor", + "untranslatable": true + }, + { + "title": "AerRuntimeJob", + "url": "/docs/api/qiskit-noise-learning/generated/aer-executor-aer-runtime-job", + "untranslatable": true + }, + { + "title": "inline_samplexes", + "url": "/docs/api/qiskit-noise-learning/generated/aer-executor-inline-samplexes", + "untranslatable": true + } + ] + }, + { + "title": "qiskit_noise_learning.analysis", + "untranslatable": true, + "children": [ + { + "title": "Module overview", + "url": "/docs/api/qiskit-noise-learning/analysis" + }, + { + "title": "AnalysisPipeline", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-analysis-pipeline", + "untranslatable": true + }, + { + "title": "AnalysisStage", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-analysis-stage", + "untranslatable": true + }, + { + "title": "AverageObservables", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-average-observables", + "untranslatable": true + }, + { + "title": "ComputeObservables", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-compute-observables", + "untranslatable": true + }, + { + "title": "CurveFitObservables", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-curve-fit-observables", + "untranslatable": true + }, + { + "title": "Fit", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-fit", + "untranslatable": true + }, + { + "title": "FlipPostSelect", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-flip-post-select", + "untranslatable": true + }, + { + "title": "LegacySolve", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-legacy-solve", + "untranslatable": true + }, + { + "title": "LinearSystemData", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-linear-system-data", + "untranslatable": true + }, + { + "title": "LSQLinearSolve", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-lsq-linear-solve", + "untranslatable": true + }, + { + "title": "NNLSSolve", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-nnls-solve", + "untranslatable": true + }, + { + "title": "PositivityMinSolve", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-positivity-min-solve", + "untranslatable": true + }, + { + "title": "SymmetrizeFidelities", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-symmetrize-fidelities", + "untranslatable": true + }, + { + "title": "SymmetrizeGenerators", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-symmetrize-generators", + "untranslatable": true + }, + { + "title": "ZeroPostSelect", + "url": "/docs/api/qiskit-noise-learning/generated/analysis-zero-post-select", + "untranslatable": true + } + ] + }, + { + "title": "qiskit_noise_learning.circuit_generator", + "untranslatable": true, + "children": [ + { + "title": "Module overview", + "url": "/docs/api/qiskit-noise-learning/circuit-generator" + }, + { + "title": "ExecutorCircuitGenerator", + "url": "/docs/api/qiskit-noise-learning/generated/circuit-generator-executor-circuit-generator", + "untranslatable": true + }, + { + "title": "ExecutorDataMapper", + "url": "/docs/api/qiskit-noise-learning/generated/circuit-generator-executor-data-mapper", + "untranslatable": true + } + ] + }, + { + "title": "qiskit_noise_learning.data", + "untranslatable": true, + "children": [ + { + "title": "Module overview", + "url": "/docs/api/qiskit-noise-learning/data" + }, + { + "title": "AggregatedObservableData", + "url": "/docs/api/qiskit-noise-learning/generated/data-aggregated-observable-data", + "untranslatable": true + }, + { + "title": "LeveledData", + "url": "/docs/api/qiskit-noise-learning/generated/data-leveled-data", + "untranslatable": true + }, + { + "title": "ModelData", + "url": "/docs/api/qiskit-noise-learning/generated/data-model-data", + "untranslatable": true + }, + { + "title": "ObservableData", + "url": "/docs/api/qiskit-noise-learning/generated/data-observable-data", + "untranslatable": true + }, + { + "title": "RawData", + "url": "/docs/api/qiskit-noise-learning/generated/data-raw-data", + "untranslatable": true + } + ] + }, + { + "title": "qiskit_noise_learning.experiment_builder", + "untranslatable": true, + "children": [ + { + "title": "Module overview", + "url": "/docs/api/qiskit-noise-learning/experiment-builder" + }, + { + "title": "AddInstructionSequences", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-add-instruction-sequences", + "untranslatable": true + }, + { + "title": "AddPaths", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-add-paths", + "untranslatable": true + }, + { + "title": "BindFragmentDepths", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-bind-fragment-depths", + "untranslatable": true + }, + { + "title": "CompleteSequences", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-complete-sequences", + "untranslatable": true + }, + { + "title": "Depth1Paths", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-depth-1-paths", + "untranslatable": true + }, + { + "title": "EvenDepthPaths", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-even-depth-paths", + "untranslatable": true + }, + { + "title": "EvenDepthVanillaPaths", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-even-depth-vanilla-paths", + "untranslatable": true + }, + { + "title": "Experiment", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment", + "untranslatable": true + }, + { + "title": "ExperimentBuilder", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment-builder", + "untranslatable": true + }, + { + "title": "ExperimentBuilderStage", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment-builder-stage", + "untranslatable": true + }, + { + "title": "GenerateInstructionSequences", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-generate-instruction-sequences", + "untranslatable": true + }, + { + "title": "IdentifyRelations", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-identify-relations", + "untranslatable": true + }, + { + "title": "MergeInstructionSequences", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-merge-instruction-sequences", + "untranslatable": true + }, + { + "title": "RankReducePaths", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-rank-reduce-paths", + "untranslatable": true + }, + { + "title": "SPAMPaths", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-spam-paths", + "untranslatable": true + }, + { + "title": "VanillaInstructionSequences", + "url": "/docs/api/qiskit-noise-learning/generated/experiment-builder-vanilla-instruction-sequences", + "untranslatable": true + } + ] + }, + { + "title": "qiskit_noise_learning.gate_sets", + "untranslatable": true, + "children": [ + { + "title": "Module overview", + "url": "/docs/api/qiskit-noise-learning/gate-sets" + }, + { + "title": "Gate", + "url": "/docs/api/qiskit-noise-learning/generated/gate-sets-gate", + "untranslatable": true + }, + { + "title": "GateSet", + "url": "/docs/api/qiskit-noise-learning/generated/gate-sets-gate-set", + "untranslatable": true + }, + { + "title": "ModelGate", + "url": "/docs/api/qiskit-noise-learning/generated/gate-sets-model-gate", + "untranslatable": true + }, + { + "title": "ModelGateSet", + "url": "/docs/api/qiskit-noise-learning/generated/gate-sets-model-gate-set", + "untranslatable": true + }, + { + "title": "QiskitGate", + "url": "/docs/api/qiskit-noise-learning/generated/gate-sets-qiskit-gate", + "untranslatable": true + }, + { + "title": "QiskitGateSet", + "url": "/docs/api/qiskit-noise-learning/generated/gate-sets-qiskit-gate-set", + "untranslatable": true + } + ] + }, + { + "title": "qiskit_noise_learning.math", + "untranslatable": true, + "children": [ + { + "title": "Module overview", + "url": "/docs/api/qiskit-noise-learning/math" + }, + { + "title": "ComposedLinearMap", + "url": "/docs/api/qiskit-noise-learning/generated/math-composed-linear-map", + "untranslatable": true + }, + { + "title": "EnumeratedIndexedSpace", + "url": "/docs/api/qiskit-noise-learning/generated/math-enumerated-indexed-space", + "untranslatable": true + }, + { + "title": "IndexedMatrix", + "url": "/docs/api/qiskit-noise-learning/generated/math-indexed-matrix", + "untranslatable": true + }, + { + "title": "IndexedSpace", + "url": "/docs/api/qiskit-noise-learning/generated/math-indexed-space", + "untranslatable": true + }, + { + "title": "IndexedVector", + "url": "/docs/api/qiskit-noise-learning/generated/math-indexed-vector", + "untranslatable": true + }, + { + "title": "LinearMap", + "url": "/docs/api/qiskit-noise-learning/generated/math-linear-map", + "untranslatable": true + } + ] + }, + { + "title": "qiskit_noise_learning.models", + "untranslatable": true, + "children": [ + { + "title": "Module overview", + "url": "/docs/api/qiskit-noise-learning/models" + }, + { + "title": "contains_pauli_lindblad_model", + "url": "/docs/api/qiskit-noise-learning/generated/models-contains-pauli-lindblad-model", + "untranslatable": true + }, + { + "title": "GeneratorIndex", + "url": "/docs/api/qiskit-noise-learning/generated/models-generator-index", + "untranslatable": true + }, + { + "title": "get_noise_site", + "url": "/docs/api/qiskit-noise-learning/generated/models-get-noise-site", + "untranslatable": true + }, + { + "title": "IdentityFidelityModel", + "url": "/docs/api/qiskit-noise-learning/generated/models-identity-fidelity-model", + "untranslatable": true + }, + { + "title": "is_fidelity_model", + "url": "/docs/api/qiskit-noise-learning/generated/models-is-fidelity-model", + "untranslatable": true + }, + { + "title": "LogFidelitySpace", + "url": "/docs/api/qiskit-noise-learning/generated/models-log-fidelity-space", + "untranslatable": true + }, + { + "title": "PauliLindbladModel", + "url": "/docs/api/qiskit-noise-learning/generated/models-pauli-lindblad-model", + "untranslatable": true + }, + { + "title": "PauliLindbladSplit", + "url": "/docs/api/qiskit-noise-learning/generated/models-pauli-lindblad-split", + "untranslatable": true + }, + { + "title": "RateSpace", + "url": "/docs/api/qiskit-noise-learning/generated/models-rate-space", + "untranslatable": true + }, + { + "title": "split_pauli_lindblad_model", + "url": "/docs/api/qiskit-noise-learning/generated/models-split-pauli-lindblad-model", + "untranslatable": true + } + ] + }, + { + "title": "qiskit_noise_learning.noise_learner", + "untranslatable": true, + "children": [ + { + "title": "Module overview", + "url": "/docs/api/qiskit-noise-learning/noise-learner" + }, + { + "title": "LearningOptions", + "url": "/docs/api/qiskit-noise-learning/generated/noise-learner-learning-options", + "untranslatable": true + }, + { + "title": "NoiseLearner", + "url": "/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner", + "untranslatable": true + }, + { + "title": "NoiseLearnerJob", + "url": "/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner-job", + "untranslatable": true + }, + { + "title": "NoiseLearnerResult", + "url": "/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner-result", + "untranslatable": true + }, + { + "title": "ProgramExecutor", + "url": "/docs/api/qiskit-noise-learning/generated/noise-learner-program-executor", + "untranslatable": true + }, + { + "title": "ProgramJob", + "url": "/docs/api/qiskit-noise-learning/generated/noise-learner-program-job", + "untranslatable": true + } + ] + }, + { + "title": "qiskit_noise_learning.sequences", + "untranslatable": true, + "children": [ + { + "title": "Module overview", + "url": "/docs/api/qiskit-noise-learning/sequences" + }, + { + "title": "ApplyGate", + "url": "/docs/api/qiskit-noise-learning/generated/sequences-apply-gate", + "untranslatable": true + }, + { + "title": "FidelityIndex", + "url": "/docs/api/qiskit-noise-learning/generated/sequences-fidelity-index", + "untranslatable": true + }, + { + "title": "group_mergeable_instruction_sequences", + "url": "/docs/api/qiskit-noise-learning/generated/sequences-group-mergeable-instruction-sequences", + "untranslatable": true + }, + { + "title": "InstructionSequence", + "url": "/docs/api/qiskit-noise-learning/generated/sequences-instruction-sequence", + "untranslatable": true + }, + { + "title": "LogPathMap", + "url": "/docs/api/qiskit-noise-learning/generated/sequences-log-path-map", + "untranslatable": true + }, + { + "title": "LogPathSpace", + "url": "/docs/api/qiskit-noise-learning/generated/sequences-log-path-space", + "untranslatable": true + }, + { + "title": "PartialPauliPermutation", + "url": "/docs/api/qiskit-noise-learning/generated/sequences-partial-pauli-permutation", + "untranslatable": true + }, + { + "title": "Path", + "url": "/docs/api/qiskit-noise-learning/generated/sequences-path", + "untranslatable": true + } + ] + }, + { + "title": "qiskit_noise_learning.visualizations", + "untranslatable": true, + "children": [ + { + "title": "Module overview", + "url": "/docs/api/qiskit-noise-learning/visualizations" + }, + { + "title": "fidelity_index_math_label", + "url": "/docs/api/qiskit-noise-learning/generated/visualizations-fidelity-index-math-label", + "untranslatable": true + }, + { + "title": "gate_set_topology", + "url": "/docs/api/qiskit-noise-learning/generated/visualizations-gate-set-topology", + "untranslatable": true + }, + { + "title": "path_math_label", + "url": "/docs/api/qiskit-noise-learning/generated/visualizations-path-math-label", + "untranslatable": true + } + ] + } + ], + "collapsed": true, + "untranslatable": true +} diff --git a/docs/api/qiskit-noise-learning/aer-executor.mdx b/docs/api/qiskit-noise-learning/aer-executor.mdx new file mode 100644 index 000000000000..53df914e0c9b --- /dev/null +++ b/docs/api/qiskit-noise-learning/aer-executor.mdx @@ -0,0 +1,31 @@ +--- +title: aer_executor (latest version) +description: API reference for qiskit_noise_learning.aer_executor in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 2 +python_api_type: module +python_api_name: qiskit_noise_learning.aer_executor +--- + + + + + +# Aer executor + +`qiskit_noise_learning.aer_executor` + +Aer-based local executor for QuantumProgram objects. + +## Classes + +| | | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | +| [`AerExecutor`](generated/aer-executor-aer-executor "qiskit_noise_learning.aer_executor.AerExecutor") | Local Aer-based executor mimicking the IBM Runtime executor interface. | +| [`AerRuntimeJob`](generated/aer-executor-aer-runtime-job "qiskit_noise_learning.aer_executor.AerRuntimeJob") | Job object returned by [`AerExecutor.run()`](generated/aer-executor-aer-executor#run "qiskit_noise_learning.aer_executor.AerExecutor.run"). | + +## Functions + +| | | +| ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- | +| [`inline_samplexes`](generated/aer-executor-inline-samplexes "qiskit_noise_learning.aer_executor.inline_samplexes")(program\[, omit, rng]) | Return a new `QuantumProgram` with `SamplexItem`s resolved in-place. | + diff --git a/docs/api/qiskit-noise-learning/analysis.mdx b/docs/api/qiskit-noise-learning/analysis.mdx new file mode 100644 index 000000000000..48b5a6425b34 --- /dev/null +++ b/docs/api/qiskit-noise-learning/analysis.mdx @@ -0,0 +1,38 @@ +--- +title: analysis (latest version) +description: API reference for qiskit_noise_learning.analysis in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 2 +python_api_type: module +python_api_name: qiskit_noise_learning.analysis +--- + + + + + +# Analysis + +`qiskit_noise_learning.analysis` + +Data analysis. + +## Classes + +| | | +| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| [`AnalysisPipeline`](generated/analysis-analysis-pipeline "qiskit_noise_learning.analysis.AnalysisPipeline") | A composite [`AnalysisStage`](generated/analysis-analysis-stage "qiskit_noise_learning.analysis.AnalysisStage") that chains stages sequentially. | +| [`AnalysisStage`](generated/analysis-analysis-stage "qiskit_noise_learning.analysis.AnalysisStage") | Abstract base for a stage in the analysis pipeline. | +| [`AverageObservables`](generated/analysis-average-observables "qiskit_noise_learning.analysis.AverageObservables") | Average observables over randomizations for each unbound path and fragment depth pair. | +| [`ComputeObservables`](generated/analysis-compute-observables "qiskit_noise_learning.analysis.ComputeObservables") | Compute observable data from raw data. | +| [`CurveFitObservables`](generated/analysis-curve-fit-observables "qiskit_noise_learning.analysis.CurveFitObservables") | Fit observable data to exponential decays of the form `a * f**fragment_depth`, and average any remaining observables over randomizations. | +| [`Fit`](generated/analysis-fit "qiskit_noise_learning.analysis.Fit") | Container for data at each level of the analysis hierarchy. | +| [`FlipPostSelect`](generated/analysis-flip-post-select "qiskit_noise_learning.analysis.FlipPostSelect") | Apply a mask to raw data based on bit flips across measurement outcomes. | +| [`LegacySolve`](generated/analysis-legacy-solve "qiskit_noise_learning.analysis.LegacySolve") | Solves for the [`ModelData`](generated/data-model-data "qiskit_noise_learning.data.ModelData") using the legacy pair-fidelity method. | +| [`LinearSystemData`](generated/analysis-linear-system-data "qiskit_noise_learning.analysis.LinearSystemData") | The linear system to solve and metadata in raw format. | +| [`LSQLinearSolve`](generated/analysis-lsq-linear-solve "qiskit_noise_learning.analysis.LSQLinearSolve") | Solves for the [`ModelData`](generated/data-model-data "qiskit_noise_learning.data.ModelData") using SciPy's linear least squares solver. | +| [`NNLSSolve`](generated/analysis-nnls-solve "qiskit_noise_learning.analysis.NNLSSolve") | Solves for the [`ModelData`](generated/data-model-data "qiskit_noise_learning.data.ModelData") using SciPy's non-negative least squares solver. | +| [`PositivityMinSolve`](generated/analysis-positivity-min-solve "qiskit_noise_learning.analysis.PositivityMinSolve") | Solves for the [`ModelData`](generated/data-model-data "qiskit_noise_learning.data.ModelData") while minimizing Pauli-Lindblad rate positivity. | +| [`SymmetrizeFidelities`](generated/analysis-symmetrize-fidelities "qiskit_noise_learning.analysis.SymmetrizeFidelities") | Project generator rates into the fidelity-symmetry null space, gate by gate. | +| [`SymmetrizeGenerators`](generated/analysis-symmetrize-generators "qiskit_noise_learning.analysis.SymmetrizeGenerators") | Project generator rates to satisfy conjugation symmetry, gate by gate. | +| [`ZeroPostSelect`](generated/analysis-zero-post-select "qiskit_noise_learning.analysis.ZeroPostSelect") | Apply a mask to raw data based on whether bit values are all False. | + diff --git a/docs/api/qiskit-noise-learning/circuit-generator.mdx b/docs/api/qiskit-noise-learning/circuit-generator.mdx new file mode 100644 index 000000000000..46184694a498 --- /dev/null +++ b/docs/api/qiskit-noise-learning/circuit-generator.mdx @@ -0,0 +1,25 @@ +--- +title: circuit_generator (latest version) +description: API reference for qiskit_noise_learning.circuit_generator in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 2 +python_api_type: module +python_api_name: qiskit_noise_learning.circuit_generator +--- + + + + + +# Circuit generator + +`qiskit_noise_learning.circuit_generator` + +Executor circuit generator. + +## Classes + +| | | +| ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| [`ExecutorCircuitGenerator`](generated/circuit-generator-executor-circuit-generator "qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator") | A circuit generator that converts sequences of Qiskit gates into a samplex items. | +| [`ExecutorDataMapper`](generated/circuit-generator-executor-data-mapper "qiskit_noise_learning.circuit_generator.ExecutorDataMapper") | Map executor results into standard results. | + diff --git a/docs/api/qiskit-noise-learning/data.mdx b/docs/api/qiskit-noise-learning/data.mdx new file mode 100644 index 000000000000..a9e9789f0d2c --- /dev/null +++ b/docs/api/qiskit-noise-learning/data.mdx @@ -0,0 +1,28 @@ +--- +title: data (latest version) +description: API reference for qiskit_noise_learning.data in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 2 +python_api_type: module +python_api_name: qiskit_noise_learning.data +--- + + + + + +# Data + +`qiskit_noise_learning.data` + +Data containers. + +## Classes + +| | | +| ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | +| [`AggregatedObservableData`](generated/data-aggregated-observable-data "qiskit_noise_learning.data.AggregatedObservableData") | Per-path estimates obtained by aggregating [`ObservableData`](generated/data-observable-data "qiskit_noise_learning.data.ObservableData"). | +| [`LeveledData`](generated/data-leveled-data "qiskit_noise_learning.data.LeveledData") | Marker base class for data at a specific level of the analysis hierarchy. | +| [`ModelData`](generated/data-model-data "qiskit_noise_learning.data.ModelData") | Results from fitting, backed by an xarray Dataset. | +| [`ObservableData`](generated/data-observable-data "qiskit_noise_learning.data.ObservableData") | A collection of calculated expectation values. | +| [`RawData`](generated/data-raw-data "qiskit_noise_learning.data.RawData") | Raw experimental outcome data associated with instruction sequences and classical registers. | + diff --git a/docs/api/qiskit-noise-learning/experiment-builder.mdx b/docs/api/qiskit-noise-learning/experiment-builder.mdx new file mode 100644 index 000000000000..d5a91788627f --- /dev/null +++ b/docs/api/qiskit-noise-learning/experiment-builder.mdx @@ -0,0 +1,39 @@ +--- +title: experiment_builder (latest version) +description: API reference for qiskit_noise_learning.experiment_builder in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 2 +python_api_type: module +python_api_name: qiskit_noise_learning.experiment_builder +--- + + + + + +# Experiment builder + +`qiskit_noise_learning.experiment_builder` + +Experiment builder. + +## Classes + +| | | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [`Experiment`](generated/experiment-builder-experiment "qiskit_noise_learning.experiment_builder.Experiment") | A learning experiment specification. | +| [`ExperimentBuilder`](generated/experiment-builder-experiment-builder "qiskit_noise_learning.experiment_builder.ExperimentBuilder") | A composite [`ExperimentBuilderStage`](generated/experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.ExperimentBuilderStage") that chains stages sequentially. | +| [`ExperimentBuilderStage`](generated/experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.ExperimentBuilderStage") | Abstract base for a stage in the experiment-building pipeline. | +| [`AddInstructionSequences`](generated/experiment-builder-add-instruction-sequences "qiskit_noise_learning.experiment_builder.AddInstructionSequences") | Add instruction sequences to an experiment. | +| [`AddPaths`](generated/experiment-builder-add-paths "qiskit_noise_learning.experiment_builder.AddPaths") | Add paths to an experiment. | +| [`BindFragmentDepths`](generated/experiment-builder-bind-fragment-depths "qiskit_noise_learning.experiment_builder.BindFragmentDepths") | Expand unbound instruction sequences at the given fragment depths. | +| [`CompleteSequences`](generated/experiment-builder-complete-sequences "qiskit_noise_learning.experiment_builder.CompleteSequences") | Complete all instruction sequences. | +| [`Depth1Paths`](generated/experiment-builder-depth-1-paths "qiskit_noise_learning.experiment_builder.Depth1Paths") | Generate depth-1 paths for each target gate. | +| [`EvenDepthPaths`](generated/experiment-builder-even-depth-paths "qiskit_noise_learning.experiment_builder.EvenDepthPaths") | Generate unbound paths with repetitions of two applications of each target gate. | +| [`EvenDepthVanillaPaths`](generated/experiment-builder-even-depth-vanilla-paths "qiskit_noise_learning.experiment_builder.EvenDepthVanillaPaths") | Generate unbound vanilla paths with repetitions of two gate applications. | +| [`GenerateInstructionSequences`](generated/experiment-builder-generate-instruction-sequences "qiskit_noise_learning.experiment_builder.GenerateInstructionSequences") | Generate one instruction sequence per path via [`to_instruction_sequence()`](generated/sequences-path#to_instruction_sequence "qiskit_noise_learning.sequences.Path.to_instruction_sequence"). | +| [`IdentifyRelations`](generated/experiment-builder-identify-relations "qiskit_noise_learning.experiment_builder.IdentifyRelations") | Identify new relations amongst existing paths and instruction sequences. | +| [`MergeInstructionSequences`](generated/experiment-builder-merge-instruction-sequences "qiskit_noise_learning.experiment_builder.MergeInstructionSequences") | Merge instruction sequences into a smaller set. | +| [`RankReducePaths`](generated/experiment-builder-rank-reduce-paths "qiskit_noise_learning.experiment_builder.RankReducePaths") | Reduce the paths to a maximal linearly independent set. | +| [`SPAMPaths`](generated/experiment-builder-spam-paths "qiskit_noise_learning.experiment_builder.SPAMPaths") | Generate depth-0 paths. | +| [`VanillaInstructionSequences`](generated/experiment-builder-vanilla-instruction-sequences "qiskit_noise_learning.experiment_builder.VanillaInstructionSequences") | Generate vanilla instruction sequences for each target gate. | + diff --git a/docs/api/qiskit-noise-learning/gate-sets.mdx b/docs/api/qiskit-noise-learning/gate-sets.mdx new file mode 100644 index 000000000000..346e36ab1ef1 --- /dev/null +++ b/docs/api/qiskit-noise-learning/gate-sets.mdx @@ -0,0 +1,29 @@ +--- +title: gate_sets (latest version) +description: API reference for qiskit_noise_learning.gate_sets in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 2 +python_api_type: module +python_api_name: qiskit_noise_learning.gate_sets +--- + + + + + +# Gate sets + +`qiskit_noise_learning.gate_sets` + +Gate sets. + +## Classes + +| | | +| ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`Gate`](generated/gate-sets-gate "qiskit_noise_learning.gate_sets.Gate") | Represents qubit metadata for a single gate in a gate set. | +| [`GateSet`](generated/gate-sets-gate-set "qiskit_noise_learning.gate_sets.GateSet") | A mapping of names to gates with qubit metadata. | +| [`ModelGate`](generated/gate-sets-model-gate "qiskit_noise_learning.gate_sets.ModelGate") | A model for a gate of the form Clifford - MCM - reset. | +| [`ModelGateSet`](generated/gate-sets-model-gate-set "qiskit_noise_learning.gate_sets.ModelGateSet") | A set of Clifford - MCM - reset gates represented as [`ModelGate`](generated/gate-sets-model-gate "qiskit_noise_learning.gate_sets.ModelGate") instances. | +| [`QiskitGate`](generated/gate-sets-qiskit-gate "qiskit_noise_learning.gate_sets.QiskitGate") | Represents a single gate in a [`QiskitGateSet`](generated/gate-sets-qiskit-gate-set "qiskit_noise_learning.gate_sets.QiskitGateSet"). | +| [`QiskitGateSet`](generated/gate-sets-qiskit-gate-set "qiskit_noise_learning.gate_sets.QiskitGateSet") | A gate set whose noise is to be learned and that is specified using Qiskit objects. | + diff --git a/docs/api/qiskit-noise-learning/generated/aer-executor-aer-executor.mdx b/docs/api/qiskit-noise-learning/generated/aer-executor-aer-executor.mdx new file mode 100644 index 000000000000..3d313b6200d1 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/aer-executor-aer-executor.mdx @@ -0,0 +1,81 @@ +--- +title: AerExecutor (latest version) +description: API reference for qiskit_noise_learning.aer_executor.AerExecutor in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.aer_executor.AerExecutor +--- + + + +# qiskit\_noise\_learning.aer\_executor.AerExecutor + + + Bases: [`object`](https://docs.python.org/3/library/functions.html#object) + + Local Aer-based executor mimicking the IBM Runtime executor interface. + + Runs a `QuantumProgram` eagerly on construction of the returned job — the result is available immediately when [`AerRuntimeJob.result()`](aer-executor-aer-runtime-job#result "qiskit_noise_learning.aer_executor.AerRuntimeJob.result") is called. + + **Noise injection** + + When `noise_dict` is provided, Pauli-Lindblad noise is injected into circuits at tagged barriers via `InsertNoisePass`. Samplomatic inserts three barriers around each boxed gate — left (`L`), middle (`M`), and right (`R`) — with labels of the form `@tag=` (e.g. `R0@tag=r0`). By default, noise is injected at the `R` (right) barriers, i.e. *after* the gate. Use `noise_after=False` on `InsertNoisePass` to target `M` barriers instead (noise *before* the gate). + + The `noise_dict` format is: + + * **Keys** — layer name tags (strings, e.g. `"r0"`, `"my_tag"`). Each key must match the `ref` of a `Tag` annotation used when building the `QuantumProgram`. A warning is emitted (if `warn_absent=True`) when a tagged barrier’s tag is absent from the dict; the barrier is left as-is (no noise inserted for that layer). + * **Values** — [`PauliLindbladMap`](/docs/api/qiskit/qiskit.quantum_info.PauliLindbladMap) instances describing the Pauli-Lindblad noise channel for that gate. The map’s `num_qubits` must equal the number of qubits on the corresponding barrier in the circuit. + * **Qubit indexing** — indices inside the map are *local* to the barrier’s qubit set, independent of global circuit qubit numbering. Local index `i` refers to the `i`-th qubit of the barrier in *ascending physical-qubit order*, so a device-wide map can be converted with [`PauliLindbladMap.keep_qubits(sorted(qubits))`](/docs/api/qiskit/qiskit.quantum_info.PauliLindbladMap#keep_qubits). + + **Parameters** + + * **qasm\_simulator** – The Aer simulator to run programs on. + * **noise\_dict** – A map from barrier label refs to Pauli-Lindblad noise maps. Pass `None` (default) to run without noise injection. + * **angle\_decimals** – Gate angles are rounded to the nearest multiple of π/2 at this decimal precision before simulation. This prevents floating-point drift from preventing Clifford-method simulation when angles are nominally Clifford. + * **warn\_absent** – If `True` (default), emit a warning when a tagged barrier’s tag is not found in `noise_dict`. Set to `False` when partial coverage of tags is intentional. + * **root\_seed** – Root seed for random number generation, covering both the sampling of shots and the sampling of twirls. Rather than being used directly, it seeds a sequence that each call to [`run()`](#qiskit_noise_learning.aer_executor.AerExecutor.run "qiskit_noise_learning.aer_executor.AerExecutor.run") draws the next seed from, so that runs are independently random. With the default of `None` a root seed is drawn nondeterministically; it is available as [`root_seed`](#qiskit_noise_learning.aer_executor.AerExecutor.root_seed "qiskit_noise_learning.aer_executor.AerExecutor.root_seed") either way. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.aer_executor.AerExecutor.__init__ "qiskit_noise_learning.aer_executor.AerExecutor.__init__")(qasm\_simulator\[, noise\_dict, ...]) | | + | [`run`](#qiskit_noise_learning.aer_executor.AerExecutor.run "qiskit_noise_learning.aer_executor.AerExecutor.run")(program) | Run a quantum program and return a completed job. | + + ## Attributes + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | + | [`root_seed`](#qiskit_noise_learning.aer_executor.AerExecutor.root_seed "qiskit_noise_learning.aer_executor.AerExecutor.root_seed") | The root seed each run's randomness is derived from. | + + ### root\_seed + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + The root seed each run’s randomness is derived from. + + Passing this to a new executor reproduces this executor’s whole sequence of runs. It is not the seed of any individual run: to reproduce a single run, use the seed of the job that produced it, [`AerRuntimeJob.seed`](aer-executor-aer-runtime-job#seed "qiskit_noise_learning.aer_executor.AerRuntimeJob.seed"). + + + ### run + + + Run a quantum program and return a completed job. + + Each call draws a fresh seed from the executor’s root seed, so successive runs are independently random even when the executor is seeded. + + **Parameters** + + **program** – The quantum program to execute. + + **Returns** + + A job whose result is immediately available. + + + diff --git a/docs/api/qiskit-noise-learning/generated/aer-executor-aer-runtime-job.mdx b/docs/api/qiskit-noise-learning/generated/aer-executor-aer-runtime-job.mdx new file mode 100644 index 000000000000..467a66c66620 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/aer-executor-aer-runtime-job.mdx @@ -0,0 +1,71 @@ +--- +title: AerRuntimeJob (latest version) +description: API reference for qiskit_noise_learning.aer_executor.AerRuntimeJob in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.aer_executor.AerRuntimeJob +--- + + + +# qiskit\_noise\_learning.aer\_executor.AerRuntimeJob + + + Bases: [`object`](https://docs.python.org/3/library/functions.html#object) + + Job object returned by [`AerExecutor.run()`](aer-executor-aer-executor#run "qiskit_noise_learning.aer_executor.AerExecutor.run"). + + The program is executed eagerly on construction; the result is available immediately when [`result()`](#qiskit_noise_learning.aer_executor.AerRuntimeJob.result "qiskit_noise_learning.aer_executor.AerRuntimeJob.result") is called. + + **Parameters** + + * **qasm\_simulator** – The Aer simulator to run on. + * **program** – The quantum program to execute. + * **noise\_dict** – A map from barrier label refs to Pauli-Lindblad noise maps. + * **angle\_decimals** – Rounding precision for gate angles (in units of π/2). + * **warn\_absent** – If `True` (default), warn when a tagged barrier has no entry in `noise_dict`. + * **seed** – Root seed for this job’s randomness. If `None`, one is drawn nondeterministically; either way the value used is available as [`seed`](#qiskit_noise_learning.aer_executor.AerRuntimeJob.seed "qiskit_noise_learning.aer_executor.AerRuntimeJob.seed"). + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.aer_executor.AerRuntimeJob.__init__ "qiskit_noise_learning.aer_executor.AerRuntimeJob.__init__")(qasm\_simulator, program\[, ...]) | | + | [`job_id`](#qiskit_noise_learning.aer_executor.AerRuntimeJob.job_id "qiskit_noise_learning.aer_executor.AerRuntimeJob.job_id")() | Return the unique job ID. | + | [`result`](#qiskit_noise_learning.aer_executor.AerRuntimeJob.result "qiskit_noise_learning.aer_executor.AerRuntimeJob.result")(\*\_, \*\*\_\_) | Return the result of the program execution. | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------- | + | [`seed`](#qiskit_noise_learning.aer_executor.AerRuntimeJob.seed "qiskit_noise_learning.aer_executor.AerRuntimeJob.seed") | The root seed this job's randomness was derived from. | + + ### job\_id + + + Return the unique job ID. + + + ### seed + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + The root seed this job’s randomness was derived from. + + Constructing another job with this seed and the same program reproduces this job’s result, including when the job itself was created without a seed. + + For a job created by [`AerExecutor.run()`](aer-executor-aer-executor#run "qiskit_noise_learning.aer_executor.AerExecutor.run") this is the seed that the executor drew for this particular run, which is not its [`AerExecutor.root_seed`](aer-executor-aer-executor#root_seed "qiskit_noise_learning.aer_executor.AerExecutor.root_seed") — the two are not interchangeable. + + + ### result + + + Return the result of the program execution. + + + diff --git a/docs/api/qiskit-noise-learning/generated/aer-executor-inline-samplexes.mdx b/docs/api/qiskit-noise-learning/generated/aer-executor-inline-samplexes.mdx new file mode 100644 index 000000000000..4480e5ffafac --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/aer-executor-inline-samplexes.mdx @@ -0,0 +1,28 @@ +--- +title: inline_samplexes (latest version) +description: API reference for qiskit_noise_learning.aer_executor.inline_samplexes in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: function +python_api_name: qiskit_noise_learning.aer_executor.inline_samplexes +--- + + + +# qiskit\_noise\_learning.aer\_executor.inline\_samplexes + + + Return a new `QuantumProgram` with `SamplexItem`s resolved in-place. + + Each `SamplexItem` whose index is not in `omit` is replaced by a `CircuitItem` via `inline_samplex_item()`. The passthrough data produced by sampling (e.g. `measurement_flips.*` arrays) is stored in the returned program’s `passthrough_data` under the key `"inlined"`, keyed by the original item index (as a string). Any existing `passthrough_data` on the input program is preserved alongside the new `"inlined"` entry. + + **Parameters** + + * **program** – The quantum program to process. + * **omit** – Indices of items to leave as `SamplexItem`s. All other `SamplexItem`s are inlined. `CircuitItem`s are always left unchanged regardless of this list. + * **rng** – Random number generator passed to `inline_samplex_item()`. If `None`, `np.random.default_rng()` is used. + + **Returns** + + A new `QuantumProgram` with the same shots, noise maps, and measurement level as the input, but with the selected `SamplexItem`s replaced by `CircuitItem`s. + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-analysis-pipeline.mdx b/docs/api/qiskit-noise-learning/generated/analysis-analysis-pipeline.mdx new file mode 100644 index 000000000000..981130c93c6b --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-analysis-pipeline.mdx @@ -0,0 +1,69 @@ +--- +title: AnalysisPipeline (latest version) +description: API reference for qiskit_noise_learning.analysis.AnalysisPipeline in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.AnalysisPipeline +--- + + + +# qiskit\_noise\_learning.analysis.AnalysisPipeline + + + Bases: [`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.analysis_pipeline.AnalysisStage") + + A composite [`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.AnalysisStage") that chains stages sequentially. + + Because [`AnalysisPipeline`](#qiskit_noise_learning.analysis.AnalysisPipeline "qiskit_noise_learning.analysis.AnalysisPipeline") is itself an [`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.AnalysisStage"), pipelines can be nested and used anywhere a single stage is expected. + + Consecutive stages must connect: the [`output_level`](analysis-analysis-stage#output_level "qiskit_noise_learning.analysis.AnalysisStage.output_level") of each stage must equal the [`input_level`](analysis-analysis-stage#input_level "qiskit_noise_learning.analysis.AnalysisStage.input_level") of the next. + + **Parameters** + + **stages** – The analysis stages to use in this pipeline in sequential order. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.AnalysisPipeline.__init__ "qiskit_noise_learning.analysis.AnalysisPipeline.__init__")(\*stages) | | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ## Attributes + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | + | [`input_level`](#qiskit_noise_learning.analysis.AnalysisPipeline.input_level "qiskit_noise_learning.analysis.AnalysisPipeline.input_level") | The data level this stage reads. | + | [`output_level`](#qiskit_noise_learning.analysis.AnalysisPipeline.output_level "qiskit_noise_learning.analysis.AnalysisPipeline.output_level") | The data level this stage writes. | + | [`stages`](#qiskit_noise_learning.analysis.AnalysisPipeline.stages "qiskit_noise_learning.analysis.AnalysisPipeline.stages") | The stages in this pipeline. | + + ### input\_level + + + Type: [`type`](https://docs.python.org/3/library/functions.html#type)\[[`LeveledData`](data-leveled-data "qiskit_noise_learning.data.leveled_data.LeveledData")] + + The data level this stage reads. + + + ### output\_level + + + Type: [`type`](https://docs.python.org/3/library/functions.html#type)\[[`LeveledData`](data-leveled-data "qiskit_noise_learning.data.leveled_data.LeveledData")] + + The data level this stage writes. + + + ### stages + + + Type: [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.analysis_pipeline.AnalysisStage"), ...] + + The stages in this pipeline. + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-analysis-stage.mdx b/docs/api/qiskit-noise-learning/generated/analysis-analysis-stage.mdx new file mode 100644 index 000000000000..4588691fa6da --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-analysis-stage.mdx @@ -0,0 +1,75 @@ +--- +title: AnalysisStage (latest version) +description: API reference for qiskit_noise_learning.analysis.AnalysisStage in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.AnalysisStage +--- + + + +# qiskit\_noise\_learning.analysis.AnalysisStage + + + Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC) + + Abstract base for a stage in the analysis pipeline. + + Each stage declares the data level it consumes ([`input_level`](#qiskit_noise_learning.analysis.AnalysisStage.input_level "qiskit_noise_learning.analysis.AnalysisStage.input_level")) and produces ([`output_level`](#qiskit_noise_learning.analysis.AnalysisStage.output_level "qiskit_noise_learning.analysis.AnalysisStage.output_level")). Stages may skip intermediate levels, e.g. going directly from `RawData` to `DecayData`. + + To implement a stage, subclass this and override `_run()`. The public [`run()`](#qiskit_noise_learning.analysis.AnalysisStage.run "qiskit_noise_learning.analysis.AnalysisStage.run") method handles shallow-copying the [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") container and marking skipped levels; `_run()` receives the copy and may mutate it in place. + + [`input_level`](#qiskit_noise_learning.analysis.AnalysisStage.input_level "qiskit_noise_learning.analysis.AnalysisStage.input_level") and [`output_level`](#qiskit_noise_learning.analysis.AnalysisStage.output_level "qiskit_noise_learning.analysis.AnalysisStage.output_level") can be declared as class attributes: + + ```python + class MyStage(AnalysisStage): + input_level = RawData + output_level = ObservableData + + def _run(self, fit): + fit[ObservableData] = compute(fit[RawData]) + ``` + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.AnalysisStage.__init__ "qiskit_noise_learning.analysis.AnalysisStage.__init__")() | | + | [`run`](#qiskit_noise_learning.analysis.AnalysisStage.run "qiskit_noise_learning.analysis.AnalysisStage.run")(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ## Attributes + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | + | [`input_level`](#qiskit_noise_learning.analysis.AnalysisStage.input_level "qiskit_noise_learning.analysis.AnalysisStage.input_level") | The data level this stage reads. | + | [`output_level`](#qiskit_noise_learning.analysis.AnalysisStage.output_level "qiskit_noise_learning.analysis.AnalysisStage.output_level") | The data level this stage writes. | + + ### input\_level + + + Type: [`type`](https://docs.python.org/3/library/functions.html#type)\[[`LeveledData`](data-leveled-data "qiskit_noise_learning.data.leveled_data.LeveledData")] + + The data level this stage reads. + + + ### output\_level + + + Type: [`type`](https://docs.python.org/3/library/functions.html#type)\[[`LeveledData`](data-leveled-data "qiskit_noise_learning.data.leveled_data.LeveledData")] + + The data level this stage writes. + + + ### run + + + Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. + + Shallow-copies `fit`, marks any `Absent` intermediate levels as `Skipped`, calls `_run()` on the copy, and returns it. The original `fit` is not modified. + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-average-observables.mdx b/docs/api/qiskit-noise-learning/generated/analysis-average-observables.mdx new file mode 100644 index 000000000000..7324e046d5d8 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-average-observables.mdx @@ -0,0 +1,48 @@ +--- +title: AverageObservables (latest version) +description: API reference for qiskit_noise_learning.analysis.AverageObservables in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.AverageObservables +--- + + + +# qiskit\_noise\_learning.analysis.AverageObservables + + + Bases: [`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.analysis_pipeline.AnalysisStage") + + Average observables over randomizations for each unbound path and fragment depth pair. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.AverageObservables.__init__ "qiskit_noise_learning.analysis.AverageObservables.__init__")() | | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ## Attributes + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | + | [`input_level`](#qiskit_noise_learning.analysis.AverageObservables.input_level "qiskit_noise_learning.analysis.AverageObservables.input_level") | The data level this stage reads. | + | [`output_level`](#qiskit_noise_learning.analysis.AverageObservables.output_level "qiskit_noise_learning.analysis.AverageObservables.output_level") | The data level this stage writes. | + + ### input\_level + + + The data level this stage reads. + + + ### output\_level + + + The data level this stage writes. + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-compute-observables.mdx b/docs/api/qiskit-noise-learning/generated/analysis-compute-observables.mdx new file mode 100644 index 000000000000..f7606d553c31 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-compute-observables.mdx @@ -0,0 +1,50 @@ +--- +title: ComputeObservables (latest version) +description: API reference for qiskit_noise_learning.analysis.ComputeObservables in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.ComputeObservables +--- + + + +# qiskit\_noise\_learning.analysis.ComputeObservables + + + Bases: [`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.analysis_pipeline.AnalysisStage") + + Compute observable data from raw data. + + This analysis stage utilizes existing relations between paths and instruction sequences in the [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") to determine how to compute observables. If relations are not specified, they are greedily constructed by exhaustively comparing paths in `fit.paths` and the instruction sequences in `fit.raw_data`. Note that in this latter case, `fit.paths` is not updated and will therefore remain `None`. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.ComputeObservables.__init__ "qiskit_noise_learning.analysis.ComputeObservables.__init__")() | | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ## Attributes + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | + | [`input_level`](#qiskit_noise_learning.analysis.ComputeObservables.input_level "qiskit_noise_learning.analysis.ComputeObservables.input_level") | The data level this stage reads. | + | [`output_level`](#qiskit_noise_learning.analysis.ComputeObservables.output_level "qiskit_noise_learning.analysis.ComputeObservables.output_level") | The data level this stage writes. | + + ### input\_level + + + The data level this stage reads. + + + ### output\_level + + + The data level this stage writes. + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-curve-fit-observables.mdx b/docs/api/qiskit-noise-learning/generated/analysis-curve-fit-observables.mdx new file mode 100644 index 000000000000..2428170174c6 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-curve-fit-observables.mdx @@ -0,0 +1,56 @@ +--- +title: CurveFitObservables (latest version) +description: API reference for qiskit_noise_learning.analysis.CurveFitObservables in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.CurveFitObservables +--- + + + +# qiskit\_noise\_learning.analysis.CurveFitObservables + + + Bases: [`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.analysis_pipeline.AnalysisStage") + + Fit observable data to exponential decays of the form `a * f**fragment_depth`, and average any remaining observables over randomizations. + + This stage will curve fit data for any unbound paths in `fit.paths`. If `fit.paths is None`, any path in the data with multiple fragment depths will be curve fit. In both cases, any remaining paths will be averaged. + + Each curve-fit row carries the following per-row metadata, which the averaged rows do not have: + + * `"spam_fidelity"`, `"spam_fidelity_std"`: the fitted prefactor $a$ and its `1`-sigma uncertainty. + * `"chi_squared"`: the raw chi-squared of the fit. + * `"reduced_chi_squared"`: the raw chi-squared divided by the degrees of freedom, that is the number of fragment depths minus the two fit parameters, or `nan` if there are none. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.CurveFitObservables.__init__ "qiskit_noise_learning.analysis.CurveFitObservables.__init__")() | | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ## Attributes + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | + | [`input_level`](#qiskit_noise_learning.analysis.CurveFitObservables.input_level "qiskit_noise_learning.analysis.CurveFitObservables.input_level") | The data level this stage reads. | + | [`output_level`](#qiskit_noise_learning.analysis.CurveFitObservables.output_level "qiskit_noise_learning.analysis.CurveFitObservables.output_level") | The data level this stage writes. | + + ### input\_level + + + The data level this stage reads. + + + ### output\_level + + + The data level this stage writes. + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-fit.mdx b/docs/api/qiskit-noise-learning/generated/analysis-fit.mdx new file mode 100644 index 000000000000..219690589ab5 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-fit.mdx @@ -0,0 +1,183 @@ +--- +title: Fit (latest version) +description: API reference for qiskit_noise_learning.analysis.Fit in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.Fit +--- + + + +# qiskit\_noise\_learning.analysis.Fit + + + Bases: [`object`](https://docs.python.org/3/library/functions.html#object) + + Container for data at each level of the analysis hierarchy. + + The `LEVELS` represent different stages of processed data. In order, they are: + + * `RawData` corresponding to bit counts of executed instruction sequences. + * `ObservableData` corresponding to observables of randomizations of paths that traverse the instruction sequences. + * `AggregatedObservableData` corresponding to a combination of observables aggregated across randomizations. + * `ModelData` corresponding to model fit parameters. + + Each level holds a history of all values written to it; the current value is always the most recent. New levels start as `Absent`. Levels bypassed by a stage are marked `Skipped`. + + Example: + + ```python + result = my_stage.run(my_raw_data) + result.raw_data # current RawData + result.history.raw_data # full write history at the RawData level + ``` + + **Parameters** + + * **model** – The model to fit. If given, it must be a fidelity model, i.e. a [`LinearMap`](math-linear-map "qiskit_noise_learning.math.LinearMap") whose output space is a [`LogFidelitySpace`](models-log-fidelity-space "qiskit_noise_learning.models.LogFidelitySpace") (see [`is_fidelity_model()`](models-is-fidelity-model "qiskit_noise_learning.models.is_fidelity_model")). + * **paths** – The paths to analyze. + * **instruction\_sequences** – The instruction sequences used in the experiment. + * **relations** – A pre-computed set of `(path_idx, sequence_idx)` tuples indicating which paths are traversed by which instruction sequences. + + **Raises** + + [**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError) – If `model` is not `None` and is not a fidelity model. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.Fit.__init__ "qiskit_noise_learning.analysis.Fit.__init__")(\*\[, model, paths, ...]) | | + | [`copy`](#qiskit_noise_learning.analysis.Fit.copy "qiskit_noise_learning.analysis.Fit.copy")() | Return a copy preserving the full history at each level. | + | [`plot_qubit_pair_decays`](#qiskit_noise_learning.analysis.Fit.plot_qubit_pair_decays "qiskit_noise_learning.analysis.Fit.plot_qubit_pair_decays")(pairs, \*\[, ...]) | Plot a grid of fidelity decays over qubit pairs, drawn from this fit's data. | + + ## Attributes + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | + | [`aggregated_observable_data`](#qiskit_noise_learning.analysis.Fit.aggregated_observable_data "qiskit_noise_learning.analysis.Fit.aggregated_observable_data") | Current data at the `AggregatedObservableData` level. | + | [`history`](#qiskit_noise_learning.analysis.Fit.history "qiskit_noise_learning.analysis.Fit.history") | The full write history for each level. | + | [`instruction_sequences`](#qiskit_noise_learning.analysis.Fit.instruction_sequences "qiskit_noise_learning.analysis.Fit.instruction_sequences") | The instruction sequences used in the experiment, or `None` if not set. | + | [`model`](#qiskit_noise_learning.analysis.Fit.model "qiskit_noise_learning.analysis.Fit.model") | The fidelity model used for design matrix construction. | + | [`model_data`](#qiskit_noise_learning.analysis.Fit.model_data "qiskit_noise_learning.analysis.Fit.model_data") | Current data at the `ModelData` level. | + | [`observable_data`](#qiskit_noise_learning.analysis.Fit.observable_data "qiskit_noise_learning.analysis.Fit.observable_data") | Current data at the `ObservableData` level. | + | [`paths`](#qiskit_noise_learning.analysis.Fit.paths "qiskit_noise_learning.analysis.Fit.paths") | The paths to compute observables for. | + | [`raw_data`](#qiskit_noise_learning.analysis.Fit.raw_data "qiskit_noise_learning.analysis.Fit.raw_data") | Current data at the `RawData` level. | + | [`relations`](#qiskit_noise_learning.analysis.Fit.relations "qiskit_noise_learning.analysis.Fit.relations") | Path-to-sequence relations, or `None` if not set. | + + ### copy + + + Return a copy preserving the full history at each level. + + + ### history + + + Type: `FitHistory` + + The full write history for each level. + + + ### model + + + Type: [`LinearMap`](math-linear-map "qiskit_noise_learning.math.linear_map.LinearMap")\[[`Hashable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable), [`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.fidelity_index.FidelityIndex")] | [`None`](https://docs.python.org/3/library/constants.html#None) + + The fidelity model used for design matrix construction. + + + ### raw\_data + + + Type: [`RawData`](data-raw-data "qiskit_noise_learning.data.raw_data.RawData") | `AbsentType` | `SkippedType` + + Current data at the `RawData` level. + + + ### observable\_data + + + Type: [`ObservableData`](data-observable-data "qiskit_noise_learning.data.observable_data.ObservableData") | `AbsentType` | `SkippedType` + + Current data at the `ObservableData` level. + + + ### aggregated\_observable\_data + + + Type: [`AggregatedObservableData`](data-aggregated-observable-data "qiskit_noise_learning.data.aggregated_observable_data.AggregatedObservableData") | `AbsentType` | `SkippedType` + + Current data at the `AggregatedObservableData` level. + + + ### model\_data + + + Type: [`ModelData`](data-model-data "qiskit_noise_learning.data.model_data.ModelData") | `AbsentType` | `SkippedType` + + Current data at the `ModelData` level. + + + ### paths + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`Path`](sequences-path "qiskit_noise_learning.sequences.path.Path")] + + The paths to compute observables for. + + + ### instruction\_sequences + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`InstructionSequence`](sequences-instruction-sequence "qiskit_noise_learning.sequences.instruction_sequence.InstructionSequence")] | [`None`](https://docs.python.org/3/library/constants.html#None) + + The instruction sequences used in the experiment, or `None` if not set. + + + ### relations + + + Type: [`set`](https://docs.python.org/3/library/stdtypes.html#set)\[[`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`int`](https://docs.python.org/3/library/functions.html#int), [`int`](https://docs.python.org/3/library/functions.html#int)]] | [`None`](https://docs.python.org/3/library/constants.html#None) + + Path-to-sequence relations, or `None` if not set. + + + ### plot\_qubit\_pair\_decays + + + Plot a grid of fidelity decays over qubit pairs, drawn from this fit’s data. + + One subplot per pair, sharing labels/colors across pairs. Which decays are drawn is controlled by the toggles below; all default to off, so enable the ones you want. A requested decay whose data has not been computed on this fit yet is skipped with a warning. + + **Parameters** + + * **pairs** – The qubit pairs to plot, one subplot each. A pair is unordered – `(1, 0)` names the same subplot as `(0, 1)` – so no pair may be repeated. + * **observable\_type** – How to draw the empirical observable data: `"raw"` (raw per-randomization scatter), `"means"` (per-fragment-depth means with error bars), `"both"`, or `None` (the default) to omit the empirical points. Uses this fit’s [`ObservableData`](data-observable-data "qiskit_noise_learning.data.ObservableData"). + * **exponential\_fit** – Whether to draw the fitted exponential decay curve, from this fit’s [`AggregatedObservableData`](data-aggregated-observable-data "qiskit_noise_learning.data.AggregatedObservableData") (its `fragment_depth == -1` fitted parameters). Defaults to `False`. + * **model\_prediction** – Whether to draw the model-predicted decay curve, from this fit’s model and [`ModelData`](data-model-data "qiskit_noise_learning.data.ModelData"). Defaults to `False`. + * **observable\_marker\_kwargs** – Optional `marker` overrides for the raw observable points. + * **means\_marker\_kwargs** – Optional `marker` overrides for the observable-means points. + * **exponential\_fit\_line\_kwargs** – Optional `line` overrides for the exponential-fit curve. + * **model\_line\_kwargs** – Optional `line` overrides for the model curve. + * **num\_cols** – The number of subplot columns; rows are derived from the pair count. + * **noise\_site** – An optional noise-site mapping forwarded to the label formatter (with the default `"formula"` label style this yields the compact `f^{gate}_{pauli}` label). Defaults to the noise site of the fit’s model when it is, or contains, a single [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"). + * **paths** – The paths to draw across all layers. Defaults to the decay paths found in this fit’s observable/aggregated observable data, falling back to the fit’s own `paths` when no such data is present. Supply this to draw model-prediction curves for a fit that carries only a model (no observable or aggregated observable data to derive the paths from). + * **fragment\_depths** – The fragment-depth range for the curves. Defaults to `0` through the largest fragment depth in the empirical data present, or `0`–`10` when there is none. + * **title** – An optional figure title. + + **Returns** + + The figure with interactive legends. + + **Raises** + + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the fit has no model (and hence no gate set) to build labels from, or if `pairs` names the same pair twice. + * [**ImportError**](https://docs.python.org/3/library/exceptions.html#ImportError) – If `matplotlib` is not installed. + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-flip-post-select.mdx b/docs/api/qiskit-noise-learning/generated/analysis-flip-post-select.mdx new file mode 100644 index 000000000000..5c819a1c37a0 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-flip-post-select.mdx @@ -0,0 +1,60 @@ +--- +title: FlipPostSelect (latest version) +description: API reference for qiskit_noise_learning.analysis.FlipPostSelect in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.FlipPostSelect +--- + + + +# qiskit\_noise\_learning.analysis.FlipPostSelect + + + Bases: [`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.analysis_pipeline.AnalysisStage") + + Apply a mask to raw data based on bit flips across measurement outcomes. + + This post selection stage is based on identifying successful bit flips on the same qubit(s) between two measurements. It can be configured to operate in one of two modes: + + * `"node"`: Shots are discarded if at least one bit failed to flip. + * `"edge"`: Shots are discarded if there exists a pair of neighbouring qubits in the measurement for which both bits failed to flip. + + **Parameters** + + * **creg\_pair\_identifier** – A callable that, given a list of present creg names, returns an iterator over pairs of creg names for which to do the flip-based post selection on. Defaults to returning pairs of cregs with names of the form `"*"` and `"*_ps"`. + * **mode** – Post-selection mode; either `"node"` or `"edge"`. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.FlipPostSelect.__init__ "qiskit_noise_learning.analysis.FlipPostSelect.__init__")(\[creg\_pair\_identifier, mode]) | | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------- | + | `creg_pair_identifier` | | + | [`input_level`](#qiskit_noise_learning.analysis.FlipPostSelect.input_level "qiskit_noise_learning.analysis.FlipPostSelect.input_level") | The data level this stage reads. | + | `mode` | | + | [`output_level`](#qiskit_noise_learning.analysis.FlipPostSelect.output_level "qiskit_noise_learning.analysis.FlipPostSelect.output_level") | The data level this stage writes. | + + ### input\_level + + + The data level this stage reads. + + + ### output\_level + + + The data level this stage writes. + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-legacy-solve.mdx b/docs/api/qiskit-noise-learning/generated/analysis-legacy-solve.mdx new file mode 100644 index 000000000000..df363ad611d6 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-legacy-solve.mdx @@ -0,0 +1,45 @@ +--- +title: LegacySolve (latest version) +description: API reference for qiskit_noise_learning.analysis.LegacySolve in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.LegacySolve +--- + + + +# qiskit\_noise\_learning.analysis.LegacySolve + + + Bases: [`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.analysis_pipeline.AnalysisStage") + + Solves for the [`ModelData`](data-model-data "qiskit_noise_learning.data.ModelData") using the legacy pair-fidelity method. + + This solver assumes that the gate set only has a single unitary gate, and that the paths are of a vanilla-learning type (i.e. even depth with no single-qubit Cliffords required). + + Delegates to `fit_noise_model_legacy()` with `noise_assumption="symmetric_fidelities"`, `optimizer_name="nnls"`, and `constrained=True`. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.LegacySolve.__init__ "qiskit_noise_learning.analysis.LegacySolve.__init__")() | | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ### input\_level + + + alias of [`AggregatedObservableData`](data-aggregated-observable-data "qiskit_noise_learning.data.aggregated_observable_data.AggregatedObservableData") + + + ### output\_level + + + alias of [`ModelData`](data-model-data "qiskit_noise_learning.data.model_data.ModelData") + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-linear-system-data.mdx b/docs/api/qiskit-noise-learning/generated/analysis-linear-system-data.mdx new file mode 100644 index 000000000000..3da6c278676c --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-linear-system-data.mdx @@ -0,0 +1,89 @@ +--- +title: LinearSystemData (latest version) +description: API reference for qiskit_noise_learning.analysis.LinearSystemData in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.LinearSystemData +--- + + + +# qiskit\_noise\_learning.analysis.LinearSystemData + + + Bases: [`Generic`](https://docs.python.org/3/library/typing.html#typing.Generic)\[`RowIndex`, `ColumnIndex`] + + The linear system to solve and metadata in raw format. + + A linear system `A @ x = b` with axis labels and metadata. + + The row and column labels are of arbitrary hashable types: this class carries no assumptions about what a row or column denotes. In the systems built by [`from_fit()`](#qiskit_noise_learning.analysis.LinearSystemData.from_fit "qiskit_noise_learning.analysis.LinearSystemData.from_fit") the rows are [`Path`](sequences-path "qiskit_noise_learning.sequences.Path") objects and the columns are the fidelity model’s parameter labels. + + The index maps are the authoritative record of how labels correspond to positions in `A`. Anything that needs to align a label-keyed quantity with the arrays should index through `row_index_map` or `column_index_map` rather than rebuilding the correspondence from [`row_labels`](#qiskit_noise_learning.analysis.LinearSystemData.row_labels "qiskit_noise_learning.analysis.LinearSystemData.row_labels") or [`column_labels`](#qiskit_noise_learning.analysis.LinearSystemData.column_labels "qiskit_noise_learning.analysis.LinearSystemData.column_labels"). + + **Parameters** + + * **A** – The matrix with shape `(m, n)`. + * **b** – The target vector length `m`. + * **sigma\_b** – Statistical `1`-sigma uncertainty on `b` per row, with length `m`. + * **row\_diagnostics** – Named per-row quantities recorded by the stages that produced `b`, each an array of length `m` holding `nan` for rows the quantity is undefined for. Keys are the metadata names used upstream; see [`from_fit()`](#qiskit_noise_learning.analysis.LinearSystemData.from_fit "qiskit_noise_learning.analysis.LinearSystemData.from_fit"). + * **row\_index\_map** – A mapping from row labels to their integer row position in `A`. + * **column\_index\_map** – A mapping from column labels to their integer column position in `A`. + * **time\_lb** – Earliest time bound across the rows. + * **time\_ub** – Latest time bound across the rows. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.LinearSystemData.__init__ "qiskit_noise_learning.analysis.LinearSystemData.__init__")(A, b, sigma\_b, row\_diagnostics, ...) | | + | [`from_fit`](#qiskit_noise_learning.analysis.LinearSystemData.from_fit "qiskit_noise_learning.analysis.LinearSystemData.from_fit")(fit) | Build the linear system arrays from a [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit"). | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | + | [`column_labels`](#qiskit_noise_learning.analysis.LinearSystemData.column_labels "qiskit_noise_learning.analysis.LinearSystemData.column_labels") | Column labels, ordered by their column position in `A`. | + | [`row_labels`](#qiskit_noise_learning.analysis.LinearSystemData.row_labels "qiskit_noise_learning.analysis.LinearSystemData.row_labels") | Row labels, ordered by their row position in `A`. | + | `A` | | + | `b` | | + | `sigma_b` | | + | `row_diagnostics` | | + | `row_index_map` | | + | `column_index_map` | | + | `time_lb` | | + | `time_ub` | | + + ### row\_labels + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[`RowIndex`] + + Row labels, ordered by their row position in `A`. + + + ### column\_labels + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[`ColumnIndex`] + + Column labels, ordered by their column position in `A`. + + + ### from\_fit + + + Build the linear system arrays from a [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit"). + + Rows are the [`Path`](sequences-path "qiskit_noise_learning.sequences.Path") objects of the [`AggregatedObservableData`](data-aggregated-observable-data "qiskit_noise_learning.data.AggregatedObservableData"), columns are the fidelity model’s parameter labels, and `row_diagnostics` holds every real-valued per-observable metadata entry under the name the producing stage used — for instance `"reduced_chi_squared"` from [`CurveFitObservables`](analysis-curve-fit-observables "qiskit_noise_learning.analysis.CurveFitObservables"). + + **Warns** + + **UserWarning** – If any row’s uncertainty is non-positive or non-finite, giving those rows’ positions in [`row_labels`](#qiskit_noise_learning.analysis.LinearSystemData.row_labels "qiskit_noise_learning.analysis.LinearSystemData.row_labels"). Such a row carries no usable statistical weight, and how it is treated is up to the solver. + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-lsq-linear-solve.mdx b/docs/api/qiskit-noise-learning/generated/analysis-lsq-linear-solve.mdx new file mode 100644 index 000000000000..59b58f792d54 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-lsq-linear-solve.mdx @@ -0,0 +1,42 @@ +--- +title: LSQLinearSolve (latest version) +description: API reference for qiskit_noise_learning.analysis.LSQLinearSolve in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.LSQLinearSolve +--- + + + +# qiskit\_noise\_learning.analysis.LSQLinearSolve + + + Bases: `ModelSolve` + + Solves for the [`ModelData`](data-model-data "qiskit_noise_learning.data.ModelData") using SciPy’s linear least squares solver. + + See SciPy’s [documentation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.lsq_linear.html) for details on the method. See `ModelSolve` for more details about the general responsibility of a model solver in this library. + + **Parameters** + + **\*\*lsq\_linear\_opts** – The options passed on to the SciPy solver. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.LSQLinearSolve.__init__ "qiskit_noise_learning.analysis.LSQLinearSolve.__init__")(\*\*lsq\_linear\_opts) | | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ## Attributes + + | | | + | -------------- | --------------------------------- | + | `input_level` | The data level this stage reads. | + | `output_level` | The data level this stage writes. | + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-nnls-solve.mdx b/docs/api/qiskit-noise-learning/generated/analysis-nnls-solve.mdx new file mode 100644 index 000000000000..d9b0a04294eb --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-nnls-solve.mdx @@ -0,0 +1,42 @@ +--- +title: NNLSSolve (latest version) +description: API reference for qiskit_noise_learning.analysis.NNLSSolve in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.NNLSSolve +--- + + + +# qiskit\_noise\_learning.analysis.NNLSSolve + + + Bases: `ModelSolve` + + Solves for the [`ModelData`](data-model-data "qiskit_noise_learning.data.ModelData") using SciPy’s non-negative least squares solver. + + See SciPy’s [documentation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.nnls.html) for details on the method. See `ModelSolve` for more details about the general responsibility of a model solver in this library. + + **Parameters** + + **\*\*nnls\_opts** – The options passed on to the SciPy solver. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.NNLSSolve.__init__ "qiskit_noise_learning.analysis.NNLSSolve.__init__")(\*\*nnls\_opts) | | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ## Attributes + + | | | + | -------------- | --------------------------------- | + | `input_level` | The data level this stage reads. | + | `output_level` | The data level this stage writes. | + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-positivity-min-solve.mdx b/docs/api/qiskit-noise-learning/generated/analysis-positivity-min-solve.mdx new file mode 100644 index 000000000000..d5a2940d24d6 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-positivity-min-solve.mdx @@ -0,0 +1,111 @@ +--- +title: PositivityMinSolve (latest version) +description: API reference for qiskit_noise_learning.analysis.PositivityMinSolve in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.PositivityMinSolve +--- + + + +# qiskit\_noise\_learning.analysis.PositivityMinSolve + + + Bases: `ModelSolve` + + Solves for the [`ModelData`](data-model-data "qiskit_noise_learning.data.ModelData") while minimizing Pauli-Lindblad rate positivity. + + Requires that the [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") uses a [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"). + + For a gate set $\mathcal{G}$, let $\{r_{G, P}\}$ denote the Pauli-Lindblad rates over gate-dependent generator sets $\mathcal{K}(G)$, $A$ the design matrix and $b$ the observed data. For the user-specified algorithm parameters: + + * Gate coefficients $\{c_G \in \mathbb{R} : G \in \mathcal{G}\}$, + * Global fit bound $\epsilon > 0$, and + * Local fit bounds $\delta_P$ for each path $P$ measured in the design matrix, + + this class solves the convex optimization problem: + +$$ +\min \sum_{G \in \mathcal{G}} c_G \sum_{P \in \mathcal{K}(G)} \max(0, r_{P, G}) +$$ + + subject to: + + * $\|W (A r - b)\|_2 \leq \epsilon$ + * $|(Ar - b)_i| \leq \delta_i$ for each row $i$ + * $r \geq 0$ (optional) + + See `ModelSolve` for more details about the general responsibility of a model solver in this library. + + The constraint bounds are specified as **policies**: callables that receive the solve-time [`LinearSystemData`](analysis-linear-system-data "qiskit_noise_learning.analysis.LinearSystemData") and return the corresponding bound. + + **Parameters** + + * **coefficients** – Per-gate coefficients for the objective function, as a mapping from gate name to float. + * **epsilon** – Policy returning the tolerance for the overall weighted L2 norm constraint. At least one of `epsilon` or `deltas` must be provided. + * **deltas** – Policy returning per-row tolerances as a mapping from [`Path`](sequences-path "qiskit_noise_learning.sequences.Path") to float. It must cover every row of the linear system, since a row absent from the mapping would be left unconstrained. At least one of `epsilon` or `deltas` must be provided. + * **weights** – Policy returning the weight matrix `W` for the L2 constraint as an [`IndexedMatrix`](math-indexed-matrix "qiskit_noise_learning.math.IndexedMatrix") whose row and column indices are [`Path`](sequences-path "qiskit_noise_learning.sequences.Path") objects. Defaults to identity. A row or column of the linear system absent from `W` is weighted zero, which drops its residual from the norm. Only used when `epsilon` is provided. + * **non\_negative** – Whether to enforce `x >= 0`. + + **Raises** + + * [**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError) – If `epsilon`, `deltas` or `weights` is given as a fixed value rather than a policy. Use [`from_constants()`](#qiskit_noise_learning.analysis.PositivityMinSolve.from_constants "qiskit_noise_learning.analysis.PositivityMinSolve.from_constants") for fixed values. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – At solve time, if the `deltas` or `weights` policy produces a label that is not a row of the linear system, or if `deltas` omits one. + * [**RuntimeError**](https://docs.python.org/3/library/exceptions.html#RuntimeError) – At solve time, if the convex solver does not return a solution, for instance because the constraints are infeasible. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.PositivityMinSolve.__init__ "qiskit_noise_learning.analysis.PositivityMinSolve.__init__")(coefficients\[, epsilon, deltas, ...]) | | + | [`from_constants`](#qiskit_noise_learning.analysis.PositivityMinSolve.from_constants "qiskit_noise_learning.analysis.PositivityMinSolve.from_constants")(coefficients\[, epsilon, ...]) | Construct from fixed constant bounds instead of data-driven policies. | + | [`from_data_scaled_deltas`](#qiskit_noise_learning.analysis.PositivityMinSolve.from_data_scaled_deltas "qiskit_noise_learning.analysis.PositivityMinSolve.from_data_scaled_deltas")(coefficients\[, ...]) | Build with a delta-only policy based on statistical uncertainty of observables. | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ## Attributes + + | | | + | -------------- | --------------------------------- | + | `input_level` | The data level this stage reads. | + | `output_level` | The data level this stage writes. | + + ### from\_constants + + + Construct from fixed constant bounds instead of data-driven policies. + + Each supplied constant is wrapped in a policy that ignores the data and returns it. See the class docstring for the meaning of each argument; here they are fixed values rather than callables. + + + ### from\_data\_scaled\_deltas + + + Build with a delta-only policy based on statistical uncertainty of observables. + + Each row’s tolerance is set from that row’s own statistical uncertainty and its exponential-fit goodness-of-fit. For row $i$, with statistical `1`-sigma `sigma_b` and the reduced chi-squared `chi2_red` read from the `"reduced_chi_squared"` entry of `row_diagnostics`: + +$$ +\begin{split}\mathrm{inflation}_i &= \max(1, \sqrt{\mathrm{chi2\_red}_i}) \\ +\delta_i &= \mathrm{scale} \cdot \mathrm{inflation}_i \cdot \sigma_{b, i}\end{split} +$$ + + Setting `delta_i` proportional to `sigma` follows the Morozov discrepancy principle (allow about `scale` standard deviations of slack). Because `curve_fit` reports `sigma_b` with `absolute_sigma=True`, it is blind to model mismatch; the `sqrt(chi2_red)` factor loosens rows whose exponential fit is poor, and the `max(1, .)` clamp means mismatch can only loosen a row, never tighten it below its statistical uncertainty. Rows with an undefined `chi2_red` (`nan`, e.g. averaged rows), and every row when the system carries no `"reduced_chi_squared"` diagnostic at all, get no inflation. If the model cannot be fit within the resulting tolerances the solve reports an infeasible problem, and `scale` is the knob that loosens every row at once. + + A row whose uncertainty is non-positive or non-finite carries no statistical information to scale by, so rather than being treated as an extremely precise row it is assigned the median tolerance of the rows that do have a usable uncertainty. This keeps such a row in the fit at a typical scale without letting it constrain the solution as a near-equality, and no row’s tolerance ever depends on another row’s uncertainty except through this substitution. + + **Parameters** + + * **coefficients** – Per-gate coefficients for the objective function, as a mapping from gate name to float. + * **scale** – Multiplier on the per-row tolerance, in units of (inflated) standard deviations. + * **non\_negative** – Whether to enforce `x >= 0`. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – At solve time, if no row of the linear system has a positive, finite uncertainty, leaving nothing to derive tolerances from. + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-symmetrize-fidelities.mdx b/docs/api/qiskit-noise-learning/generated/analysis-symmetrize-fidelities.mdx new file mode 100644 index 000000000000..e27c9b175741 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-symmetrize-fidelities.mdx @@ -0,0 +1,43 @@ +--- +title: SymmetrizeFidelities (latest version) +description: API reference for qiskit_noise_learning.analysis.SymmetrizeFidelities in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.SymmetrizeFidelities +--- + + + +# qiskit\_noise\_learning.analysis.SymmetrizeFidelities + + + Bases: [`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.analysis_pipeline.AnalysisStage") + + Project generator rates into the fidelity-symmetry null space, gate by gate. + + For each gate, builds commutation matrices of generators against generators and conjugated generators against generators, then projects rates into the null space of their difference. Covariance is zeroed (the iterative projection with clipping is non-linear). + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.SymmetrizeFidelities.__init__ "qiskit_noise_learning.analysis.SymmetrizeFidelities.__init__")() | | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ### input\_level + + + alias of [`ModelData`](data-model-data "qiskit_noise_learning.data.model_data.ModelData") + + + ### output\_level + + + alias of [`ModelData`](data-model-data "qiskit_noise_learning.data.model_data.ModelData") + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-symmetrize-generators.mdx b/docs/api/qiskit-noise-learning/generated/analysis-symmetrize-generators.mdx new file mode 100644 index 000000000000..069bb7ca7d47 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-symmetrize-generators.mdx @@ -0,0 +1,43 @@ +--- +title: SymmetrizeGenerators (latest version) +description: API reference for qiskit_noise_learning.analysis.SymmetrizeGenerators in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.SymmetrizeGenerators +--- + + + +# qiskit\_noise\_learning.analysis.SymmetrizeGenerators + + + Bases: [`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.analysis_pipeline.AnalysisStage") + + Project generator rates to satisfy conjugation symmetry, gate by gate. + + For each gate, finds the pairs of generators that map to each under its conjugate action. The covariance is propagated through averaging. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.SymmetrizeGenerators.__init__ "qiskit_noise_learning.analysis.SymmetrizeGenerators.__init__")() | | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ### input\_level + + + alias of [`ModelData`](data-model-data "qiskit_noise_learning.data.model_data.ModelData") + + + ### output\_level + + + alias of [`ModelData`](data-model-data "qiskit_noise_learning.data.model_data.ModelData") + + + diff --git a/docs/api/qiskit-noise-learning/generated/analysis-zero-post-select.mdx b/docs/api/qiskit-noise-learning/generated/analysis-zero-post-select.mdx new file mode 100644 index 000000000000..316afe3d3a20 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/analysis-zero-post-select.mdx @@ -0,0 +1,63 @@ +--- +title: ZeroPostSelect (latest version) +description: API reference for qiskit_noise_learning.analysis.ZeroPostSelect in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.analysis.ZeroPostSelect +--- + + + +# qiskit\_noise\_learning.analysis.ZeroPostSelect + + + Bases: [`AnalysisStage`](analysis-analysis-stage "qiskit_noise_learning.analysis.analysis_pipeline.AnalysisStage") + + Apply a mask to raw data based on whether bit values are all False. + + This post-selection stage identifies cregs and masks shots whose bit patterns indicate failure. It can be configured to operate in one of two modes: + + * `"node"`: Shots are discarded if any bit in the identified creg is True. + + * **`"edge"`: Shots are discarded if there exists a pair of neighbouring qubits in the** + + coupling map for which both bits are True. + + **Parameters** + + * **creg\_identifier** – A callable that, given a list of present creg names, returns an iterator over creg names to post-select on. Defaults to identifying cregs with naming pattern `"*_ps"`. + * **mode** – Post-selection mode; either `"node"` or `"edge"`. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.analysis.ZeroPostSelect.__init__ "qiskit_noise_learning.analysis.ZeroPostSelect.__init__")(\[creg\_identifier, mode]) | | + | `run`(fit) | Run this stage, returning a new [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") with the output level populated. | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------- | + | `creg_identifier` | | + | [`input_level`](#qiskit_noise_learning.analysis.ZeroPostSelect.input_level "qiskit_noise_learning.analysis.ZeroPostSelect.input_level") | The data level this stage reads. | + | `mode` | | + | [`output_level`](#qiskit_noise_learning.analysis.ZeroPostSelect.output_level "qiskit_noise_learning.analysis.ZeroPostSelect.output_level") | The data level this stage writes. | + + ### input\_level + + + The data level this stage reads. + + + ### output\_level + + + The data level this stage writes. + + + diff --git a/docs/api/qiskit-noise-learning/generated/circuit-generator-executor-circuit-generator.mdx b/docs/api/qiskit-noise-learning/generated/circuit-generator-executor-circuit-generator.mdx new file mode 100644 index 000000000000..786fbc51c39e --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/circuit-generator-executor-circuit-generator.mdx @@ -0,0 +1,102 @@ +--- +title: ExecutorCircuitGenerator (latest version) +description: API reference for qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator +--- + + + +# qiskit\_noise\_learning.circuit\_generator.ExecutorCircuitGenerator + + + Bases: `CircuitGenerator`\[[`QuantumProgram`](/docs/api/qiskit-ibm-runtime/quantum-program-quantum-program "(in Qiskit Runtime IBM Client)"), [`ExecutorDataMapper`](circuit-generator-executor-data-mapper "qiskit_noise_learning.circuit_generator.executor_data_mapper.ExecutorDataMapper"), [`QuantumProgramResult`](/docs/api/qiskit-ibm-runtime/results-quantum-program-result "(in Qiskit Runtime IBM Client)")] + + A circuit generator that converts sequences of Qiskit gates into a samplex items. + + **Parameters** + + * **gate\_set** – The Qiskit gate set that this generator constructs against. + * **creg\_prefix** – The prefix assigned to all creg names used in instruction sequence measurements. Defaults to `"meas"`. + * **local\_clifford\_ref\_prefix** – The prefix assigned to all local Clifford parameter references in template circuits. Defaults to `"c"`. + * **pass\_manager** – An optional `PassManager` to apply to all template circuits produced by [`ExecutorCircuitGenerator.generate()`](#qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.generate "qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.generate"). + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.__init__ "qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.__init__")(gate\_set\[, creg\_prefix, ...]) | | + | [`collect`](#qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.collect "qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.collect")(result, data\_mapper) | Coerce data from a specific execution framework into a canonical form. | + | [`generate`](#qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.generate "qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.generate")(experiment) | Generate a new experimental task from the provided experiment. | + | [`generate_samplex_item`](#qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.generate_samplex_item "qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.generate_samplex_item")(instruction\_sequences, ...) | Generate a samplex item from instruction sequences with the same structure. | + | [`generate_samplex_items`](#qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.generate_samplex_items "qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.generate_samplex_items")(...) | Generate samplex items from instruction sequences. | + | `partition`(sequences) | Partition the positions of instruction sequences that can share a generation output. | + + ## Attributes + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | + | [`gate_set`](#qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.gate_set "qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.gate_set") | The gate set this generator constructs against. | + + ### gate\_set + + + Type: [`QiskitGateSet`](gate-sets-qiskit-gate-set "qiskit_noise_learning.gate_sets.qiskit_gate_set.QiskitGateSet") + + The gate set this generator constructs against. + + + ### collect + + + Coerce data from a specific execution framework into a canonical form. + + + ### generate + + + Generate a new experimental task from the provided experiment. + + + ### generate\_samplex\_items + + + Generate samplex items from instruction sequences. + + **Parameters** + + * **instruction\_sequences** – The instruction sequences to generate circuits for. + * **num\_randomizations** – The number of randomizations per sequence. + + **Returns** + + A tuple of samplex items and a data mapper. + + + ### generate\_samplex\_item + + + Generate a samplex item from instruction sequences with the same structure. + + **Parameters** + + * **instruction\_sequences** – The similar instruction sequences to generate. + * **num\_randomizations** – The number of randomizations per sequence. + + **Returns** + + A samplex item where the order of the arguments correspond to the order of `instruction_sequences`, an ordered list of creg names, and a dictionary mapping creg names to the ordered list of qubit indices they measure. + + **Raises** + + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If `instruction_sequences` is empty. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If any of the instruction sequences is not complete. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If any of the instruction sequences have different structure. + + + diff --git a/docs/api/qiskit-noise-learning/generated/circuit-generator-executor-data-mapper.mdx b/docs/api/qiskit-noise-learning/generated/circuit-generator-executor-data-mapper.mdx new file mode 100644 index 000000000000..1b9c3c5ec55f --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/circuit-generator-executor-data-mapper.mdx @@ -0,0 +1,120 @@ +--- +title: ExecutorDataMapper (latest version) +description: API reference for qiskit_noise_learning.circuit_generator.ExecutorDataMapper in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.circuit_generator.ExecutorDataMapper +--- + + + +# qiskit\_noise\_learning.circuit\_generator.ExecutorDataMapper + + + Bases: [`object`](https://docs.python.org/3/library/functions.html#object) + + Map executor results into standard results. + + As instruction sequences with similar structure are generated together with a single template circuit and different samplex arguments, the order of input sequences to [`ExecutorCircuitGenerator.generate()`](circuit-generator-executor-circuit-generator#generate "qiskit_noise_learning.circuit_generator.ExecutorCircuitGenerator.generate") is not preserved during execution. This class contains properties to format the results of a [`qiskit_ibm_runtime.results.QuantumProgramResult`](/docs/api/qiskit-ibm-runtime/results-quantum-program-result "(in Qiskit Runtime IBM Client)") to the order of the input sequences. + + **Parameters** + + * **item\_sequence\_indices** – For each program item, an ordered list of instruction sequence indices. Position in the list corresponds to the configuration index within the result item. + * **creg\_names** – The name of classical registers in each program item. + * **measurement\_maps** – For each program item, a dictionary from creg names to an ordered array of measured qubit indices. + * **instruction\_sequences** – The instruction sequences associated with the data. + * **num\_randomizations** – The number of randomizations used per experiment. + * **fidelity\_model** – The fidelity model used in the experiment. + * **paths** – The analysis paths. + * **relations** – Path-to-sequence relations. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - | + | [`__init__`](#qiskit_noise_learning.circuit_generator.ExecutorDataMapper.__init__ "qiskit_noise_learning.circuit_generator.ExecutorDataMapper.__init__")(item\_sequence\_indices, creg\_names, ...) | | + + ## Attributes + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | + | [`creg_names`](#qiskit_noise_learning.circuit_generator.ExecutorDataMapper.creg_names "qiskit_noise_learning.circuit_generator.ExecutorDataMapper.creg_names") | List of names of the classical registers contained in the results. | + | [`fidelity_model`](#qiskit_noise_learning.circuit_generator.ExecutorDataMapper.fidelity_model "qiskit_noise_learning.circuit_generator.ExecutorDataMapper.fidelity_model") | The fidelity model used in the experiment. | + | [`instruction_sequences`](#qiskit_noise_learning.circuit_generator.ExecutorDataMapper.instruction_sequences "qiskit_noise_learning.circuit_generator.ExecutorDataMapper.instruction_sequences") | The instruction sequences corresponding to the sequence indices in the sequence map. | + | [`item_sequence_indices`](#qiskit_noise_learning.circuit_generator.ExecutorDataMapper.item_sequence_indices "qiskit_noise_learning.circuit_generator.ExecutorDataMapper.item_sequence_indices") | Per program item, the instruction sequence indices corresponding to each config. | + | [`measurement_maps`](#qiskit_noise_learning.circuit_generator.ExecutorDataMapper.measurement_maps "qiskit_noise_learning.circuit_generator.ExecutorDataMapper.measurement_maps") | A per-program-item map from creg name to an ordered array of measured qubit indices. | + | [`num_randomizations`](#qiskit_noise_learning.circuit_generator.ExecutorDataMapper.num_randomizations "qiskit_noise_learning.circuit_generator.ExecutorDataMapper.num_randomizations") | The number of randomizations used per experiment. | + | [`paths`](#qiskit_noise_learning.circuit_generator.ExecutorDataMapper.paths "qiskit_noise_learning.circuit_generator.ExecutorDataMapper.paths") | The analysis paths. | + | [`relations`](#qiskit_noise_learning.circuit_generator.ExecutorDataMapper.relations "qiskit_noise_learning.circuit_generator.ExecutorDataMapper.relations") | Path-to-sequence relations. | + + ### item\_sequence\_indices + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`int`](https://docs.python.org/3/library/functions.html#int)]] + + Per program item, the instruction sequence indices corresponding to each config. + + + ### creg\_names + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str)]] + + List of names of the classical registers contained in the results. + + The list at a given index corresponds to names expected in the data of the [`qiskit_ibm_runtime.results.QuantumProgramResult`](/docs/api/qiskit-ibm-runtime/results-quantum-program-result "(in Qiskit Runtime IBM Client)") at the same index. + + + ### measurement\_maps + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`dict`](https://docs.python.org/3/library/stdtypes.html#dict)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)\[[`int`](https://docs.python.org/3/library/functions.html#int)]]] + + A per-program-item map from creg name to an ordered array of measured qubit indices. + + + ### instruction\_sequences + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list) + + The instruction sequences corresponding to the sequence indices in the sequence map. + + + ### num\_randomizations + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + The number of randomizations used per experiment. + + + ### fidelity\_model + + + Type: [`LinearMap`](math-linear-map "qiskit_noise_learning.math.linear_map.LinearMap")\[[`Hashable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable), [`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.fidelity_index.FidelityIndex")] | [`None`](https://docs.python.org/3/library/constants.html#None) + + The fidelity model used in the experiment. + + + ### paths + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`Path`](sequences-path "qiskit_noise_learning.sequences.path.Path")] | [`None`](https://docs.python.org/3/library/constants.html#None) + + The analysis paths. + + + ### relations + + + Type: [`set`](https://docs.python.org/3/library/stdtypes.html#set)\[[`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`int`](https://docs.python.org/3/library/functions.html#int), [`int`](https://docs.python.org/3/library/functions.html#int)]] | [`None`](https://docs.python.org/3/library/constants.html#None) + + Path-to-sequence relations. + + + diff --git a/docs/api/qiskit-noise-learning/generated/data-aggregated-observable-data.mdx b/docs/api/qiskit-noise-learning/generated/data-aggregated-observable-data.mdx new file mode 100644 index 000000000000..b421ee99d142 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/data-aggregated-observable-data.mdx @@ -0,0 +1,109 @@ +--- +title: AggregatedObservableData (latest version) +description: API reference for qiskit_noise_learning.data.AggregatedObservableData in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.data.AggregatedObservableData +--- + + + +# qiskit\_noise\_learning.data.AggregatedObservableData + + + Bases: [`LeveledData`](data-leveled-data "qiskit_noise_learning.data.leveled_data.LeveledData") + + Per-path estimates obtained by aggregating [`ObservableData`](data-observable-data "qiskit_noise_learning.data.ObservableData"). + + This class holds a single estimate per observable, obtained by collapsing the per-randomization structure of [`ObservableData`](data-observable-data "qiskit_noise_learning.data.ObservableData"). Each observable estimate is labelled by an unbound path and a corresponding fragment depth. A non-negative fragment depth corresponds to labelling by a bound path with that depth, and a fragment depth of `-1` signals that the estimate corresponds to a genuinely unbound path. For a non-negative fragment depth, the estimate value corresponds to the product of all fidelities in the path, and the estimate for a fragment depth of `-1` corresponds to the product of the fidelities in the repeatable fragment. + + * Data variables: + + > * `estimate_values`: A 1d float array of per-observable estimates, with dimensions `("observable",)`. + > * `estimate_std`: A 1d array of standard deviations for the estimates, with dimensions `("observable",)`. + > * `time_lbs`: A lower bound on the data collection for each observable, with dimensions `("observable",)`. + > * `time_ubs`: An upper bound on the data collection for each observable, with dimensions `("observable",)`. + > * `metadata`: A 1d object array of any additional per-observable data, with dimensions `("observable",)`. + + * Coordinates: + + > * `unbound_path`: A 1d array of unbound [`Path`](sequences-path "qiskit_noise_learning.sequences.Path") instances labelling each observable, with dimensions `("observable",)`. + > * `fragment_depth`: A 1d array of type `int` specifying the fragment depth associated to the observable. A value of `-1` indicates an estimate of only the `repeatable_fragment` of the path. + + **Parameters** + + **dataset** – A `Dataset` with the above formatting. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.data.AggregatedObservableData.__init__ "qiskit_noise_learning.data.AggregatedObservableData.__init__")(dataset) | | + | [`filter_time`](#qiskit_noise_learning.data.AggregatedObservableData.filter_time "qiskit_noise_learning.data.AggregatedObservableData.filter_time")(lb, ub) | Filter to data gathered within the time bounds. | + | [`from_arrays`](#qiskit_noise_learning.data.AggregatedObservableData.from_arrays "qiskit_noise_learning.data.AggregatedObservableData.from_arrays")(unbound\_paths, fragment\_depths, ...) | Instantiate from data specified as arrays in standard containers. | + | [`merge`](#qiskit_noise_learning.data.AggregatedObservableData.merge "qiskit_noise_learning.data.AggregatedObservableData.merge")(other) | Merge the data from self and other into a single instance. | + + ## Attributes + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | + | [`dataset`](#qiskit_noise_learning.data.AggregatedObservableData.dataset "qiskit_noise_learning.data.AggregatedObservableData.dataset") | The aggregated observable data set. | + + ### dataset + + + Type: `Dataset` + + The aggregated observable data set. + + + ### from\_arrays + + + Instantiate from data specified as arrays in standard containers. + + **Parameters** + + * **unbound\_paths** – A list of unbound paths (with `fragment_depth=None`). + * **fragment\_depths** – A list of fragment depths, with `-1` indicating the corresponding estimate is in reference to only the repeatable fragment of the corresponding path. + * **estimate\_values** – A 1d array of per-observable estimates. + * **estimate\_std** – A 1d array of standard deviations. + * **time\_lbs** – A 1d array of time lower bounds. + * **time\_ubs** – A 1d array of time upper bounds. + * **metadata** – Any additional data associated with a given observable. + + + ### merge + + + Merge the data from self and other into a single instance. + + **Parameters** + + **other** – The other data. + + **Returns** + + A new instance containing both data sets. + + + ### filter\_time + + + Filter to data gathered within the time bounds. + + **Parameters** + + * **lb** – The time lower bound (inclusive). + * **ub** – The time upper bound (inclusive). + + **Returns** + + The time filtered version of self. + + + diff --git a/docs/api/qiskit-noise-learning/generated/data-leveled-data.mdx b/docs/api/qiskit-noise-learning/generated/data-leveled-data.mdx new file mode 100644 index 000000000000..151ed435dc56 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/data-leveled-data.mdx @@ -0,0 +1,28 @@ +--- +title: LeveledData (latest version) +description: API reference for qiskit_noise_learning.data.LeveledData in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.data.LeveledData +--- + + + +# qiskit\_noise\_learning.data.LeveledData + + + Bases: [`object`](https://docs.python.org/3/library/functions.html#object) + + Marker base class for data at a specific level of the analysis hierarchy. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------ | - | + | [`__init__`](#qiskit_noise_learning.data.LeveledData.__init__ "qiskit_noise_learning.data.LeveledData.__init__")() | | + + diff --git a/docs/api/qiskit-noise-learning/generated/data-model-data.mdx b/docs/api/qiskit-noise-learning/generated/data-model-data.mdx new file mode 100644 index 000000000000..7b9f281ac5da --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/data-model-data.mdx @@ -0,0 +1,82 @@ +--- +title: ModelData (latest version) +description: API reference for qiskit_noise_learning.data.ModelData in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.data.ModelData +--- + + + +# qiskit\_noise\_learning.data.ModelData + + + Bases: [`LeveledData`](data-leveled-data "qiskit_noise_learning.data.leveled_data.LeveledData"), [`Generic`](https://docs.python.org/3/library/typing.html#typing.Generic)\[`ParameterIndex`] + + Results from fitting, backed by an xarray Dataset. + + The dataset has data variables: + + * `parameter_values`: 1D array with dimension `parameter_index`. + * `covariance`: 2D array with dimensions `(parameter_row_index, parameter_col_index)`. + + The `parameter_index`, `parameter_row_index`, and `parameter_col_index` coordinates all share the same parameter labels. Additional fit metadata is stored in dataset attrs. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.data.ModelData.__init__ "qiskit_noise_learning.data.ModelData.__init__")(dataset) | | + | [`filter_time`](#qiskit_noise_learning.data.ModelData.filter_time "qiskit_noise_learning.data.ModelData.filter_time")(lb, ub) | Filter to data gathered within the time bounds. | + | [`from_arrays`](#qiskit_noise_learning.data.ModelData.from_arrays "qiskit_noise_learning.data.ModelData.from_arrays")(parameter\_indices, ...\[, metadata]) | Instantiate from data specified as arrays in standard containers. | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------- | + | `dataset` | | + | [`metadata`](#qiskit_noise_learning.data.ModelData.metadata "qiskit_noise_learning.data.ModelData.metadata") | Metadata describing the model parameter fit. | + + ### from\_arrays + + + Instantiate from data specified as arrays in standard containers. + + **Parameters** + + * **parameter\_indices** – A list of `ParameterIndex` instances. + * **parameter\_values** – A 1d array of floats indicating parameter values. + * **covariance** – A 2d array of floats indicating the covariances of the parameter values. + * **time\_lbs** – A 1d array of data acquisition time lower bounds for each parameter estimate. + * **time\_ubs** – A 1d array of data acquisition time upper bounds for each parameter estimate. + * **metadata** – Any metadata to attach to the dataset. + + + ### metadata + + + Type: [`dict`](https://docs.python.org/3/library/stdtypes.html#dict)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)] + + Metadata describing the model parameter fit. + + + ### filter\_time + + + Filter to data gathered within the time bounds. + + **Parameters** + + * **lb** – The time lower bound (inclusive). + * **ub** – The time upper bound (inclusive). + + **Returns** + + The time filtered version of self. + + + diff --git a/docs/api/qiskit-noise-learning/generated/data-observable-data.mdx b/docs/api/qiskit-noise-learning/generated/data-observable-data.mdx new file mode 100644 index 000000000000..728b8af2e6f9 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/data-observable-data.mdx @@ -0,0 +1,124 @@ +--- +title: ObservableData (latest version) +description: API reference for qiskit_noise_learning.data.ObservableData in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.data.ObservableData +--- + + + +# qiskit\_noise\_learning.data.ObservableData + + + Bases: [`LeveledData`](data-leveled-data "qiskit_noise_learning.data.leveled_data.LeveledData") + + A collection of calculated expectation values. + + This class is a wrapper around an XArray `Dataset`, containing the following data: + + * Data variables: + + > * `observable_values`: Observables computed from single `InstructionSequence` and `Path` pairs at a given fragment depth, separated by randomizations. Has dimensions `("observable", "randomization")`. `np.nan` values are assumed to be due to raggedness of the `"randomization"` dimension for different observables. + > * `time_lbs`: Lower bound on data acquisition times, with dimensions `("observable", "randomization")`, and of type `"datetime64[us]"`. + > * `time_ubs`: Upper bound on data acquisition times, with dimensions `("observable", "randomization")`, and of type `"datetime64[us]"`. + + * Coordinates: + + > * `unbound_path`: The unbound path (with `fragment_depth=None`) for each observable, along dimension `("observable",)`, of type `Path`. + > * `fragment_depth`: Integer array of fragment depths along dimension `("observable",)`. + + **Parameters** + + **dataset** – A dataset with the above formatting. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.data.ObservableData.__init__ "qiskit_noise_learning.data.ObservableData.__init__")(dataset) | | + | [`filter_time`](#qiskit_noise_learning.data.ObservableData.filter_time "qiskit_noise_learning.data.ObservableData.filter_time")(lb, ub) | Filter to data gathered within the time bounds. | + | [`from_arrays`](#qiskit_noise_learning.data.ObservableData.from_arrays "qiskit_noise_learning.data.ObservableData.from_arrays")(unbound\_paths, fragment\_depths, ...) | Instantiate from data specified as arrays. | + | [`merge`](#qiskit_noise_learning.data.ObservableData.merge "qiskit_noise_learning.data.ObservableData.merge")(other) | Merge observable data into a single instance. | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | + | `dataset` | | + | [`observable_values`](#qiskit_noise_learning.data.ObservableData.observable_values "qiskit_noise_learning.data.ObservableData.observable_values") | Observables data array. | + | [`time_lbs`](#qiskit_noise_learning.data.ObservableData.time_lbs "qiskit_noise_learning.data.ObservableData.time_lbs") | Time lower bounds data array. | + | [`time_ubs`](#qiskit_noise_learning.data.ObservableData.time_ubs "qiskit_noise_learning.data.ObservableData.time_ubs") | Time upper bounds data array. | + + ### from\_arrays + + + Instantiate from data specified as arrays. + + **Parameters** + + * **unbound\_paths** – The unbound paths corresponding to the observables. + * **fragment\_depths** – The fragment depths for each observable. + * **observable\_values** – A 2d numpy array of `floats` with axes `("observable", "randomization")`. + * **time\_lbs** – A lower bound on the data collection time for each observable and randomization. Has axes `("observable", "randomization")`. + * **time\_ubs** – Upper bounds on the data collection time for each observable and randomization. Has axes `("observable", "randomization")`. + + + ### observable\_values + + + Type: `DataArray` + + Observables data array. + + + ### time\_lbs + + + Type: `DataArray` + + Time lower bounds data array. + + + ### time\_ubs + + + Type: `DataArray` + + Time upper bounds data array. + + + ### merge + + + Merge observable data into a single instance. + + **Parameters** + + **other** – The other observable data set. + + **Returns** + + The merged data. + + + ### filter\_time + + + Filter to data gathered within the time bounds. + + **Parameters** + + * **lb** – The time lower bound (inclusive). + * **ub** – The time upper bound (inclusive). + + **Returns** + + The time filtered version of self. + + + diff --git a/docs/api/qiskit-noise-learning/generated/data-raw-data.mdx b/docs/api/qiskit-noise-learning/generated/data-raw-data.mdx new file mode 100644 index 000000000000..3b047bc00fa3 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/data-raw-data.mdx @@ -0,0 +1,121 @@ +--- +title: RawData (latest version) +description: API reference for qiskit_noise_learning.data.RawData in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.data.RawData +--- + + + +# qiskit\_noise\_learning.data.RawData + + + Bases: [`LeveledData`](data-leveled-data "qiskit_noise_learning.data.leveled_data.LeveledData") + + Raw experimental outcome data associated with instruction sequences and classical registers. + + This class is a wrapper around a 1-layer deep XArray `DataTree` with arbitrary string keys. Each leaf dataset contains: + + * Data variables: + + > * `data`: The raw boolean data with dimensions `("randomization", "shot", "bit")`. + > * `data_mask`: A boolean mask with dimensions `("randomization", "shot")`. Handles potential raggedness in the `"shot"` dimension across different randomizations. + > * `measurement_flips`: A boolean array of measurement flips with dimensions `("randomization", "bit")`. + > * `time_lbs`: Lower bound on data acquisition times, with dimensions `("randomization",)`, of type `"datetime64[us]"`. + > * `time_ubs`: Upper bound on data acquisition times, with dimensions `("randomization",)`, of type `"datetime64[us]"`. + + * Coordinates: + + > * `unbound_instruction_sequence`: The unbound instruction sequence for the data, along dimension `("randomization",)`, of type `InstructionSequence`. + > * `fragment_depth`: Integer array of fragment depths along dimension `("randomization",)`. + + * Attrs: + + > * `creg_names`: Ordered list of classical register names. + > * `measurement_map`: Dictionary mapping creg names to arrays of measured qubit indices. + > * `creg_bit_boundaries`: Dictionary mapping creg names to `(start_idx, end_idx)` tuples indicating the slice of the `"bit"` dimension for that register. + + Datasets are grouped by creg metadata: two datasets with the same `creg_names` and `measurement_map` are merged along the `"randomization"` dimension. + + **Parameters** + + **datatree** – A datatree in the above format. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.data.RawData.__init__ "qiskit_noise_learning.data.RawData.__init__")(datatree) | | + | [`filter_time`](#qiskit_noise_learning.data.RawData.filter_time "qiskit_noise_learning.data.RawData.filter_time")(lb, ub) | Filter to data gathered within the time bounds. | + | [`from_arrays`](#qiskit_noise_learning.data.RawData.from_arrays "qiskit_noise_learning.data.RawData.from_arrays")(creg\_names, measurement\_map, ...) | Instantiate from data specified as arrays. | + | [`merge`](#qiskit_noise_learning.data.RawData.merge "qiskit_noise_learning.data.RawData.merge")(other) | Merge with another raw data set. | + + ## Attributes + + | | | + | -------------------------------------------------------------------------------------------------------- | -------------- | + | [`datatree`](#qiskit_noise_learning.data.RawData.datatree "qiskit_noise_learning.data.RawData.datatree") | The data tree. | + + ### datatree + + + Type: `DataTree` + + The data tree. + + + ### from\_arrays + + + Instantiate from data specified as arrays. + + All instruction sequences must share the same creg structure (same `creg_names` and `measurement_map`). The resulting `RawData` contains a single-leaf datatree. + + **Parameters** + + * **creg\_names** – Ordered list of classical register names. + * **measurement\_map** – Dictionary mapping creg names to arrays of measured physical qubit indices. + * **instruction\_sequences** – The list of instruction sequences used to generate the experiments. + * **data** – A list of outcome data for each instruction sequence for all classical registers. The data has dimensions `("randomization", "shot", "bit")`. Bits are ordered according to `creg_names` order, with each creg’s bits contiguous. + * **measurement\_flips** – A list of measurement flips to be applied to the data for each instruction sequence. Dimensions are `("randomization", "bit")`. + * **time\_lbs** – A lower bound on the data collection time for each randomization for a given instruction sequence. The dimensions are `("randomization",)`. + * **time\_ubs** – An upper bound on the data collection time for each randomization for a given instruction sequence. The dimensions are `("randomization",)`. + + + ### merge + + + Merge with another raw data set. + + Datasets with matching creg metadata (`creg_names` and `measurement_map`) are concatenated along the `"randomization"` dimension. Potential raggedness of the `"shot"` dimension is handled via the `"data_mask"` data variable. + + **Parameters** + + **other** – The other raw dataset. + + **Returns** + + The merged data. + + + ### filter\_time + + + Filter to data gathered within the time bounds. + + **Parameters** + + * **lb** – The time lower bound (inclusive). + * **ub** – The time upper bound (inclusive). + + **Returns** + + The time filtered version of self. + + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-add-instruction-sequences.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-add-instruction-sequences.mdx new file mode 100644 index 000000000000..a063a1e22ea6 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-add-instruction-sequences.mdx @@ -0,0 +1,45 @@ +--- +title: AddInstructionSequences (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.AddInstructionSequences in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.AddInstructionSequences +--- + + + +# qiskit\_noise\_learning.experiment\_builder.AddInstructionSequences + + + Bases: [`ExperimentBuilderStage`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.experiment_builder_stage.ExperimentBuilderStage") + + Add instruction sequences to an experiment. + + This is both a concrete stage (pass sequences directly) and the base class for sequence-generator stages that compute sequences from the experiment at runtime. + + Subclasses should override `_generate_sequences()` to return sequences and multipliers computed from the experiment’s data. + + **Parameters** + + * **instruction\_sequences** – The instruction sequences to add. + * **randomization\_multipliers** – Per-sequence randomization multipliers. If `None`, defaults to all ones. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.AddInstructionSequences.__init__ "qiskit_noise_learning.experiment_builder.AddInstructionSequences.__init__")(instruction\_sequences\[, ...]) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------ | - | + | `populates_fields` | | + | `required_fields` | | + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-add-paths.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-add-paths.mdx new file mode 100644 index 000000000000..356da1a29b7e --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-add-paths.mdx @@ -0,0 +1,44 @@ +--- +title: AddPaths (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.AddPaths in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.AddPaths +--- + + + +# qiskit\_noise\_learning.experiment\_builder.AddPaths + + + Bases: [`ExperimentBuilderStage`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.experiment_builder_stage.ExperimentBuilderStage") + + Add paths to an experiment. + + This is both a concrete stage (pass path iterators directly) and the base class for path-generator stages that compute paths from the experiment at runtime. + + Subclasses should override `_generate_paths()` to yield paths computed from the experiment’s fidelity model or other data. + + **Parameters** + + **path\_iterators** – One or more iterators of [`Path`](sequences-path "qiskit_noise_learning.sequences.Path") instances. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.AddPaths.__init__ "qiskit_noise_learning.experiment_builder.AddPaths.__init__")(\*path\_iterators) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------ | - | + | `populates_fields` | | + | `required_fields` | | + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-bind-fragment-depths.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-bind-fragment-depths.mdx new file mode 100644 index 000000000000..0897b59f094a --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-bind-fragment-depths.mdx @@ -0,0 +1,42 @@ +--- +title: BindFragmentDepths (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.BindFragmentDepths in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.BindFragmentDepths +--- + + + +# qiskit\_noise\_learning.experiment\_builder.BindFragmentDepths + + + Bases: [`ExperimentBuilderStage`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.experiment_builder_stage.ExperimentBuilderStage") + + Expand unbound instruction sequences at the given fragment depths. + + Each unbound instruction sequence is replaced by a bound copy at each fragment depth. Bound sequences are kept as-is. The `randomization_multipliers` and `relations` are updated accordingly: the multiplier of an unbound sequence is propagated to all its bound expansions, and any relation pointing to an unbound sequence is fanned out to all the resulting bound sequences. + + **Parameters** + + **fragment\_depths** – The fragment depths at which to bind unbound sequences. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.BindFragmentDepths.__init__ "qiskit_noise_learning.experiment_builder.BindFragmentDepths.__init__")(fragment\_depths) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------ | - | + | `populates_fields` | | + | `required_fields` | | + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-complete-sequences.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-complete-sequences.mdx new file mode 100644 index 000000000000..486a20418445 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-complete-sequences.mdx @@ -0,0 +1,38 @@ +--- +title: CompleteSequences (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.CompleteSequences in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.CompleteSequences +--- + + + +# qiskit\_noise\_learning.experiment\_builder.CompleteSequences + + + Bases: [`ExperimentBuilderStage`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.experiment_builder_stage.ExperimentBuilderStage") + + Complete all instruction sequences. + + Calls [`complete()`](sequences-instruction-sequence#complete "qiskit_noise_learning.sequences.InstructionSequence.complete") on each instruction sequence to finalize any [`PartialPauliPermutation`](sequences-partial-pauli-permutation "qiskit_noise_learning.sequences.PartialPauliPermutation") instances. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.CompleteSequences.__init__ "qiskit_noise_learning.experiment_builder.CompleteSequences.__init__")() | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------ | - | + | `populates_fields` | | + | `required_fields` | | + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-depth-1-paths.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-depth-1-paths.mdx new file mode 100644 index 000000000000..5f643a3a755d --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-depth-1-paths.mdx @@ -0,0 +1,55 @@ +--- +title: Depth1Paths (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.Depth1Paths in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.Depth1Paths +--- + + + +# qiskit\_noise\_learning.experiment\_builder.Depth1Paths + + + Bases: [`AddPaths`](experiment-builder-add-paths "qiskit_noise_learning.experiment_builder.stages.path_generators.add_paths.AddPaths") + + Generate depth-1 paths for each target gate. + + **Parameters** + + * **prep\_gate** – The preparation gate. If `None`, defaults to the gate named `"P"`. + * **meas\_gate** – The measurement gate. If `None`, defaults to the gate named `"M"`. + * **gates** – Gates to generate paths for; these must be unitary (no preparation or measurement component). If `None`, defaults to all unitary (non-SPAM) gates. + * **input\_paulis** – Optional mapping from gate name to input Paulis. If not specified, defaults to the gate generators if the fidelity model contains a [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"), otherwise a `ValueError` is raised. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.Depth1Paths.__init__ "qiskit_noise_learning.experiment_builder.Depth1Paths.__init__")(\*\[, prep\_gate, meas\_gate, gates, ...]) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | + | `populates_fields` | | + | [`required_fields`](#qiskit_noise_learning.experiment_builder.Depth1Paths.required_fields "qiskit_noise_learning.experiment_builder.Depth1Paths.required_fields") | Built-in immutable sequence. | + + ### required\_fields + + + Type: [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), ...] + + Built-in immutable sequence. + + If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items. + + If the argument is a tuple, the return value is the same object. + + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-even-depth-paths.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-even-depth-paths.mdx new file mode 100644 index 000000000000..28769c4cffa8 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-even-depth-paths.mdx @@ -0,0 +1,58 @@ +--- +title: EvenDepthPaths (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.EvenDepthPaths in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.EvenDepthPaths +--- + + + +# qiskit\_noise\_learning.experiment\_builder.EvenDepthPaths + + + Bases: [`AddPaths`](experiment-builder-add-paths "qiskit_noise_learning.experiment_builder.stages.path_generators.add_paths.AddPaths") + + Generate unbound paths with repetitions of two applications of each target gate. + + For each target gate, generates all well-defined paths where the repeatable fragment consists of two applications of the gate with intermediate single-qubit Cliffords. + + **Parameters** + + * **prep\_gate** – The preparation gate. If `None`, defaults to the gate named `"P"`. + * **meas\_gate** – The measurement gate. If `None`, defaults to the gate named `"M"`. + * **gates** – Gates to generate paths for; these must be unitary (no preparation or measurement component). If `None`, defaults to all unitary gates. + * **input\_paulis** – Optional mapping from gate name to input Paulis. If not specified, defaults to the gate generators if the fidelity model contains a [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"), otherwise a `ValueError` is raised. + * **output\_paulis** – Optional mapping from gate name to output Paulis. Defaults to input. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.EvenDepthPaths.__init__ "qiskit_noise_learning.experiment_builder.EvenDepthPaths.__init__")(\*\[, prep\_gate, meas\_gate, gates, ...]) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | + | `populates_fields` | | + | [`required_fields`](#qiskit_noise_learning.experiment_builder.EvenDepthPaths.required_fields "qiskit_noise_learning.experiment_builder.EvenDepthPaths.required_fields") | Built-in immutable sequence. | + + ### required\_fields + + + Type: [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), ...] + + Built-in immutable sequence. + + If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items. + + If the argument is a tuple, the return value is the same object. + + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-even-depth-vanilla-paths.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-even-depth-vanilla-paths.mdx new file mode 100644 index 000000000000..4e7e9f5faddb --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-even-depth-vanilla-paths.mdx @@ -0,0 +1,57 @@ +--- +title: EvenDepthVanillaPaths (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.EvenDepthVanillaPaths in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.EvenDepthVanillaPaths +--- + + + +# qiskit\_noise\_learning.experiment\_builder.EvenDepthVanillaPaths + + + Bases: [`AddPaths`](experiment-builder-add-paths "qiskit_noise_learning.experiment_builder.stages.path_generators.add_paths.AddPaths") + + Generate unbound vanilla paths with repetitions of two gate applications. + + For each target gate, generates paths where the repeatable fragment consists of two applications of the gate. + + **Parameters** + + * **prep\_gate** – The preparation gate. If `None`, defaults to the gate named `"P"`. + * **meas\_gate** – The measurement gate. If `None`, defaults to the gate named `"M"`. + * **gates** – Gates to generate paths for; these must be unitary (no preparation or measurement component). If `None`, defaults to all unitary gates in the gate set. + * **input\_paulis** – Optional mapping from gate name to the Paulis to use. If not specified, defaults to the gate generators if the fidelity model contains a [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"), otherwise a `ValueError` is raised. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.EvenDepthVanillaPaths.__init__ "qiskit_noise_learning.experiment_builder.EvenDepthVanillaPaths.__init__")(\*\[, prep\_gate, meas\_gate, gates, ...]) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | + | `populates_fields` | | + | [`required_fields`](#qiskit_noise_learning.experiment_builder.EvenDepthVanillaPaths.required_fields "qiskit_noise_learning.experiment_builder.EvenDepthVanillaPaths.required_fields") | Built-in immutable sequence. | + + ### required\_fields + + + Type: [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), ...] + + Built-in immutable sequence. + + If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items. + + If the argument is a tuple, the return value is the same object. + + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment-builder-stage.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment-builder-stage.mdx new file mode 100644 index 000000000000..a073c42eb43c --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment-builder-stage.mdx @@ -0,0 +1,65 @@ +--- +title: ExperimentBuilderStage (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.ExperimentBuilderStage in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.ExperimentBuilderStage +--- + + + +# qiskit\_noise\_learning.experiment\_builder.ExperimentBuilderStage + + + Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC) + + Abstract base for a stage in the experiment-building pipeline. + + Each stage takes an [`Experiment`](experiment-builder-experiment "qiskit_noise_learning.experiment_builder.Experiment") and returns a new [`Experiment`](experiment-builder-experiment "qiskit_noise_learning.experiment_builder.Experiment") with additional fields populated or existing fields transformed. + + Subclasses declare which [`Experiment`](experiment-builder-experiment "qiskit_noise_learning.experiment_builder.Experiment") fields they require via the `required_fields` class attribute, and which fields they populate (can take form `None` to a non-`None` value) via `populates_fields`. The public [`run()`](#qiskit_noise_learning.experiment_builder.ExperimentBuilderStage.run "qiskit_noise_learning.experiment_builder.ExperimentBuilderStage.run") method validates that the required fields are not `None` before dispatching to `_run()`. + + [`ExperimentBuilder`](experiment-builder-experiment-builder "qiskit_noise_learning.experiment_builder.ExperimentBuilder") uses `populates_fields` to compute its aggregate `required_fields`: a stage’s requirement is satisfied if a preceding stage populates that field. + + **Parameters** + + * **required\_fields** – Tuple of [`Experiment`](experiment-builder-experiment "qiskit_noise_learning.experiment_builder.Experiment") property names that must be non-`None` before this stage can execute. + * **populates\_fields** – Tuple of [`Experiment`](experiment-builder-experiment "qiskit_noise_learning.experiment_builder.Experiment") property names that this stage populates on the returned [`Experiment`](experiment-builder-experiment "qiskit_noise_learning.experiment_builder.Experiment"). + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.ExperimentBuilderStage.__init__ "qiskit_noise_learning.experiment_builder.ExperimentBuilderStage.__init__")() | | + | [`run`](#qiskit_noise_learning.experiment_builder.ExperimentBuilderStage.run "qiskit_noise_learning.experiment_builder.ExperimentBuilderStage.run")(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------ | - | + | `populates_fields` | | + | `required_fields` | | + + ### run + + + Validate required fields, then apply this stage. + + **Parameters** + + **experiment** – The input experiment. + + **Returns** + + A new [`Experiment`](experiment-builder-experiment "qiskit_noise_learning.experiment_builder.Experiment") with this stage’s transformations applied. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If any field listed in `required_fields` is `None`. + + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment-builder.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment-builder.mdx new file mode 100644 index 000000000000..0173ea4cde37 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment-builder.mdx @@ -0,0 +1,67 @@ +--- +title: ExperimentBuilder (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.ExperimentBuilder in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.ExperimentBuilder +--- + + + +# qiskit\_noise\_learning.experiment\_builder.ExperimentBuilder + + + Bases: [`ExperimentBuilderStage`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.experiment_builder_stage.ExperimentBuilderStage") + + A composite [`ExperimentBuilderStage`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.ExperimentBuilderStage") that chains stages sequentially. + + Because [`ExperimentBuilder`](#qiskit_noise_learning.experiment_builder.ExperimentBuilder "qiskit_noise_learning.experiment_builder.ExperimentBuilder") is itself an [`ExperimentBuilderStage`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.ExperimentBuilderStage"), builders can be nested and used anywhere a single stage is expected. + + **Parameters** + + **stages** – The stages to chain in sequential order. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.ExperimentBuilder.__init__ "qiskit_noise_learning.experiment_builder.ExperimentBuilder.__init__")(\*stages) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | + | [`populates_fields`](#qiskit_noise_learning.experiment_builder.ExperimentBuilder.populates_fields "qiskit_noise_learning.experiment_builder.ExperimentBuilder.populates_fields") | The union of all fields populated by stages in this pipeline. | + | [`required_fields`](#qiskit_noise_learning.experiment_builder.ExperimentBuilder.required_fields "qiskit_noise_learning.experiment_builder.ExperimentBuilder.required_fields") | The fields required by this pipeline that no internal stage populates. | + | [`stages`](#qiskit_noise_learning.experiment_builder.ExperimentBuilder.stages "qiskit_noise_learning.experiment_builder.ExperimentBuilder.stages") | The stages in this builder. | + + ### stages + + + Type: [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`ExperimentBuilderStage`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.experiment_builder_stage.ExperimentBuilderStage"), ...] + + The stages in this builder. + + + ### required\_fields + + + Type: [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), ...] + + The fields required by this pipeline that no internal stage populates. + + + ### populates\_fields + + + Type: [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), ...] + + The union of all fields populated by stages in this pipeline. + + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment.mdx new file mode 100644 index 000000000000..fa52c0c8acfc --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-experiment.mdx @@ -0,0 +1,168 @@ +--- +title: Experiment (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.Experiment in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.Experiment +--- + + + +# qiskit\_noise\_learning.experiment\_builder.Experiment + + + Bases: [`object`](https://docs.python.org/3/library/functions.html#object) + + A learning experiment specification. + + An [`Experiment`](#qiskit_noise_learning.experiment_builder.Experiment "qiskit_noise_learning.experiment_builder.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`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.ExperimentBuilderStage") instances. + + **Parameters** + + * **fidelity\_model** – A fidelity model or a model gate set (which is wrapped in an [`IdentityFidelityModel`](models-identity-fidelity-model "qiskit_noise_learning.models.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 as [`replace()`](#qiskit_noise_learning.experiment_builder.Experiment.replace "qiskit_noise_learning.experiment_builder.Experiment.replace") (co-replacement, length consistency, relations bounds). + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.experiment_builder.Experiment.__init__ "qiskit_noise_learning.experiment_builder.Experiment.__init__")(\*\[, fidelity\_model, paths, ...]) | | + | [`replace`](#qiskit_noise_learning.experiment_builder.Experiment.replace "qiskit_noise_learning.experiment_builder.Experiment.replace")(\*\[, validate]) | Return a shallow copy with the given fields overridden. | + + ## Attributes + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | + | [`design_matrix`](#qiskit_noise_learning.experiment_builder.Experiment.design_matrix "qiskit_noise_learning.experiment_builder.Experiment.design_matrix") | The design matrix, lazily computed from the fidelity model and paths. | + | [`fidelity_model`](#qiskit_noise_learning.experiment_builder.Experiment.fidelity_model "qiskit_noise_learning.experiment_builder.Experiment.fidelity_model") | The fidelity model. | + | [`gate_set`](#qiskit_noise_learning.experiment_builder.Experiment.gate_set "qiskit_noise_learning.experiment_builder.Experiment.gate_set") | The model gate set. | + | [`instruction_sequences`](#qiskit_noise_learning.experiment_builder.Experiment.instruction_sequences "qiskit_noise_learning.experiment_builder.Experiment.instruction_sequences") | The instruction sequences. | + | [`is_executable`](#qiskit_noise_learning.experiment_builder.Experiment.is_executable "qiskit_noise_learning.experiment_builder.Experiment.is_executable") | Whether this experiment has all the information required to be run. | + | [`paths`](#qiskit_noise_learning.experiment_builder.Experiment.paths "qiskit_noise_learning.experiment_builder.Experiment.paths") | The analysis paths. | + | [`randomization_multipliers`](#qiskit_noise_learning.experiment_builder.Experiment.randomization_multipliers "qiskit_noise_learning.experiment_builder.Experiment.randomization_multipliers") | Per-sequence randomization multipliers. | + | [`randomizations`](#qiskit_noise_learning.experiment_builder.Experiment.randomizations "qiskit_noise_learning.experiment_builder.Experiment.randomizations") | Global number of randomizations. | + | [`relations`](#qiskit_noise_learning.experiment_builder.Experiment.relations "qiskit_noise_learning.experiment_builder.Experiment.relations") | The set of path and sequence relations. | + | [`shots`](#qiskit_noise_learning.experiment_builder.Experiment.shots "qiskit_noise_learning.experiment_builder.Experiment.shots") | Global number of shots. | + + ### fidelity\_model + + + Type: [`LinearMap`](math-linear-map "qiskit_noise_learning.math.linear_map.LinearMap")\[[`Hashable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable), [`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.fidelity_index.FidelityIndex")] | [`None`](https://docs.python.org/3/library/constants.html#None) + + The fidelity model. + + + ### gate\_set + + + Type: [`ModelGateSet`](gate-sets-model-gate-set "qiskit_noise_learning.gate_sets.model_gate_set.ModelGateSet") | [`None`](https://docs.python.org/3/library/constants.html#None) + + The model gate set. + + + ### paths + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`Path`](sequences-path "qiskit_noise_learning.sequences.path.Path")] | [`None`](https://docs.python.org/3/library/constants.html#None) + + The analysis paths. + + + ### instruction\_sequences + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`InstructionSequence`](sequences-instruction-sequence "qiskit_noise_learning.sequences.instruction_sequence.InstructionSequence")] | [`None`](https://docs.python.org/3/library/constants.html#None) + + The instruction sequences. + + + ### relations + + + Type: [`set`](https://docs.python.org/3/library/stdtypes.html#set)\[[`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`int`](https://docs.python.org/3/library/functions.html#int), [`int`](https://docs.python.org/3/library/functions.html#int)]] | [`None`](https://docs.python.org/3/library/constants.html#None) + + The set of path and sequence relations. + + + ### shots + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + Global number of shots. + + + ### randomizations + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + Global number of randomizations. + + + ### randomization\_multipliers + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`int`](https://docs.python.org/3/library/functions.html#int)] | [`None`](https://docs.python.org/3/library/constants.html#None) + + Per-sequence randomization multipliers. + + + ### design\_matrix + + + Type: [`IndexedMatrix`](math-indexed-matrix "qiskit_noise_learning.math.indexed_matrix.IndexedMatrix") + + The design matrix, lazily computed from the fidelity model and paths. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If `fidelity_model` or `paths` is `None`. + + + ### is\_executable + + + Type: [`bool`](https://docs.python.org/3/library/functions.html#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 + + + Return a shallow copy with the given fields overridden. + + When `validate=True` (default), the following checks are enforced: + + * **Co-replacement**: `instruction_sequences` and `randomization_multipliers` must always both be `None` or both be non-`None`. Replacing one without the other is only allowed if it preserves this invariant. + * **Length consistency**: `randomization_multipliers` must have the same length as `instruction_sequences`. + * **Relations bounds**: Setting `relations` requires `paths` and `instruction_sequences` to be present, and all indices must be in bounds. + * **Soft invalidation**: Replacing `paths` or `instruction_sequences` without providing new `relations` will set `relations` to `None` with a warning. + + **Parameters** + + * **validate** – If `True`, enforce the above checks. If `False`, fields are set as-is with no validation. + * **\*\*kwargs** – Field names and their new values. + + **Raises** + + * [**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError) – If an unrecognized field name is given. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If a validation constraint is violated. + + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-generate-instruction-sequences.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-generate-instruction-sequences.mdx new file mode 100644 index 000000000000..0487d7347d6f --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-generate-instruction-sequences.mdx @@ -0,0 +1,44 @@ +--- +title: GenerateInstructionSequences (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.GenerateInstructionSequences in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.GenerateInstructionSequences +--- + + + +# qiskit\_noise\_learning.experiment\_builder.GenerateInstructionSequences + + + Bases: [`AddInstructionSequences`](experiment-builder-add-instruction-sequences "qiskit_noise_learning.experiment_builder.stages.sequence_generators.add_instruction_sequences.AddInstructionSequences") + + Generate one instruction sequence per path via [`to_instruction_sequence()`](sequences-path#to_instruction_sequence "qiskit_noise_learning.sequences.Path.to_instruction_sequence"). + + For each path (optionally skipping paths already referenced by a relation), generates a corresponding instruction sequence and adds it along with a new relation entry. + + **Parameters** + + * **bound\_multiplier** – Randomization multiplier for bound sequences. + * **unbound\_multiplier** – Randomization multiplier for unbound sequences. + * **skip\_related\_paths** – If `True` (default), paths that already appear in a relation are not used to generate new sequences. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.GenerateInstructionSequences.__init__ "qiskit_noise_learning.experiment_builder.GenerateInstructionSequences.__init__")(\*\[, bound\_multiplier, ...]) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------ | - | + | `populates_fields` | | + | `required_fields` | | + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-identify-relations.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-identify-relations.mdx new file mode 100644 index 000000000000..fbbb85807e69 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-identify-relations.mdx @@ -0,0 +1,42 @@ +--- +title: IdentifyRelations (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.IdentifyRelations in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.IdentifyRelations +--- + + + +# qiskit\_noise\_learning.experiment\_builder.IdentifyRelations + + + Bases: [`ExperimentBuilderStage`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.experiment_builder_stage.ExperimentBuilderStage") + + Identify new relations amongst existing paths and instruction sequences. + + Iterates over all path/sequence pairs and identifies which sequences traverse which paths. Optionally extends instruction sequence permutations to enable new traversals. + + **Parameters** + + **attempt\_instruction\_extension** – Whether to extend instruction sequence permutations to traverse new paths. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.IdentifyRelations.__init__ "qiskit_noise_learning.experiment_builder.IdentifyRelations.__init__")(\[attempt\_instruction\_extension]) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------ | - | + | `populates_fields` | | + | `required_fields` | | + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-merge-instruction-sequences.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-merge-instruction-sequences.mdx new file mode 100644 index 000000000000..a0eb81fe5e50 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-merge-instruction-sequences.mdx @@ -0,0 +1,42 @@ +--- +title: MergeInstructionSequences (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.MergeInstructionSequences in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.MergeInstructionSequences +--- + + + +# qiskit\_noise\_learning.experiment\_builder.MergeInstructionSequences + + + Bases: [`ExperimentBuilderStage`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.experiment_builder_stage.ExperimentBuilderStage") + + Merge instruction sequences into a smaller set. + + The sequences that can be merged with each other are grouped together by [`group_mergeable_instruction_sequences()`](sequences-group-mergeable-instruction-sequences "qiskit_noise_learning.sequences.group_mergeable_instruction_sequences"), and every group is merged into a single sequence. + + **Parameters** + + **grouping\_strategies** – The grouping strategies to take the fewest groups found by any of, as documented in [`group_mergeable_instruction_sequences()`](sequences-group-mergeable-instruction-sequences "qiskit_noise_learning.sequences.group_mergeable_instruction_sequences"). If `None`, an empirically determined default set of strategies is used. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.MergeInstructionSequences.__init__ "qiskit_noise_learning.experiment_builder.MergeInstructionSequences.__init__")(\[grouping\_strategies]) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------ | - | + | `populates_fields` | | + | `required_fields` | | + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-rank-reduce-paths.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-rank-reduce-paths.mdx new file mode 100644 index 000000000000..2cdba6b0ef9f --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-rank-reduce-paths.mdx @@ -0,0 +1,42 @@ +--- +title: RankReducePaths (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.RankReducePaths in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.RankReducePaths +--- + + + +# qiskit\_noise\_learning.experiment\_builder.RankReducePaths + + + Bases: [`ExperimentBuilderStage`](experiment-builder-experiment-builder-stage "qiskit_noise_learning.experiment_builder.experiment_builder_stage.ExperimentBuilderStage") + + Reduce the paths to a maximal linearly independent set. + + Removes linearly dependent paths from the experiment’s design matrix, updates relations accordingly, and removes any instruction sequences no longer referenced. + + **Parameters** + + **tol** – Tolerance for determining linear independence. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.RankReducePaths.__init__ "qiskit_noise_learning.experiment_builder.RankReducePaths.__init__")(\[tol]) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------ | - | + | `populates_fields` | | + | `required_fields` | | + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-spam-paths.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-spam-paths.mdx new file mode 100644 index 000000000000..21d4840f2066 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-spam-paths.mdx @@ -0,0 +1,42 @@ +--- +title: SPAMPaths (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.SPAMPaths in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.SPAMPaths +--- + + + +# qiskit\_noise\_learning.experiment\_builder.SPAMPaths + + + Bases: [`AddPaths`](experiment-builder-add-paths "qiskit_noise_learning.experiment_builder.stages.path_generators.add_paths.AddPaths") + + Generate depth-0 paths. + + **Parameters** + + * **prep\_gate** – The preparation gate. If `None`, defaults to the gate named `"P"`. + * **meas\_gate** – The measurement gate. If `None`, defaults to the gate named `"M"`. + * **indices\_list** – An iterable of qubit index lists. If `None`, generates single-qubit paths for every qubit. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.SPAMPaths.__init__ "qiskit_noise_learning.experiment_builder.SPAMPaths.__init__")(\*\[, prep\_gate, meas\_gate, indices\_list]) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------ | - | + | `populates_fields` | | + | `required_fields` | | + + diff --git a/docs/api/qiskit-noise-learning/generated/experiment-builder-vanilla-instruction-sequences.mdx b/docs/api/qiskit-noise-learning/generated/experiment-builder-vanilla-instruction-sequences.mdx new file mode 100644 index 000000000000..fdb871936526 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/experiment-builder-vanilla-instruction-sequences.mdx @@ -0,0 +1,58 @@ +--- +title: VanillaInstructionSequences (latest version) +description: API reference for qiskit_noise_learning.experiment_builder.VanillaInstructionSequences in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.experiment_builder.VanillaInstructionSequences +--- + + + +# qiskit\_noise\_learning.experiment\_builder.VanillaInstructionSequences + + + Bases: [`AddInstructionSequences`](experiment-builder-add-instruction-sequences "qiskit_noise_learning.experiment_builder.stages.sequence_generators.add_instruction_sequences.AddInstructionSequences") + + Generate vanilla instruction sequences for each target gate. + + For each gate, generates 9 instruction sequences sufficient to measure any single- and two-qubit Pauli fidelity on a triangle-free coupling map. + + **Parameters** + + * **prep\_gate** – The preparation gate. If `None`, defaults to the gate named `"P"`. + * **meas\_gate** – The measurement gate. If `None`, defaults to the gate named `"M"`. + * **gates** – Gates to generate sequences for. If `None`, defaults to all non-SPAM gates. + * **coupling\_map** – The coupling map. If `None`, defaults to the gate set’s coupling map. + * **randomization\_multiplier** – Randomization multiplier applied to all generated sequences. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.experiment_builder.VanillaInstructionSequences.__init__ "qiskit_noise_learning.experiment_builder.VanillaInstructionSequences.__init__")(\*\[, prep\_gate, meas\_gate, gates, ...]) | | + | `run`(experiment) | Validate required fields, then apply this stage. | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | + | `populates_fields` | | + | [`required_fields`](#qiskit_noise_learning.experiment_builder.VanillaInstructionSequences.required_fields "qiskit_noise_learning.experiment_builder.VanillaInstructionSequences.required_fields") | Built-in immutable sequence. | + + ### required\_fields + + + Type: [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), ...] + + Built-in immutable sequence. + + If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items. + + If the argument is a tuple, the return value is the same object. + + + diff --git a/docs/api/qiskit-noise-learning/generated/gate-sets-gate-set.mdx b/docs/api/qiskit-noise-learning/generated/gate-sets-gate-set.mdx new file mode 100644 index 000000000000..9315e604629e --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/gate-sets-gate-set.mdx @@ -0,0 +1,150 @@ +--- +title: GateSet (latest version) +description: API reference for qiskit_noise_learning.gate_sets.GateSet in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.gate_sets.GateSet +--- + + + +# qiskit\_noise\_learning.gate\_sets.GateSet + + + Bases: [`Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), `GateType`] + + A mapping of names to gates with qubit metadata. + + **Parameters** + + * **num\_qubits** – How many qubits the QPU of interest has. + * **qubit\_subset** – A subset of `range(num_qubits)` specifying the region of interest of the QPU. All gates added must act within this subset. By default, contains all qubits. + * **target** – An optional `Target` against which operations will be validated whenever gates are added to the gate set. Its number of qubits must match `num_qubits` if both are present. + * **name** – Name for this gate set. If `None`, [`name`](#qiskit_noise_learning.gate_sets.GateSet.name "qiskit_noise_learning.gate_sets.GateSet.name") falls back to the class name. + * **latex\_str** – An optional LaTeX string for rendering this gate set. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.gate_sets.GateSet.__init__ "qiskit_noise_learning.gate_sets.GateSet.__init__")(num\_qubits\[, qubit\_subset, target, ...]) | | + | [`add_gate`](#qiskit_noise_learning.gate_sets.GateSet.add_gate "qiskit_noise_learning.gate_sets.GateSet.add_gate")(gate) | Add a gate to the gate set. | + | [`draw`](#qiskit_noise_learning.gate_sets.GateSet.draw "qiskit_noise_learning.gate_sets.GateSet.draw")() | Draw the device topology with per-gate coloring. | + | `get`(k\[,d]) | | + | `items`() | | + | `keys`() | | + | `values`() | | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | + | [`label`](#qiskit_noise_learning.gate_sets.GateSet.label "qiskit_noise_learning.gate_sets.GateSet.label") | A string label for use in plotter legends. | + | [`latex_str`](#qiskit_noise_learning.gate_sets.GateSet.latex_str "qiskit_noise_learning.gate_sets.GateSet.latex_str") | A LaTeX string for this gate set. | + | [`math_label`](#qiskit_noise_learning.gate_sets.GateSet.math_label "qiskit_noise_learning.gate_sets.GateSet.math_label") | A string label for use within latex math mode. | + | [`model_gate_set`](#qiskit_noise_learning.gate_sets.GateSet.model_gate_set "qiskit_noise_learning.gate_sets.GateSet.model_gate_set") | Return a [`ModelGateSet`](gate-sets-model-gate-set "qiskit_noise_learning.gate_sets.ModelGateSet") representing this gate set. | + | [`name`](#qiskit_noise_learning.gate_sets.GateSet.name "qiskit_noise_learning.gate_sets.GateSet.name") | Name for this gate set, defaulting to the class name. | + | [`num_qubits`](#qiskit_noise_learning.gate_sets.GateSet.num_qubits "qiskit_noise_learning.gate_sets.GateSet.num_qubits") | The total number of qubits of the device this gateset acts on. | + | [`qubit_subset`](#qiskit_noise_learning.gate_sets.GateSet.qubit_subset "qiskit_noise_learning.gate_sets.GateSet.qubit_subset") | The indices of the subset of device qubits that all gates act on. | + | [`target`](#qiskit_noise_learning.gate_sets.GateSet.target "qiskit_noise_learning.gate_sets.GateSet.target") | The target of this gateset, if one exists. | + + ### model\_gate\_set + + + Type: [`ModelGateSet`](gate-sets-model-gate-set "qiskit_noise_learning.gate_sets.ModelGateSet") + + Return a [`ModelGateSet`](gate-sets-model-gate-set "qiskit_noise_learning.gate_sets.ModelGateSet") representing this gate set. + + + ### name + + + Type: [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + Name for this gate set, defaulting to the class name. + + + ### latex\_str + + + Type: [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + A LaTeX string for this gate set. + + + ### label + + + Type: [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + A string label for use in plotter legends. + + + ### math\_label + + + Type: [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + A string label for use within latex math mode. + + + ### num\_qubits + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + The total number of qubits of the device this gateset acts on. + + + ### qubit\_subset + + + Type: [`frozenset`](https://docs.python.org/3/library/stdtypes.html#frozenset)\[[`int`](https://docs.python.org/3/library/functions.html#int)] + + The indices of the subset of device qubits that all gates act on. + + + ### target + + + Type: [`Target`](/docs/api/qiskit/qiskit.transpiler.Target) | [`None`](https://docs.python.org/3/library/constants.html#None) + + The target of this gateset, if one exists. + + + ### add\_gate + + + Add a gate to the gate set. + + **Parameters** + + **gate** – The gate to add. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the gate acts on some qubits outside of the valid range, or if the gate name is already used in the gate set. + + + ### draw + + + Draw the device topology with per-gate coloring. + + Each gate’s 2-qubit interactions are drawn as colored edges on the device coupling graph. Gates that act only on single qubits (such as preparation and measurement) are shown as shaped markers on the relevant nodes. + + **Returns** + + The figure, with toggleable legends. + + **Raises** + + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If [`target`](#qiskit_noise_learning.gate_sets.GateSet.target "qiskit_noise_learning.gate_sets.GateSet.target") is `None`. + * [**ImportError**](https://docs.python.org/3/library/exceptions.html#ImportError) – If `matplotlib` is not installed. + + + diff --git a/docs/api/qiskit-noise-learning/generated/gate-sets-gate.mdx b/docs/api/qiskit-noise-learning/generated/gate-sets-gate.mdx new file mode 100644 index 000000000000..1c3cefc241ba --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/gate-sets-gate.mdx @@ -0,0 +1,171 @@ +--- +title: Gate (latest version) +description: API reference for qiskit_noise_learning.gate_sets.Gate in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.gate_sets.Gate +--- + + + +# qiskit\_noise\_learning.gate\_sets.Gate + + + Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC) + + Represents qubit metadata for a single gate in a gate set. + + Typically serves as a base class for types that implement non-trivial gates. + + **Parameters** + + * **name** – The gate name. + * **qubit\_idxs** – The physical qubit indices that the gate acts on. + * **prep\_idxs** – The physical qubit indices that this gate prepares, or resets to the 0 state. + * **meas\_idxs** – The physical qubit indices that this gate measures. + * **latex\_str** – An optional LaTeX string for rendering this gate. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------- | - | + | [`__init__`](#qiskit_noise_learning.gate_sets.Gate.__init__ "qiskit_noise_learning.gate_sets.Gate.__init__")(name, qubit\_idxs\[, prep\_idxs, ...]) | | + + ## Attributes + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | + | [`constituent_gate_idxs`](#qiskit_noise_learning.gate_sets.Gate.constituent_gate_idxs "qiskit_noise_learning.gate_sets.Gate.constituent_gate_idxs") | Iterator over tuples of physical indices that specify where constituent gates act. | + | [`gate_idxs`](#qiskit_noise_learning.gate_sets.Gate.gate_idxs "qiskit_noise_learning.gate_sets.Gate.gate_idxs") | The physical indices where this gate undergoes unitary action. | + | [`idling_idxs`](#qiskit_noise_learning.gate_sets.Gate.idling_idxs "qiskit_noise_learning.gate_sets.Gate.idling_idxs") | The physical qubit indices that this gate is idling on. | + | [`label`](#qiskit_noise_learning.gate_sets.Gate.label "qiskit_noise_learning.gate_sets.Gate.label") | A string label for use in plotter legends. | + | [`latex_str`](#qiskit_noise_learning.gate_sets.Gate.latex_str "qiskit_noise_learning.gate_sets.Gate.latex_str") | A LaTeX string for this gate. | + | [`math_label`](#qiskit_noise_learning.gate_sets.Gate.math_label "qiskit_noise_learning.gate_sets.Gate.math_label") | A string label for use within latex math mode. | + | [`meas_idxs`](#qiskit_noise_learning.gate_sets.Gate.meas_idxs "qiskit_noise_learning.gate_sets.Gate.meas_idxs") | The physical qubit indices that this gate measures. | + | [`model_gate`](#qiskit_noise_learning.gate_sets.Gate.model_gate "qiskit_noise_learning.gate_sets.Gate.model_gate") | Return a [`ModelGate`](gate-sets-model-gate "qiskit_noise_learning.gate_sets.ModelGate") representing this gate. | + | [`name`](#qiskit_noise_learning.gate_sets.Gate.name "qiskit_noise_learning.gate_sets.Gate.name") | The gate name. | + | [`num_qubits`](#qiskit_noise_learning.gate_sets.Gate.num_qubits "qiskit_noise_learning.gate_sets.Gate.num_qubits") | The number of qubits this gate acts on. | + | [`prep_idxs`](#qiskit_noise_learning.gate_sets.Gate.prep_idxs "qiskit_noise_learning.gate_sets.Gate.prep_idxs") | The physical qubit indices that this gate prepares (or resets). | + | [`qubit_idxs`](#qiskit_noise_learning.gate_sets.Gate.qubit_idxs "qiskit_noise_learning.gate_sets.Gate.qubit_idxs") | The physical qubit indices this gate acts on. | + | [`sorted_meas_idxs`](#qiskit_noise_learning.gate_sets.Gate.sorted_meas_idxs "qiskit_noise_learning.gate_sets.Gate.sorted_meas_idxs") | The indices of the measured qubits in increasing order. | + | [`sorted_prep_idxs`](#qiskit_noise_learning.gate_sets.Gate.sorted_prep_idxs "qiskit_noise_learning.gate_sets.Gate.sorted_prep_idxs") | The indices of the reset qubits in increasing order. | + + ### model\_gate + + + Type: [`ModelGate`](gate-sets-model-gate "qiskit_noise_learning.gate_sets.ModelGate") + + Return a [`ModelGate`](gate-sets-model-gate "qiskit_noise_learning.gate_sets.ModelGate") representing this gate. + + + ### name + + + Type: [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + The gate name. + + + ### latex\_str + + + Type: [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + A LaTeX string for this gate. + + + ### label + + + Type: [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + A string label for use in plotter legends. + + + ### math\_label + + + Type: [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + A string label for use within latex math mode. + + + ### num\_qubits + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + The number of qubits this gate acts on. + + + ### qubit\_idxs + + + Type: [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`int`](https://docs.python.org/3/library/functions.html#int), ...] + + The physical qubit indices this gate acts on. + + + ### meas\_idxs + + + Type: [`frozenset`](https://docs.python.org/3/library/stdtypes.html#frozenset)\[[`int`](https://docs.python.org/3/library/functions.html#int)] + + The physical qubit indices that this gate measures. + + + ### sorted\_meas\_idxs + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`int`](https://docs.python.org/3/library/functions.html#int)] + + The indices of the measured qubits in increasing order. + + + ### prep\_idxs + + + Type: [`frozenset`](https://docs.python.org/3/library/stdtypes.html#frozenset)\[[`int`](https://docs.python.org/3/library/functions.html#int)] + + The physical qubit indices that this gate prepares (or resets). + + + ### sorted\_prep\_idxs + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`int`](https://docs.python.org/3/library/functions.html#int)] + + The indices of the reset qubits in increasing order. + + + ### idling\_idxs + + + Type: [`set`](https://docs.python.org/3/library/stdtypes.html#set)\[[`int`](https://docs.python.org/3/library/functions.html#int)] + + The physical qubit indices that this gate is idling on. + + + ### gate\_idxs + + + Type: [`frozenset`](https://docs.python.org/3/library/stdtypes.html#frozenset)\[[`int`](https://docs.python.org/3/library/functions.html#int)] + + The physical indices where this gate undergoes unitary action. + + + ### constituent\_gate\_idxs + + + Type: [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)\[[`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`int`](https://docs.python.org/3/library/functions.html#int), ...]] + + Iterator over tuples of physical indices that specify where constituent gates act. + + Some subclasses may not have a meaningful notion of what a “constituent gate” is, because they don’t choose to represent unitary action by some seperable representation. The only contract they need to obey is that the union of all yielded integers is equal to [`gate_idxs`](#qiskit_noise_learning.gate_sets.Gate.gate_idxs "qiskit_noise_learning.gate_sets.Gate.gate_idxs"). + + + diff --git a/docs/api/qiskit-noise-learning/generated/gate-sets-model-gate-set.mdx b/docs/api/qiskit-noise-learning/generated/gate-sets-model-gate-set.mdx new file mode 100644 index 000000000000..9500cbc515e7 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/gate-sets-model-gate-set.mdx @@ -0,0 +1,72 @@ +--- +title: ModelGateSet (latest version) +description: API reference for qiskit_noise_learning.gate_sets.ModelGateSet in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.gate_sets.ModelGateSet +--- + + + +# qiskit\_noise\_learning.gate\_sets.ModelGateSet + + + Bases: [`GateSet`](gate-sets-gate-set "qiskit_noise_learning.gate_sets.gate_set.GateSet")\[[`ModelGate`](gate-sets-model-gate "qiskit_noise_learning.gate_sets.model_gate.ModelGate")] + + A set of Clifford - MCM - reset gates represented as [`ModelGate`](gate-sets-model-gate "qiskit_noise_learning.gate_sets.ModelGate") instances. + + **Parameters** + + * **num\_qubits** – How many qubits the QPU of interest has. + * **qubit\_subset** – A subset of `range(num_qubits)` specifying the region of interest of the QPU. All gates added must act within this subset. By default, contains all qubits. + * **coupling\_map** – A coupling map for the device. Defaults to the full coupling map on `num_qubits`. + * **name** – Name for this gate set. If `None`, `name` falls back to the class name. + * **latex\_str** – An optional LaTeX string for rendering this gate set. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.gate_sets.ModelGateSet.__init__ "qiskit_noise_learning.gate_sets.ModelGateSet.__init__")(num\_qubits, \*\[, qubit\_subset, ...]) | | + | `add_gate`(gate) | Add a gate to the gate set. | + | `draw`() | Draw the device topology with per-gate coloring. | + | `get`(k\[,d]) | | + | `items`() | | + | `keys`() | | + | `values`() | | + + ## Attributes + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | + | [`coupling_map`](#qiskit_noise_learning.gate_sets.ModelGateSet.coupling_map "qiskit_noise_learning.gate_sets.ModelGateSet.coupling_map") | The coupling map for the device this gate set is modeling. | + | `label` | A string label for use in plotter legends. | + | `latex_str` | A LaTeX string for this gate set. | + | `math_label` | A string label for use within latex math mode. | + | [`model_gate_set`](#qiskit_noise_learning.gate_sets.ModelGateSet.model_gate_set "qiskit_noise_learning.gate_sets.ModelGateSet.model_gate_set") | Return a [`ModelGateSet`](#qiskit_noise_learning.gate_sets.ModelGateSet "qiskit_noise_learning.gate_sets.ModelGateSet") representing this gate set. | + | `name` | Name for this gate set, defaulting to the class name. | + | `num_qubits` | The total number of qubits of the device this gateset acts on. | + | `qubit_subset` | The indices of the subset of device qubits that all gates act on. | + | `target` | The target of this gateset, if one exists. | + + ### coupling\_map + + + Type: [`CouplingMap`](/docs/api/qiskit/qiskit.transpiler.CouplingMap) + + The coupling map for the device this gate set is modeling. + + + ### model\_gate\_set + + + Type: [`Self`](https://docs.python.org/3/library/typing.html#typing.Self) + + Return a [`ModelGateSet`](#qiskit_noise_learning.gate_sets.ModelGateSet "qiskit_noise_learning.gate_sets.ModelGateSet") representing this gate set. + + + diff --git a/docs/api/qiskit-noise-learning/generated/gate-sets-model-gate.mdx b/docs/api/qiskit-noise-learning/generated/gate-sets-model-gate.mdx new file mode 100644 index 000000000000..5aa1fd210fe2 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/gate-sets-model-gate.mdx @@ -0,0 +1,124 @@ +--- +title: ModelGate (latest version) +description: API reference for qiskit_noise_learning.gate_sets.ModelGate in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.gate_sets.ModelGate +--- + + + +# qiskit\_noise\_learning.gate\_sets.ModelGate + + + Bases: [`Gate`](gate-sets-gate "qiskit_noise_learning.gate_sets.gate.Gate") + + A model for a gate of the form Clifford - MCM - reset. + + **Parameters** + + * **cliffords** – An iterable of tuples of physical qubit indices and `Clifford`s corresponding to the ideal Clifford layer. The order of the iterable should start with the first applied Clifford and proceed temporally, and `None` is interpreted as the identity. + * **qubit\_idxs** – The physical qubit indices. + * **meas\_idxs** – The physical qubit indices that this gate measures. + * **prep\_idxs** – The physical qubit indices that this gate prepares, or resets. + * **latex\_str** – An optional LaTeX string for rendering this gate. + + **Raises** + + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If both `cliffords` and `qubit_idxs` are not specified. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If any of the elements of `cliffords` have mismatched length of qubit indices and number of qubits of the Clifford. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.gate_sets.ModelGate.__init__ "qiskit_noise_learning.gate_sets.ModelGate.__init__")(name\[, cliffords, qubit\_idxs, ...]) | | + | [`clifford_propagate`](#qiskit_noise_learning.gate_sets.ModelGate.clifford_propagate "qiskit_noise_learning.gate_sets.ModelGate.clifford_propagate")(...) | Given a Pauli, propagate it through the ideal Clifford operation. | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | + | [`clifford`](#qiskit_noise_learning.gate_sets.ModelGate.clifford "qiskit_noise_learning.gate_sets.ModelGate.clifford") | The overall Clifford operation for this gate. | + | [`cliffords`](#qiskit_noise_learning.gate_sets.ModelGate.cliffords "qiskit_noise_learning.gate_sets.ModelGate.cliffords") | A list of tuples of qubit indices and a Clifford that acts on them. | + | [`constituent_gate_idxs`](#qiskit_noise_learning.gate_sets.ModelGate.constituent_gate_idxs "qiskit_noise_learning.gate_sets.ModelGate.constituent_gate_idxs") | Iterator over tuples of physical indices that specify where constituent gates act. | + | `gate_idxs` | The physical indices where this gate undergoes unitary action. | + | `idling_idxs` | The physical qubit indices that this gate is idling on. | + | `label` | A string label for use in plotter legends. | + | `latex_str` | A LaTeX string for this gate. | + | `math_label` | A string label for use within latex math mode. | + | `meas_idxs` | The physical qubit indices that this gate measures. | + | [`model_gate`](#qiskit_noise_learning.gate_sets.ModelGate.model_gate "qiskit_noise_learning.gate_sets.ModelGate.model_gate") | Return a [`ModelGate`](#qiskit_noise_learning.gate_sets.ModelGate "qiskit_noise_learning.gate_sets.ModelGate") representing this gate. | + | `name` | The gate name. | + | `num_qubits` | The number of qubits this gate acts on. | + | `prep_idxs` | The physical qubit indices that this gate prepares (or resets). | + | `qubit_idxs` | The physical qubit indices this gate acts on. | + | `sorted_meas_idxs` | The indices of the measured qubits in increasing order. | + | `sorted_prep_idxs` | The indices of the reset qubits in increasing order. | + + ### clifford + + + Type: [`Clifford`](/docs/api/qiskit/qiskit.quantum_info.Clifford) + + The overall Clifford operation for this gate. + + + ### cliffords + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`int`](https://docs.python.org/3/library/functions.html#int), ...], [`Clifford`](/docs/api/qiskit/qiskit.quantum_info.Clifford)]] + + A list of tuples of qubit indices and a Clifford that acts on them. + + The list is in temporal order. Each element contains the qubit indices that the corresponding Clifford acts on. + + + ### model\_gate + + + Type: [`Self`](https://docs.python.org/3/library/typing.html#typing.Self) + + Return a [`ModelGate`](#qiskit_noise_learning.gate_sets.ModelGate "qiskit_noise_learning.gate_sets.ModelGate") representing this gate. + + + ### constituent\_gate\_idxs + + + Type: [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)\[[`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`int`](https://docs.python.org/3/library/functions.html#int), ...]] + + Iterator over tuples of physical indices that specify where constituent gates act. + + Some subclasses may not have a meaningful notion of what a “constituent gate” is, because they don’t choose to represent unitary action by some seperable representation. The only contract they need to obey is that the union of all yielded integers is equal to [`gate_idxs`](gate-sets-gate#gate_idxs "qiskit_noise_learning.gate_sets.Gate.gate_idxs"). + + + ### clifford\_propagate + + + Given a Pauli, propagate it through the ideal Clifford operation. + + If `inverse == False` (the default), then this method returns $C P C^\dagger$, and otherwise returns $C^\dagger P C$. + + If the input is a phaseless Pauli type, the propagation will be phaseless. + + Note that the Clifford will be applied to on `self.qubit_idxs`. + + **Parameters** + + * **pauli** – The Pauli to propagate. + * **inverse** – Whether to apply the gate or its inverse. + + **Returns** + + The propagated result, which has the same type as the input. + + **Raises** + + [**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError) – If invalid type supplied. + + + diff --git a/docs/api/qiskit-noise-learning/generated/gate-sets-qiskit-gate-set.mdx b/docs/api/qiskit-noise-learning/generated/gate-sets-qiskit-gate-set.mdx new file mode 100644 index 000000000000..6eaa78d13ae6 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/gate-sets-qiskit-gate-set.mdx @@ -0,0 +1,256 @@ +--- +title: QiskitGateSet (latest version) +description: API reference for qiskit_noise_learning.gate_sets.QiskitGateSet in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.gate_sets.QiskitGateSet +--- + + + +# qiskit\_noise\_learning.gate\_sets.QiskitGateSet + + + Bases: [`GateSet`](gate-sets-gate-set "qiskit_noise_learning.gate_sets.gate_set.GateSet")\[[`QiskitGate`](gate-sets-qiskit-gate "qiskit_noise_learning.gate_sets.qiskit_gate.QiskitGate")] + + A gate set whose noise is to be learned and that is specified using Qiskit objects. + + Here, we are using “gate” in the context of noise learning, where our operations of interest are not typically the smallest operations that are discretely executed on a device (such as `cz` gates), but rather collections of such operations whose noise will be learned together as a unit. To the point, typically, in this class, gates are layers. They need not be however; partial width layers and layers with overlapping operations within are valid. We require this object to represent a set of them because in certain cases their noise needs to be learned together in order to have a consistent gauge defined between their noise models, or to allow parametrizations of their noise models to be correlated. + + This object satisfies the Python mapping protocol so that, for example, gates can be extracted with dictionary syntax. The names of gates are always strings. + + ```python + >>> from qiskit_noise_learning.gate_sets import QiskitGateSet + >>> from qiskit.circuit import QuantumCircuit + + >>> # instantiate a new gate set on 10 qubits + >>> gate_set = QiskitGateSet(10) + + >>> # the gate set comes populated with preparation and measurement gates on all 10 qubits + >>> assert len(gate_set) == 2 + >>> assert "P" in gate_set and "M" in gate_set + ``` + + **Parameters** + + * **num\_qubits** – How many qubits the QPU of interest has. If a `target` is provided, this field may be omitted. + * **target** – An optional `Target` against which operations will be validated whenever gates are added to the gate set. Its number of qubits must match `num_qubits` if both are present. + * **qubit\_subset** – A subset of `range(num_qubits)` specifying the region of interest of the QPU. All gates added must act within this subset. By default, contains all qubits. When `add_default_spam` is `True`, the iteration order of this argument determines the qubit ordering of the default preparation and measurement gates. + * **add\_default\_spam** – Whether to initialize the gateset with gates that respectively implement state preparation (given name `"P"`) and state measurement (given name `"M"`) on all qubits in the region of interest. + * **name** – Name for this gate set. If `None`, `name` falls back to the class name. + * **latex\_str** – An optional LaTeX string for rendering this gate set. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.gate_sets.QiskitGateSet.__init__ "qiskit_noise_learning.gate_sets.QiskitGateSet.__init__")(\[num\_qubits, target, qubit\_subset, ...]) | | + | [`add_box_as_gate`](#qiskit_noise_learning.gate_sets.QiskitGateSet.add_box_as_gate "qiskit_noise_learning.gate_sets.QiskitGateSet.add_box_as_gate")(box\_instr, \*\[, name, latex\_str]) | Add a Qiskit circuit instruction containing a box operation as a gate. | + | [`add_circuit_as_gate`](#qiskit_noise_learning.gate_sets.QiskitGateSet.add_circuit_as_gate "qiskit_noise_learning.gate_sets.QiskitGateSet.add_circuit_as_gate")(circuit\[, qubit\_idxs, ...]) | Add a quantum circuit object as a gate. | + | [`add_gate`](#qiskit_noise_learning.gate_sets.QiskitGateSet.add_gate "qiskit_noise_learning.gate_sets.QiskitGateSet.add_gate")(gate) | Add a gate to the gate set. | + | [`add_measurement`](#qiskit_noise_learning.gate_sets.QiskitGateSet.add_measurement "qiskit_noise_learning.gate_sets.QiskitGateSet.add_measurement")(qubit\_idxs, operation\_type, ...) | Add a gate to this gate set that measures specified qubits. | + | [`add_preparation`](#qiskit_noise_learning.gate_sets.QiskitGateSet.add_preparation "qiskit_noise_learning.gate_sets.QiskitGateSet.add_preparation")(\[qubit\_idxs, annotations, ...]) | Add a gate to this gate set that prepares (or resets) specified qubits. | + | [`build_new_gate`](#qiskit_noise_learning.gate_sets.QiskitGateSet.build_new_gate "qiskit_noise_learning.gate_sets.QiskitGateSet.build_new_gate")(\[name, idle\_unused, latex\_str]) | Return a circuit builder whose contents will be added as a gate. | + | `draw`() | Draw the device topology with per-gate coloring. | + | `get`(k\[,d]) | | + | `items`() | | + | `keys`() | | + | `values`() | | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- | + | `label` | A string label for use in plotter legends. | + | `latex_str` | A LaTeX string for this gate set. | + | `math_label` | A string label for use within latex math mode. | + | [`model_gate_set`](#qiskit_noise_learning.gate_sets.QiskitGateSet.model_gate_set "qiskit_noise_learning.gate_sets.QiskitGateSet.model_gate_set") | The model for this gate set. | + | `name` | Name for this gate set, defaulting to the class name. | + | `num_qubits` | The total number of qubits of the device this gateset acts on. | + | `qubit_subset` | The indices of the subset of device qubits that all gates act on. | + | [`target`](#qiskit_noise_learning.gate_sets.QiskitGateSet.target "qiskit_noise_learning.gate_sets.QiskitGateSet.target") | The target of this gateset, if one exists. | + + ### model\_gate\_set + + + Type: [`ModelGateSet`](gate-sets-model-gate-set "qiskit_noise_learning.gate_sets.model_gate_set.ModelGateSet") + + The model for this gate set. + + + ### target + + + Type: [`Target`](/docs/api/qiskit/qiskit.transpiler.Target) | [`None`](https://docs.python.org/3/library/constants.html#None) + + The target of this gateset, if one exists. + + + ### add\_gate + + + Add a gate to the gate set. + + ```python + >>> from qiskit_noise_learning.gate_sets import QiskitGateSet, QiskitGate + >>> from qiskit.circuit import QuantumCircuit + + >>> gate_set = QiskitGateSet(10) + >>> circuit = QuantumCircuit(5) + >>> circuit.cx(3, 4) + >>> gate_set.add_gate(QiskitGate("gate0", circuit, [4, 5, 7, 8, 9])) + + >>> assert "gate0" in gate_set + ``` + + **Parameters** + + **gate** – The gate to add. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the gate acts on some qubits outside of the valid range, or this gate set has a target and some member of the gate does not comply, or if the name is already used in the gate set. + + + ### add\_box\_as\_gate + + + Add a Qiskit circuit instruction containing a box operation as a gate. + + ```python + >>> from qiskit_noise_learning.gate_sets import QiskitGateSet, QiskitGate + >>> from qiskit.circuit import QuantumCircuit + + >>> gate_set = QiskitGateSet(10) + >>> circuit = QuantumCircuit(10) + >>> with circuit.box(): + ... circuit.cx(3, 4) + ... # use noop to indicate that only the first 7 qubits will be part of the gate, + ... # otherwise it would be restricted to only qubits 3 and 4, and learned noise + ... # will only be with respect to those two qubits + ... circuit.noop(range(7)) + + >>> name = gate_set.add_box_as_gate(circuit[0]) + + >>> assert name in gate_set + ``` + + **Parameters** + + * **box\_instr** – The circuit instruction containing a box operation. + * **name** – The name of the gate, or `None` to have a name chosen for you. + * **latex\_str** – An optional LaTeX string for this gate. + + **Returns** + + The name of the added gate. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the provided instruction does not contain a [`qiskit.circuit.BoxOp`](/docs/api/qiskit/qiskit.circuit.BoxOp) operation, or if the instruction acts on non-physical qubits. + + + ### add\_circuit\_as\_gate + + + Add a quantum circuit object as a gate. + + This method is a thin wrapper for [`add_gate()`](#qiskit_noise_learning.gate_sets.QiskitGateSet.add_gate "qiskit_noise_learning.gate_sets.QiskitGateSet.add_gate") that constructs a [`QiskitGate`](gate-sets-qiskit-gate "qiskit_noise_learning.gate_sets.QiskitGate") for you. + + ```python + >>> from qiskit_noise_learning.gate_sets import QiskitGateSet, QiskitGate + >>> from qiskit.circuit import QuantumCircuit + + >>> gate_set = QiskitGateSet(10) + >>> circuit = QuantumCircuit(5) + >>> circuit.cx(3, 4) + >>> name = gate_set.add_circuit_as_gate(circuit, [4, 5, 7, 8, 9]) + + >>> assert name in gate_set + ``` + + + The `circuit.qubits` are completely irrelevant and do not, for example, represent physical qubits. Instead, the mapping `dict(zip(circuit.qubits, qubit_idxs))` provides the recipe for which physical qubits each qubit in the circuit corresponds to. + + + **Parameters** + + * **circuit** – The circuit to use as a gate. + * **qubit\_idxs** – The physical qubits on which the circuit acts. + * **annotations** – The annotations that describe how to implement the circuit, or `None` to use the default annotations of [`QiskitGate`](gate-sets-qiskit-gate "qiskit_noise_learning.gate_sets.QiskitGate"). + * **name** – The name of the gate, or `None` to have a name chosen for you. + * **latex\_str** – An optional LaTeX string for this gate. + + **Returns** + + The name of the added gate. + + + ### build\_new\_gate + + + Return a circuit builder whose contents will be added as a gate. + + ```python + >>> from qiskit_noise_learning.gate_sets import QiskitGateSet, QiskitGate + >>> from qiskit.circuit import QuantumCircuit + + >>> gate_set = QiskitGateSet(10) + >>> with gate_set.build_new_gate() as builder: + ... builder.circuit.cx(4, 5) + + >>> assert builder.name in gate_set + >>> assert set(gate_set[builder.name].qubit_idxs) == set(range(10)) + ``` + + **Parameters** + + * **name** – The name of the gate, or `None` to have a name chosen for you. + * **idle\_unused** – Whether all qubits in [`qubit_subset`](gate-sets-gate-set#qubit_subset "qiskit_noise_learning.gate_sets.GateSet.qubit_subset") that are not already part of the gate will be automatically included as idling qubits. + * **latex\_str** – An optional LaTeX string for this gate. + + **Returns** + + A circuit builder. + + + ### add\_measurement + + + Add a gate to this gate set that measures specified qubits. + + **Parameters** + + * **qubit\_idxs** – The physical qubit indices to measure. + * **operation\_type** – The type of measurement operation to apply on each qubit. + * **annotations** – The annotations that describe how to implement the measurement, or `None` to use the default annotations of [`QiskitGate`](gate-sets-qiskit-gate "qiskit_noise_learning.gate_sets.QiskitGate"). + * **name** – The name of the gate, or `None` to have a name chosen for you. + * **latex\_str** – An optional LaTeX string for this gate. + + **Returns** + + The name of the added gate. + + + ### add\_preparation + + + Add a gate to this gate set that prepares (or resets) specified qubits. + + **Parameters** + + * **qubit\_idxs** – The physical qubit indices to prepare. + * **annotations** – The annotations that describe how to implement the preparation, or `None` to use the default annotations of [`QiskitGate`](gate-sets-qiskit-gate "qiskit_noise_learning.gate_sets.QiskitGate"). + * **name** – The name of the gate, or `None` to have a name chosen for you. + * **latex\_str** – An optional LaTeX string for this gate. + + **Returns** + + The name of the added gate. + + + diff --git a/docs/api/qiskit-noise-learning/generated/gate-sets-qiskit-gate.mdx b/docs/api/qiskit-noise-learning/generated/gate-sets-qiskit-gate.mdx new file mode 100644 index 000000000000..b04560807666 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/gate-sets-qiskit-gate.mdx @@ -0,0 +1,131 @@ +--- +title: QiskitGate (latest version) +description: API reference for qiskit_noise_learning.gate_sets.QiskitGate in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.gate_sets.QiskitGate +--- + + + +# qiskit\_noise\_learning.gate\_sets.QiskitGate + + + Bases: [`Gate`](gate-sets-gate "qiskit_noise_learning.gate_sets.gate.Gate") + + Represents a single gate in a [`QiskitGateSet`](gate-sets-qiskit-gate-set "qiskit_noise_learning.gate_sets.QiskitGateSet"). + + It is assumed that the gate consists of a sequence of unitary operations, followed by measurements, with no qubit being measured more than once, and finally preparations or resets. This is not currently validated. + + In many ways, this class is similar to a [`CircuitInstruction`](/docs/api/qiskit/qiskit.circuit.CircuitInstruction) containing a [`BoxOp`](/docs/api/qiskit/qiskit.circuit.BoxOp) in that it represents the action on some subset of qubits, and possibly with some of those qubits idling. It differs in that the physical qubits are represented as integers rather than [`Qubit`](/docs/api/qiskit/circuit#qiskit.circuit.Qubit) objects, and that we explicitly store which physical qubit indices perform preparation (or reset) operations. + + This class also implements the equality operation, where two [`QiskitGate`](#qiskit_noise_learning.gate_sets.QiskitGate "qiskit_noise_learning.gate_sets.QiskitGate") instances are equal whenever their physical indices are equal, and their circuits are equal taking into account permutations of the lists `qubit_idxs` and `circuit.qubits`. + + **Parameters** + + * **name** – The name for the gate. + * **circuit** – The quantum circuit. + * **qubit\_idxs** – The physical qubit indices that `circuit.qubits` act on. + * **prep\_idxs** – The physical qubit indices that this gate prepares, or resets. This is included because explicitly using the `Reset` instruction is not common. + * **annotations** – The annotations that describe how to implement the gate. If `None`, this defaults to Pauli twirling. If no `samplomatic.Tag` annotation is provided, then one is added automatically whose tag name is equal to `name`. + * **latex\_str** – An optional LaTeX string for this gate. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.gate_sets.QiskitGate.__init__ "qiskit_noise_learning.gate_sets.QiskitGate.__init__")(name, circuit, qubit\_idxs\[, ...]) | | + | [`draw`](#qiskit_noise_learning.gate_sets.QiskitGate.draw "qiskit_noise_learning.gate_sets.QiskitGate.draw")(\*args, \*\*kwargs) | Draw this gate as a circuit diagram. | + | [`iter_ops`](#qiskit_noise_learning.gate_sets.QiskitGate.iter_ops "qiskit_noise_learning.gate_sets.QiskitGate.iter_ops")() | Iterate through the operations that compose this gate in circuit order. | + + ## Attributes + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | + | [`annotations`](#qiskit_noise_learning.gate_sets.QiskitGate.annotations "qiskit_noise_learning.gate_sets.QiskitGate.annotations") | The annotations to use with this gate. | + | [`circuit`](#qiskit_noise_learning.gate_sets.QiskitGate.circuit "qiskit_noise_learning.gate_sets.QiskitGate.circuit") | A circuit representation of this gate. | + | [`constituent_gate_idxs`](#qiskit_noise_learning.gate_sets.QiskitGate.constituent_gate_idxs "qiskit_noise_learning.gate_sets.QiskitGate.constituent_gate_idxs") | Iterator over tuples of physical indices that specify where constituent gates act. | + | `gate_idxs` | The physical indices where this gate undergoes unitary action. | + | `idling_idxs` | The physical qubit indices that this gate is idling on. | + | `label` | A string label for use in plotter legends. | + | `latex_str` | A LaTeX string for this gate. | + | `math_label` | A string label for use within latex math mode. | + | `meas_idxs` | The physical qubit indices that this gate measures. | + | [`model_gate`](#qiskit_noise_learning.gate_sets.QiskitGate.model_gate "qiskit_noise_learning.gate_sets.QiskitGate.model_gate") | The model for this gate. | + | `name` | The gate name. | + | `num_qubits` | The number of qubits this gate acts on. | + | `prep_idxs` | The physical qubit indices that this gate prepares (or resets). | + | `qubit_idxs` | The physical qubit indices this gate acts on. | + | `sorted_meas_idxs` | The indices of the measured qubits in increasing order. | + | `sorted_prep_idxs` | The indices of the reset qubits in increasing order. | + + ### circuit + + + Type: [`QuantumCircuit`](/docs/api/qiskit/qiskit.circuit.QuantumCircuit) + + A circuit representation of this gate. + + + The `circuit.qubits` are completely irrelevant and do not, for example, represent physical qubits. Instead, the mappnig `dict(zip(circuit.qubits, qubit_idxs))` provides the recipe for which physical qubits each qubit in the circuit corresponds to. See also [`iter_ops()`](#qiskit_noise_learning.gate_sets.QiskitGate.iter_ops "qiskit_noise_learning.gate_sets.QiskitGate.iter_ops"). + + + + ### annotations + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`Annotation`](/docs/api/qiskit/qiskit.circuit.Annotation)] + + The annotations to use with this gate. + + + ### constituent\_gate\_idxs + + + Type: [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)\[[`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`int`](https://docs.python.org/3/library/functions.html#int), ...]] + + Iterator over tuples of physical indices that specify where constituent gates act. + + Some subclasses may not have a meaningful notion of what a “constituent gate” is, because they don’t choose to represent unitary action by some seperable representation. The only contract they need to obey is that the union of all yielded integers is equal to [`gate_idxs`](gate-sets-gate#gate_idxs "qiskit_noise_learning.gate_sets.Gate.gate_idxs"). + + + ### iter\_ops + + + Iterate through the operations that compose this gate in circuit order. + + **Yields** + + Tuples `(physical_qubits, operation)` for each instruction in [`circuit`](#qiskit_noise_learning.gate_sets.QiskitGate.circuit "qiskit_noise_learning.gate_sets.QiskitGate.circuit"). + + + ### model\_gate + + + Type: [`ModelGate`](gate-sets-model-gate "qiskit_noise_learning.gate_sets.model_gate.ModelGate") + + The model for this gate. + + + ### draw + + + Draw this gate as a circuit diagram. + + Wire labels display the mapping from virtual qubit indices (the circuit’s qubit ordering) to physical qubit indices, using the Qiskit `TranspileLayout` convention, e.g. `v_0 -> 5`. + + **Parameters** + + * **\*args** – Positional keyword arguments forwarded to [`draw()`](/docs/api/qiskit/qiskit.circuit.QuantumCircuit#draw). + * **\*\*kwargs** – Keyword arguments forwarded to [`draw()`](/docs/api/qiskit/qiskit.circuit.QuantumCircuit#draw). + + **Returns** + + Text, matplotlib figure, or latex depending on the `output` kwarg. + + + diff --git a/docs/api/qiskit-noise-learning/generated/math-composed-linear-map.mdx b/docs/api/qiskit-noise-learning/generated/math-composed-linear-map.mdx new file mode 100644 index 000000000000..20e141f4df32 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/math-composed-linear-map.mdx @@ -0,0 +1,81 @@ +--- +title: ComposedLinearMap (latest version) +description: API reference for qiskit_noise_learning.math.ComposedLinearMap in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.math.ComposedLinearMap +--- + + + +# qiskit\_noise\_learning.math.ComposedLinearMap + + + Bases: [`LinearMap`](math-linear-map "qiskit_noise_learning.math.linear_map.LinearMap")\[`InputIndex`, `OutputIndex`] + + A linear map formed by composing a chain of maps. + + Maps are stored in application order: `maps[0]` is applied first (innermost), `maps[-1]` is applied last (outermost). + + **Parameters** + + **maps** – The ordered sequence of maps to compose. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.math.ComposedLinearMap.__init__ "qiskit_noise_learning.math.ComposedLinearMap.__init__")(maps) | | + | [`compose`](#qiskit_noise_learning.math.ComposedLinearMap.compose "qiskit_noise_learning.math.ComposedLinearMap.compose")(outer) | Post-compose: self maps I->O, outer maps O->C, result maps I->C. | + | `left_multiply`(matrix) | Multiply on the left by an explicit matrix. | + | [`pre_compose`](#qiskit_noise_learning.math.ComposedLinearMap.pre_compose "qiskit_noise_learning.math.ComposedLinearMap.pre_compose")(inner) | Pre-compose: inner maps A->I, self maps I->O, result maps A->O. | + | `projected_output`(output\_indices, vector) | Compute a projection of the map applied to a vector. | + | [`rows`](#qiskit_noise_learning.math.ComposedLinearMap.rows "qiskit_noise_learning.math.ComposedLinearMap.rows")(output\_indices) | Construct the sub-matrix whose rows are the given output indices. | + + ## Attributes + + | | | + | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | + | `input_space` | The input space. | + | [`maps`](#qiskit_noise_learning.math.ComposedLinearMap.maps "qiskit_noise_learning.math.ComposedLinearMap.maps") | The ordered list of maps in application order. | + | `output_space` | The output space. | + + ### maps + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`LinearMap`](math-linear-map "qiskit_noise_learning.math.linear_map.LinearMap")] + + The ordered list of maps in application order. + + + ### rows + + + Construct the sub-matrix whose rows are the given output indices. + + **Parameters** + + **output\_indices** – The labels for the desired rows of the matrix. + + **Returns** + + [`IndexedMatrix`](math-indexed-matrix "qiskit_noise_learning.math.IndexedMatrix") + + + ### compose + + + Post-compose: self maps I->O, outer maps O->C, result maps I->C. + + + ### pre\_compose + + + Pre-compose: inner maps A->I, self maps I->O, result maps A->O. + + + diff --git a/docs/api/qiskit-noise-learning/generated/math-enumerated-indexed-space.mdx b/docs/api/qiskit-noise-learning/generated/math-enumerated-indexed-space.mdx new file mode 100644 index 000000000000..8a4609e37022 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/math-enumerated-indexed-space.mdx @@ -0,0 +1,48 @@ +--- +title: EnumeratedIndexedSpace (latest version) +description: API reference for qiskit_noise_learning.math.EnumeratedIndexedSpace in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.math.EnumeratedIndexedSpace +--- + + + +# qiskit\_noise\_learning.math.EnumeratedIndexedSpace + + + Bases: [`IndexedSpace`](math-indexed-space "qiskit_noise_learning.math.indexed_space.IndexedSpace")\[`Index`] + + An indexed space backed by an explicit finite collection of indices. + + **Parameters** + + **indices** – The collection of valid indices in this space. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------------- | - | + | [`__init__`](#qiskit_noise_learning.math.EnumeratedIndexedSpace.__init__ "qiskit_noise_learning.math.EnumeratedIndexedSpace.__init__")(indices) | | + + ## Attributes + + | | | + | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | + | [`dim`](#qiskit_noise_learning.math.EnumeratedIndexedSpace.dim "qiskit_noise_learning.math.EnumeratedIndexedSpace.dim") | The dimension (cardinality) of the space. | + + ### dim + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + The dimension (cardinality) of the space. + + May be `math.inf` for infinite-dimensional spaces. + + + diff --git a/docs/api/qiskit-noise-learning/generated/math-indexed-matrix.mdx b/docs/api/qiskit-noise-learning/generated/math-indexed-matrix.mdx new file mode 100644 index 000000000000..2f18c5726187 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/math-indexed-matrix.mdx @@ -0,0 +1,160 @@ +--- +title: IndexedMatrix (latest version) +description: API reference for qiskit_noise_learning.math.IndexedMatrix in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.math.IndexedMatrix +--- + + + +# qiskit\_noise\_learning.math.IndexedMatrix + + + Bases: [`Generic`](https://docs.python.org/3/library/typing.html#typing.Generic)\[`RowIndex`, `ColumnIndex`] + + A matrix with float entries and arbitrary row and column index data. + + **Parameters** + + * **row\_index\_map** – A mapping from row indices to the integer row axes of `data`. + * **column\_index\_map** – A mapping from column indices to the integer column axes of `data`. + * **data** – The array for the given row and column indices. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the shape of `data` is inconsistent with the values of `row_index_map` or `column_index_map`. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.math.IndexedMatrix.__init__ "qiskit_noise_learning.math.IndexedMatrix.__init__")(\[row\_index\_map, column\_index\_map, data]) | | + | [`add_rows`](#qiskit_noise_learning.math.IndexedMatrix.add_rows "qiskit_noise_learning.math.IndexedMatrix.add_rows")(row\_indices, rows\[, tol]) | Add rows to the matrix. | + | [`copy`](#qiskit_noise_learning.math.IndexedMatrix.copy "qiskit_noise_learning.math.IndexedMatrix.copy")() | Return a copy of self. | + | [`from_index_lists`](#qiskit_noise_learning.math.IndexedMatrix.from_index_lists "qiskit_noise_learning.math.IndexedMatrix.from_index_lists")(row\_indices, ...) | Construct from ordered lists of row and column indices. | + | [`from_rows`](#qiskit_noise_learning.math.IndexedMatrix.from_rows "qiskit_noise_learning.math.IndexedMatrix.from_rows")(row\_indices, rows\[, tol]) | Construct from row indices and their sparse [`IndexedVector`](math-indexed-vector "qiskit_noise_learning.math.IndexedVector") rows. | + | [`linearly_independent_rows`](#qiskit_noise_learning.math.IndexedMatrix.linearly_independent_rows "qiskit_noise_learning.math.IndexedMatrix.linearly_independent_rows")(\[tol]) | Return a submatrix containing a maximal set of linearly independent rows. | + + ## Attributes + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | + | [`column_index_map`](#qiskit_noise_learning.math.IndexedMatrix.column_index_map "qiskit_noise_learning.math.IndexedMatrix.column_index_map") | Dictionary mapping column indices to the column axis integer of `self.data`. | + | [`data`](#qiskit_noise_learning.math.IndexedMatrix.data "qiskit_noise_learning.math.IndexedMatrix.data") | The numerical data. | + | [`rank`](#qiskit_noise_learning.math.IndexedMatrix.rank "qiskit_noise_learning.math.IndexedMatrix.rank") | The rank of the matrix. | + | [`row_index_map`](#qiskit_noise_learning.math.IndexedMatrix.row_index_map "qiskit_noise_learning.math.IndexedMatrix.row_index_map") | Dictionary mapping row indices to the row axis integer of `self.data`. | + | [`shape`](#qiskit_noise_learning.math.IndexedMatrix.shape "qiskit_noise_learning.math.IndexedMatrix.shape") | The shape of the matrix. | + + ### from\_index\_lists + + + Construct from ordered lists of row and column indices. + + **Parameters** + + * **row\_indices** – The list of row indices for the row axes of `data`. + * **column\_indices** – The list of column indices for the column axes of `data`. + * **data** – The data matrix. + + **Returns** + + An [`IndexedMatrix`](#qiskit_noise_learning.math.IndexedMatrix "qiskit_noise_learning.math.IndexedMatrix") whose row and column index maps are built from `row_indices` and `column_indices`. + + + ### from\_rows + + + Construct from row indices and their sparse [`IndexedVector`](math-indexed-vector "qiskit_noise_learning.math.IndexedVector") rows. + + **Parameters** + + * **row\_indices** – The index for each row. + * **rows** – The sparse rows, as [`IndexedVector`](math-indexed-vector "qiskit_noise_learning.math.IndexedVector") instances. + * **tol** – Tolerance below which row values are treated as `0.0`. + + **Returns** + + An [`IndexedMatrix`](#qiskit_noise_learning.math.IndexedMatrix "qiskit_noise_learning.math.IndexedMatrix") containing the (non-zero) rows. + + + ### row\_index\_map + + + Type: [`dict`](https://docs.python.org/3/library/stdtypes.html#dict)\[`RowIndex`, [`int`](https://docs.python.org/3/library/functions.html#int)] + + Dictionary mapping row indices to the row axis integer of `self.data`. + + + ### column\_index\_map + + + Type: [`dict`](https://docs.python.org/3/library/stdtypes.html#dict)\[`ColumnIndex`, [`int`](https://docs.python.org/3/library/functions.html#int)] + + Dictionary mapping column indices to the column axis integer of `self.data`. + + + ### data + + + Type: [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)\[[`float`](https://docs.python.org/3/library/functions.html#float)] + + The numerical data. + + + ### shape + + + Type: [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`int`](https://docs.python.org/3/library/functions.html#int), [`int`](https://docs.python.org/3/library/functions.html#int)] + + The shape of the matrix. + + + ### rank + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + The rank of the matrix. + + + ### add\_rows + + + Add rows to the matrix. + + **Parameters** + + * **row\_indices** – A list of indices for the rows. + * **rows** – The list of rows. + * **tol** – Tolerance below which values in `rows` are assumed to be `0.0`. + + **Raises** + + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If any row index is duplicated in `row_indices` or is already present in this instance. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the number of row indices does not match the number of rows. + + + ### linearly\_independent\_rows + + + Return a submatrix containing a maximal set of linearly independent rows. + + Rows are processed in order (according to the indices in `self.row_index_map`): a row is kept if and only if it is linearly independent of all preceding kept rows. This guarantees earlier rows are always preferred. + + **Parameters** + + **tol** – The tolerance for determining linear independence based on the norm of the component of a row orthogonal to the span of preceding kept rows. + + + ### copy + + + Return a copy of self. + + + diff --git a/docs/api/qiskit-noise-learning/generated/math-indexed-space.mdx b/docs/api/qiskit-noise-learning/generated/math-indexed-space.mdx new file mode 100644 index 000000000000..6ab8ea2b6a24 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/math-indexed-space.mdx @@ -0,0 +1,44 @@ +--- +title: IndexedSpace (latest version) +description: API reference for qiskit_noise_learning.math.IndexedSpace in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.math.IndexedSpace +--- + + + +# qiskit\_noise\_learning.math.IndexedSpace + + + Bases: [`Generic`](https://docs.python.org/3/library/typing.html#typing.Generic)\[`Index`], [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC) + + Abstract description of a vector space with arbitrary basis index types. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------- | - | + | [`__init__`](#qiskit_noise_learning.math.IndexedSpace.__init__ "qiskit_noise_learning.math.IndexedSpace.__init__")() | | + + ## Attributes + + | | | + | --------------------------------------------------------------------------------------------------- | ----------------------------------------- | + | [`dim`](#qiskit_noise_learning.math.IndexedSpace.dim "qiskit_noise_learning.math.IndexedSpace.dim") | The dimension (cardinality) of the space. | + + ### dim + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) | [`float`](https://docs.python.org/3/library/functions.html#float) + + The dimension (cardinality) of the space. + + May be `math.inf` for infinite-dimensional spaces. + + + diff --git a/docs/api/qiskit-noise-learning/generated/math-indexed-vector.mdx b/docs/api/qiskit-noise-learning/generated/math-indexed-vector.mdx new file mode 100644 index 000000000000..dbe74e7e505e --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/math-indexed-vector.mdx @@ -0,0 +1,53 @@ +--- +title: IndexedVector (latest version) +description: API reference for qiskit_noise_learning.math.IndexedVector in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.math.IndexedVector +--- + + + +# qiskit\_noise\_learning.math.IndexedVector + + + Bases: [`dict`](https://docs.python.org/3/library/stdtypes.html#dict)\[`Index`, [`float`](https://docs.python.org/3/library/functions.html#float)] + + A vector of floats with arbitrary index, or axis label, data. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.math.IndexedVector.__init__ "qiskit_noise_learning.math.IndexedVector.__init__")(\*args, \*\*kwargs) | | + | [`add`](#qiskit_noise_learning.math.IndexedVector.add "qiskit_noise_learning.math.IndexedVector.add")(other) | Return a new indexed vector that is the sum of self and other. | + | `clear`() | | + | `copy`() | | + | `fromkeys`(iterable\[, value]) | Create a new dictionary with keys from iterable and values set to value. | + | `get`(key\[, default]) | Return the value for key if key is in the dictionary, else default. | + | `items`() | | + | `keys`() | | + | [`mul`](#qiskit_noise_learning.math.IndexedVector.mul "qiskit_noise_learning.math.IndexedVector.mul")(const) | Return a new indexed vector by multipling self with a constant. | + | `pop`(k\[,d]) | If the key is not found, return the default if given; otherwise, raise a KeyError. | + | `popitem`() | Remove and return a (key, value) pair as a 2-tuple. | + | `setdefault`(key\[, default]) | Insert key with a value of default if key is not in the dictionary. | + | `update`(\[E, ]\*\*F) | If E is present and has a .keys() method, then does: for k in E.keys(): D\[k] = E\[k] If E is present and lacks a .keys() method, then does: for k, v in E: D\[k] = v In either case, this is followed by: for k in F: D\[k] = F\[k] | + | `values`() | | + + ### add + + + Return a new indexed vector that is the sum of self and other. + + + ### mul + + + Return a new indexed vector by multipling self with a constant. + + + diff --git a/docs/api/qiskit-noise-learning/generated/math-linear-map.mdx b/docs/api/qiskit-noise-learning/generated/math-linear-map.mdx new file mode 100644 index 000000000000..c65ca3374a85 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/math-linear-map.mdx @@ -0,0 +1,122 @@ +--- +title: LinearMap (latest version) +description: API reference for qiskit_noise_learning.math.LinearMap in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.math.LinearMap +--- + + + +# qiskit\_noise\_learning.math.LinearMap + + + Bases: [`Generic`](https://docs.python.org/3/library/typing.html#typing.Generic)\[`InputIndex`, `OutputIndex`], [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC) + + An implicit linear map between two indexed spaces. + + **Parameters** + + * **input\_space** – The input space. + * **output\_space** – The output space. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.math.LinearMap.__init__ "qiskit_noise_learning.math.LinearMap.__init__")(input\_space, output\_space) | | + | [`compose`](#qiskit_noise_learning.math.LinearMap.compose "qiskit_noise_learning.math.LinearMap.compose")(outer) | Post-compose: self maps I->O, outer maps O->C, result maps I->C. | + | [`left_multiply`](#qiskit_noise_learning.math.LinearMap.left_multiply "qiskit_noise_learning.math.LinearMap.left_multiply")(matrix) | Multiply on the left by an explicit matrix. | + | [`pre_compose`](#qiskit_noise_learning.math.LinearMap.pre_compose "qiskit_noise_learning.math.LinearMap.pre_compose")(inner) | Pre-compose: inner maps A->I, self maps I->O, result maps A->O. | + | [`projected_output`](#qiskit_noise_learning.math.LinearMap.projected_output "qiskit_noise_learning.math.LinearMap.projected_output")(output\_indices, vector) | Compute a projection of the map applied to a vector. | + | [`rows`](#qiskit_noise_learning.math.LinearMap.rows "qiskit_noise_learning.math.LinearMap.rows")(output\_indices) | Construct the sub-matrix whose rows are the given output indices. | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------ | ----------------- | + | [`input_space`](#qiskit_noise_learning.math.LinearMap.input_space "qiskit_noise_learning.math.LinearMap.input_space") | The input space. | + | [`output_space`](#qiskit_noise_learning.math.LinearMap.output_space "qiskit_noise_learning.math.LinearMap.output_space") | The output space. | + + ### input\_space + + + Type: [`IndexedSpace`](math-indexed-space "qiskit_noise_learning.math.indexed_space.IndexedSpace")\[`InputIndex`] + + The input space. + + + ### output\_space + + + Type: [`IndexedSpace`](math-indexed-space "qiskit_noise_learning.math.indexed_space.IndexedSpace")\[`OutputIndex`] + + The output space. + + + ### rows + + + Construct the sub-matrix whose rows are the given output indices. + + **Parameters** + + **output\_indices** – The labels for the desired rows of the matrix. + + **Returns** + + [`IndexedMatrix`](math-indexed-matrix "qiskit_noise_learning.math.IndexedMatrix") + + + ### left\_multiply + + + Multiply on the left by an explicit matrix. + + **Parameters** + + **matrix** – A matrix whose column indices are output indices of this map. + + **Returns** + + The resulting matrix. + + + ### projected\_output + + + Compute a projection of the map applied to a vector. + + The projection is defined by an iterable of output indices: only the component of the vector on those output indices will be returned. + + **Parameters** + + * **output\_indices** – The output indices defining the projection. + * **vector** – A mapping from input indices to floats. + + **Returns** + + The projected output vector. + + **Raises** + + [**KeyError**](https://docs.python.org/3/library/exceptions.html#KeyError) – If an input index appearing in the rows is not present in `vector`. + + + ### compose + + + Post-compose: self maps I->O, outer maps O->C, result maps I->C. + + + ### pre\_compose + + + Pre-compose: inner maps A->I, self maps I->O, result maps A->O. + + + diff --git a/docs/api/qiskit-noise-learning/generated/models-contains-pauli-lindblad-model.mdx b/docs/api/qiskit-noise-learning/generated/models-contains-pauli-lindblad-model.mdx new file mode 100644 index 000000000000..f08982ad3846 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/models-contains-pauli-lindblad-model.mdx @@ -0,0 +1,24 @@ +--- +title: contains_pauli_lindblad_model (latest version) +description: API reference for qiskit_noise_learning.models.contains_pauli_lindblad_model in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: function +python_api_name: qiskit_noise_learning.models.contains_pauli_lindblad_model +--- + + + +# qiskit\_noise\_learning.models.contains\_pauli\_lindblad\_model + + + Whether a map is, or contains, a [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"). + + **Parameters** + + **model** – The map to inspect. + + **Returns** + + `True` if `model` is a [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel") or a [`ComposedLinearMap`](math-composed-linear-map "qiskit_noise_learning.math.ComposedLinearMap") whose chain contains one. + + diff --git a/docs/api/qiskit-noise-learning/generated/models-generator-index.mdx b/docs/api/qiskit-noise-learning/generated/models-generator-index.mdx new file mode 100644 index 000000000000..be6342642b78 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/models-generator-index.mdx @@ -0,0 +1,30 @@ +--- +title: Qiskit noise learning API documentation (latest version) +description: Index of all the modules in the latest version of qiskit-noise-learning. +--- + + + +# qiskit\_noise\_learning.models.GeneratorIndex + + + Bases: [`object`](https://docs.python.org/3/library/functions.html#object) + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------- | - | + | [`__init__`](#qiskit_noise_learning.models.GeneratorIndex.__init__ "qiskit_noise_learning.models.GeneratorIndex.__init__")(gate\_name, generator) | | + + ## Attributes + + | | | + | ----------- | - | + | `gate_name` | | + | `generator` | | + + diff --git a/docs/api/qiskit-noise-learning/generated/models-get-noise-site.mdx b/docs/api/qiskit-noise-learning/generated/models-get-noise-site.mdx new file mode 100644 index 000000000000..2c89b01de4b2 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/models-get-noise-site.mdx @@ -0,0 +1,24 @@ +--- +title: get_noise_site (latest version) +description: API reference for qiskit_noise_learning.models.get_noise_site in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: function +python_api_name: qiskit_noise_learning.models.get_noise_site +--- + + + +# qiskit\_noise\_learning.models.get\_noise\_site + + + The noise-site mapping of the map’s [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"), if it has exactly one. + + **Parameters** + + **model** – The map to inspect. + + **Returns** + + The `{gate_name: "before" | "after"}` mapping from the map’s single [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"), or `None` if `model` is, or contains, no (or more than one) [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"). + + diff --git a/docs/api/qiskit-noise-learning/generated/models-identity-fidelity-model.mdx b/docs/api/qiskit-noise-learning/generated/models-identity-fidelity-model.mdx new file mode 100644 index 000000000000..af47d232149b --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/models-identity-fidelity-model.mdx @@ -0,0 +1,71 @@ +--- +title: IdentityFidelityModel (latest version) +description: API reference for qiskit_noise_learning.models.IdentityFidelityModel in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.models.IdentityFidelityModel +--- + + + +# qiskit\_noise\_learning.models.IdentityFidelityModel + + + Bases: [`LinearMap`](math-linear-map "qiskit_noise_learning.math.linear_map.LinearMap")\[[`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.fidelity_index.FidelityIndex"), [`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.fidelity_index.FidelityIndex")] + + A fidelity model whose parameters are the log fidelities themselves. + + The parameterization matrix is the identity: the input and output spaces are the same [`LogFidelitySpace`](models-log-fidelity-space "qiskit_noise_learning.models.LogFidelitySpace"), and the row of a fidelity index is the unit vector on that index. + + **Parameters** + + **gate\_set** – The gate set whose fidelities are being modelled. To be converted to a [`ModelGateSet`](gate-sets-model-gate-set "qiskit_noise_learning.gate_sets.ModelGateSet"). + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.models.IdentityFidelityModel.__init__ "qiskit_noise_learning.models.IdentityFidelityModel.__init__")(gate\_set) | | + | `compose`(outer) | Post-compose: self maps I->O, outer maps O->C, result maps I->C. | + | `left_multiply`(matrix) | Multiply on the left by an explicit matrix. | + | `pre_compose`(inner) | Pre-compose: inner maps A->I, self maps I->O, result maps A->O. | + | `projected_output`(output\_indices, vector) | Compute a projection of the map applied to a vector. | + | [`rows`](#qiskit_noise_learning.models.IdentityFidelityModel.rows "qiskit_noise_learning.models.IdentityFidelityModel.rows")(output\_indices) | Construct the sub-matrix whose rows are the given fidelity indices. | + + ## Attributes + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | + | [`gate_set`](#qiskit_noise_learning.models.IdentityFidelityModel.gate_set "qiskit_noise_learning.models.IdentityFidelityModel.gate_set") | The gate set whose fidelities are being modelled. | + | `input_space` | The input space. | + | `output_space` | The output space. | + + ### gate\_set + + + Type: [`ModelGateSet`](gate-sets-model-gate-set "qiskit_noise_learning.gate_sets.model_gate_set.ModelGateSet") + + The gate set whose fidelities are being modelled. + + + ### rows + + + Construct the sub-matrix whose rows are the given fidelity indices. + + Each row is the unit vector on its fidelity index (the identity parameterization). + + **Parameters** + + **output\_indices** – The fidelity indices labelling the desired rows. + + **Returns** + + An [`IndexedMatrix`](math-indexed-matrix "qiskit_noise_learning.math.IndexedMatrix") whose rows and columns are both the requested fidelity indices, with identity data. + + + diff --git a/docs/api/qiskit-noise-learning/generated/models-is-fidelity-model.mdx b/docs/api/qiskit-noise-learning/generated/models-is-fidelity-model.mdx new file mode 100644 index 000000000000..2f04fc54f6d0 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/models-is-fidelity-model.mdx @@ -0,0 +1,24 @@ +--- +title: is_fidelity_model (latest version) +description: API reference for qiskit_noise_learning.models.is_fidelity_model in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: function +python_api_name: qiskit_noise_learning.models.is_fidelity_model +--- + + + +# qiskit\_noise\_learning.models.is\_fidelity\_model + + + Whether an object is a [`LinearMap`](math-linear-map "qiskit_noise_learning.math.LinearMap") with a [`LogFidelitySpace`](models-log-fidelity-space "qiskit_noise_learning.models.LogFidelitySpace") output space. + + **Parameters** + + **model** – The object to check. + + **Returns** + + `True` if `model` is a [`LinearMap`](math-linear-map "qiskit_noise_learning.math.LinearMap") whose output space is a [`LogFidelitySpace`](models-log-fidelity-space "qiskit_noise_learning.models.LogFidelitySpace"), otherwise `False`. + + diff --git a/docs/api/qiskit-noise-learning/generated/models-log-fidelity-space.mdx b/docs/api/qiskit-noise-learning/generated/models-log-fidelity-space.mdx new file mode 100644 index 000000000000..e62ff270a4ed --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/models-log-fidelity-space.mdx @@ -0,0 +1,59 @@ +--- +title: LogFidelitySpace (latest version) +description: API reference for qiskit_noise_learning.models.LogFidelitySpace in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.models.LogFidelitySpace +--- + + + +# qiskit\_noise\_learning.models.LogFidelitySpace + + + Bases: [`IndexedSpace`](math-indexed-space "qiskit_noise_learning.math.indexed_space.IndexedSpace")\[[`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.fidelity_index.FidelityIndex")] + + The space of log fidelities of a gate set. + + The basis indices are the [`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.FidelityIndex") objects of the gate set, excluding the trivial identity fidelity of each gate. See [`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.FidelityIndex") for more information. + + **Parameters** + + **gate\_set** – The gate set whose fidelities the space describes. Converted to a [`ModelGateSet`](gate-sets-model-gate-set "qiskit_noise_learning.gate_sets.ModelGateSet"). + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------- | - | + | [`__init__`](#qiskit_noise_learning.models.LogFidelitySpace.__init__ "qiskit_noise_learning.models.LogFidelitySpace.__init__")(gate\_set) | | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | + | [`dim`](#qiskit_noise_learning.models.LogFidelitySpace.dim "qiskit_noise_learning.models.LogFidelitySpace.dim") | The total number of fidelities of the gate set, excluding the trivial identity ones. | + | [`gate_set`](#qiskit_noise_learning.models.LogFidelitySpace.gate_set "qiskit_noise_learning.models.LogFidelitySpace.gate_set") | The gate set whose fidelities this space describes. | + + ### gate\_set + + + Type: [`ModelGateSet`](gate-sets-model-gate-set "qiskit_noise_learning.gate_sets.model_gate_set.ModelGateSet") + + The gate set whose fidelities this space describes. + + + ### dim + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + The total number of fidelities of the gate set, excluding the trivial identity ones. + + Each gate contributes the count given by Equation [(4)](/docs/addons/qiskit-noise-learning/guides/formalism#equation-num-fidelities) of the [mathematical formalism](/docs/addons/qiskit-noise-learning/guides/formalism), less one. + + + diff --git a/docs/api/qiskit-noise-learning/generated/models-pauli-lindblad-model.mdx b/docs/api/qiskit-noise-learning/generated/models-pauli-lindblad-model.mdx new file mode 100644 index 000000000000..6a50b7161bef --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/models-pauli-lindblad-model.mdx @@ -0,0 +1,194 @@ +--- +title: PauliLindbladModel (latest version) +description: API reference for qiskit_noise_learning.models.PauliLindbladModel in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.models.PauliLindbladModel +--- + + + +# qiskit\_noise\_learning.models.PauliLindbladModel + + + Bases: [`LinearMap`](math-linear-map "qiskit_noise_learning.math.linear_map.LinearMap")\[[`GeneratorIndex`](models-generator-index "qiskit_noise_learning.models.pauli_lindblad_model.GeneratorIndex"), [`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.fidelity_index.FidelityIndex")] + + A linear mapping from Pauli-Lindblad generator rates to log fidelities. + + This model class assumes that every gate in the gate set is either a unitary, a pure preparation (all qubits are prepared and the unitary part is trivial), or a pure measurement (all qubits are measured and the unitary part is trivial). It is further assumed that at least one preparation and at least one measurement gate are present. + + The noise model for each gate in this case is a Pauli channel, parameterized in terms of the rates of a Pauli-Lindblad decomposition $\exp(\sum_{P \in \mathcal{P}_n} r_P L(P))$, where the $r_P$ are the rates, and $L(P) = P \cdot P - \cdot$. In the case of unitary gates, the noise can be modelled as either occuring before or after the ideal unitary. + + **Parameters** + + * **gate\_set** – The gate set whose fidelities are being modelled. To be converted to a `ModelGateSet`. + * **generators** – A dictionary mapping gate name to the set of Pauli-Lindblad generators for the noise model of that gate. The generators for each gate must be unique. + * **noise\_site** – A dictionary specifying, for each gate name, whether the noise model occurs before or after the gate, indicated with strings `"before"` and `"after"`. Any unspecified values for the gate set will be populated with default values: `"before"` for unitary gates and pure measurement gates, and `"after"` for pure preparation. An error will be raised if a value for pure measurement or preparation is specified that differs from the default. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the gate set is not of the required form, or if `noise_model_before_gate` has any invalid values. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.models.PauliLindbladModel.__init__ "qiskit_noise_learning.models.PauliLindbladModel.__init__")(gate\_set, generators\[, noise\_site]) | | + | `compose`(outer) | Post-compose: self maps I->O, outer maps O->C, result maps I->C. | + | [`k_local`](#qiskit_noise_learning.models.PauliLindbladModel.k_local "qiskit_noise_learning.models.PauliLindbladModel.k_local")(gate\_set\[, k, gate\_k, paulis, ...]) | Construct a k-local model. | + | [`k_partition_local`](#qiskit_noise_learning.models.PauliLindbladModel.k_partition_local "qiskit_noise_learning.models.PauliLindbladModel.k_partition_local")(gate\_set\[, k, gate\_k, ...]) | Construct a k-local model according to qubit partitions. | + | `left_multiply`(matrix) | Multiply on the left by an explicit matrix. | + | `pre_compose`(inner) | Pre-compose: inner maps A->I, self maps I->O, result maps A->O. | + | `projected_output`(output\_indices, vector) | Compute a projection of the map applied to a vector. | + | [`rows`](#qiskit_noise_learning.models.PauliLindbladModel.rows "qiskit_noise_learning.models.PauliLindbladModel.rows")(output\_indices) | Construct the sub-matrix whose rows are the given fidelity indices. | + | [`to_pauli_lindblad_maps`](#qiskit_noise_learning.models.PauliLindbladModel.to_pauli_lindblad_maps "qiskit_noise_learning.models.PauliLindbladModel.to_pauli_lindblad_maps")(model\_data\[, ...]) | Return a dictionary of `PauliLindbladMap` for each gate in the model. | + + ## Attributes + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | + | [`gate_set`](#qiskit_noise_learning.models.PauliLindbladModel.gate_set "qiskit_noise_learning.models.PauliLindbladModel.gate_set") | The gate set whose fidelities are being modelled. | + | [`generators`](#qiskit_noise_learning.models.PauliLindbladModel.generators "qiskit_noise_learning.models.PauliLindbladModel.generators") | The generators for the noise model. | + | `input_space` | The input space. | + | [`meas_names`](#qiskit_noise_learning.models.PauliLindbladModel.meas_names "qiskit_noise_learning.models.PauliLindbladModel.meas_names") | The names of the measurements in this model. | + | [`noise_site`](#qiskit_noise_learning.models.PauliLindbladModel.noise_site "qiskit_noise_learning.models.PauliLindbladModel.noise_site") | Whether each noise map occurs before or after each gate. | + | `output_space` | The output space. | + | [`prep_names`](#qiskit_noise_learning.models.PauliLindbladModel.prep_names "qiskit_noise_learning.models.PauliLindbladModel.prep_names") | The names of the preparation in this model. | + + ### gate\_set + + + Type: [`ModelGateSet`](gate-sets-model-gate-set "qiskit_noise_learning.gate_sets.model_gate_set.ModelGateSet") + + The gate set whose fidelities are being modelled. + + + ### generators + + + Type: [`dict`](https://docs.python.org/3/library/stdtypes.html#dict)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), [`QubitSparsePauliList`](/docs/api/qiskit/qiskit.quantum_info.QubitSparsePauliList)] + + The generators for the noise model. + + + ### meas\_names + + + Type: [`set`](https://docs.python.org/3/library/stdtypes.html#set)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str)] + + The names of the measurements in this model. + + + ### noise\_site + + + Type: [`dict`](https://docs.python.org/3/library/stdtypes.html#dict)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), [`str`](https://docs.python.org/3/library/stdtypes.html#str)] + + Whether each noise map occurs before or after each gate. + + + ### prep\_names + + + Type: [`set`](https://docs.python.org/3/library/stdtypes.html#set)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str)] + + The names of the preparation in this model. + + + ### rows + + + Construct the sub-matrix whose rows are the given fidelity indices. + + **Parameters** + + **output\_indices** – The fidelity indices labelling the desired rows. + + **Returns** + + An [`IndexedMatrix`](math-indexed-matrix "qiskit_noise_learning.math.IndexedMatrix") indexed by the (non-zero) requested fidelity indices and by the generator indices appearing in those rows. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If any fidelity index labels a gate that is not in the model. + + + ### k\_partition\_local + + + Construct a k-local model according to qubit partitions. + + Note that the default partition for this method (described below) results in differing default behaviour for this method as compared to [`PauliLindbladModel.k_local()`](#qiskit_noise_learning.models.PauliLindbladModel.k_local "qiskit_noise_learning.models.PauliLindbladModel.k_local"). + + This method defines k-locality in terms of partitions of a set of $n$-qubits, generalizing the usual notion beyond single qubits. A partition is a collection of disjoint sets of qubit indices that covers $\{0, ..., n - 1\}$. Two qubit indices $i, j$ are neighbours if either edge $(i, j)$ or $(j, i)$ is in the coupling map, which is drawn from `gate_set` or defaults to the complete coupling map. Given a partition $P$, two distinct qubit index sets $B_0, B_1 \in P$ are neighbours if there exists indices $i \in B_0$ and $j \in B_1$ that are neighbours. Similarly, distinct $B_0, B_1 \in P$ are next-nearest neighbours if there exists a distinct $B_2 \in P$ which is neighbours with both $B_0$ and $B_1$, and so on. + + For a given gate, the $k$-local model is built recursively starting with $1$-local terms defined in the argument `local_paulis`, with $1$-local terms for subsets of size `m` given by `local_paulis[m]`. $2$-local terms are built via tensor product of $1$-local terms between pairs of neighbouring subsets. Generally, $k$-local terms are built from the tensor product of $(k - 1)$-local terms and $1$-local terms on sets of $k$ connected sets. + + If no `qubit_partition` is supplied, the partition of singletons is assumed. If no `local_paulis` is supplied, the set of all possible Paulis on the given number of qubits is assumed. + + **Parameters** + + * **gate\_set** – The gate set being modelled. Must contain only Clifford, pure preparation, and pure measurement layers. To be converted to a `ModelGateSet`. The coupling map is drawn from `gate_set.model_gate_set.coupling_map`, or if it is `None`, defaults to the complete coupling map. + * **k** – The default degree of locality of the model. Applies to all gates not specified in `gate_k`. Defaults to `2`. + * **gate\_k** – A dictionary mapping gate names to per-gate locality values that override `k` for the specified gates. + * **qubit\_partitions** – A dictionary indicating a qubit partition for each gate. Any unspecified partitions will be populated with a default in which qubits are grouped together if they are connected by unitary gate operations. + * **local\_paulis** – A dictionary indicating the 1-local Paulis to use each qubit partition for each gate. I.e. `len(local_paulis[gate_name])` must equal the maximum partition size in `qubit_partitions[gate_name]`, and `local_paulis[gate_name][k].num_qubits` must equal `k`. For Clifford gates, `local_paulis[gate_name][k]` defaults to all possible non-identity Paulis on `k` qubits, and for measurement and preparation, it defaults to all Paulis consisting of $\{I, X\}$ on `k` qubits. + * **noise\_site** – Dictionary indicating whether to model gate noise as `"before"` or `"after"` the gate. + + **Returns** + + A new [`PauliLindbladModel`](#qiskit_noise_learning.models.PauliLindbladModel "qiskit_noise_learning.models.PauliLindbladModel") instance. + + **Raises** + + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If any `k` value exceeds `len(gate_set.qubit_subset)`. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If `gate_k` contains names not in the gate set. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – Name not in `gate_set` is used in any other dictionary. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – Any partition is ill-formed. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – `local_paulis` does not satisfy the assumed form. + + + ### k\_local + + + Construct a k-local model. + + This is equivalent to calling [`PauliLindbladModel.k_partition_local()`](#qiskit_noise_learning.models.PauliLindbladModel.k_partition_local "qiskit_noise_learning.models.PauliLindbladModel.k_partition_local") with each partition specified as partition of singletons for each gate. + + **Parameters** + + * **gate\_set** – The gate set being modelled. Must contain only Clifford, pure preparation, and pure measurement layers. To be converted to a `ModelGateSet`. + * **k** – The default degree of locality of the model. Applies to all gates not specified in `gate_k`. Defaults to `2`. + * **gate\_k** – A dictionary mapping gate names to per-gate locality values that override `k` for the specified gates. + * **paulis** – A dictionary indicating the single-qubit Paulis to use in the k-local model for each gate. For Clifford gates, defaults to all single qubit Paulis, and for measurement and preparation, defaults to $\{I, X\}$. + * **noise\_site** – Dictionary indicating whether to model gate noise as `"before"` or `"after"` the gate. + + **Returns** + + A new `PauliFidelityModel` instance. + + + ### to\_pauli\_lindblad\_maps + + + Return a dictionary of `PauliLindbladMap` for each gate in the model. + + **Parameters** + + * **model\_fit** – The fitted model parameters and covariance. + * **include\_spam** – Whether to include SPAM gates in the output. + + **Returns** + + A dictionary from gate names to corresponding noise maps. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If `model_data` does not contain the correct parameters. + + + diff --git a/docs/api/qiskit-noise-learning/generated/models-pauli-lindblad-split.mdx b/docs/api/qiskit-noise-learning/generated/models-pauli-lindblad-split.mdx new file mode 100644 index 000000000000..e9a15211f3a2 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/models-pauli-lindblad-split.mdx @@ -0,0 +1,70 @@ +--- +title: PauliLindbladSplit (latest version) +description: API reference for qiskit_noise_learning.models.PauliLindbladSplit in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.models.PauliLindbladSplit +--- + + + +# qiskit\_noise\_learning.models.PauliLindbladSplit + + + Bases: [`NamedTuple`](https://docs.python.org/3/library/typing.html#typing.NamedTuple) + + The decomposition of a map around its underlying [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"). + + The original map is equivalent to `after @ model @ before` (`before` applied first). A `None` value for `before` or `after` indicates there are no maps on that side of `model`. + + **Parameters** + + * **before** – The maps applied before `model` (mapping into `model`’s input space), or `None`. + * **model** – The underlying [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"). + * **after** – The maps applied after `model` (mapping out of `model`’s output space), or `None`. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------- | + | [`__init__`](#qiskit_noise_learning.models.PauliLindbladSplit.__init__ "qiskit_noise_learning.models.PauliLindbladSplit.__init__")() | | + | `count`(value, /) | Return number of occurrences of value. | + | `index`(value\[, start, stop]) | Return first index of value. | + + ## Attributes + + | | | + | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------ | + | [`after`](#qiskit_noise_learning.models.PauliLindbladSplit.after "qiskit_noise_learning.models.PauliLindbladSplit.after") | Alias for field number 2 | + | [`before`](#qiskit_noise_learning.models.PauliLindbladSplit.before "qiskit_noise_learning.models.PauliLindbladSplit.before") | Alias for field number 0 | + | [`model`](#qiskit_noise_learning.models.PauliLindbladSplit.model "qiskit_noise_learning.models.PauliLindbladSplit.model") | Alias for field number 1 | + + ### before + + + Type: [`ComposedLinearMap`](math-composed-linear-map "qiskit_noise_learning.math.linear_map.ComposedLinearMap") | [`None`](https://docs.python.org/3/library/constants.html#None) + + Alias for field number 0 + + + ### model + + + Type: [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.pauli_lindblad_model.PauliLindbladModel") + + Alias for field number 1 + + + ### after + + + Type: [`ComposedLinearMap`](math-composed-linear-map "qiskit_noise_learning.math.linear_map.ComposedLinearMap") | [`None`](https://docs.python.org/3/library/constants.html#None) + + Alias for field number 2 + + + diff --git a/docs/api/qiskit-noise-learning/generated/models-rate-space.mdx b/docs/api/qiskit-noise-learning/generated/models-rate-space.mdx new file mode 100644 index 000000000000..02b3fc3c36e7 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/models-rate-space.mdx @@ -0,0 +1,57 @@ +--- +title: RateSpace (latest version) +description: API reference for qiskit_noise_learning.models.RateSpace in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.models.RateSpace +--- + + + +# qiskit\_noise\_learning.models.RateSpace + + + Bases: [`IndexedSpace`](math-indexed-space "qiskit_noise_learning.math.indexed_space.IndexedSpace")\[[`GeneratorIndex`](models-generator-index "qiskit_noise_learning.models.pauli_lindblad_model.GeneratorIndex")] + + Space of Pauli-Lindblad generator rates, indexed by [`GeneratorIndex`](models-generator-index "qiskit_noise_learning.models.GeneratorIndex"). + + **Parameters** + + **generators** – A dictionary mapping gate name to the gate’s Pauli-Lindblad generators. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------- | - | + | [`__init__`](#qiskit_noise_learning.models.RateSpace.__init__ "qiskit_noise_learning.models.RateSpace.__init__")(generators) | | + + ## Attributes + + | | | + | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | + | [`dim`](#qiskit_noise_learning.models.RateSpace.dim "qiskit_noise_learning.models.RateSpace.dim") | The dimension (cardinality) of the space. | + | [`generators`](#qiskit_noise_learning.models.RateSpace.generators "qiskit_noise_learning.models.RateSpace.generators") | The Pauli-Lindblad generators for each gate. | + + ### generators + + + Type: [`dict`](https://docs.python.org/3/library/stdtypes.html#dict)\[[`str`](https://docs.python.org/3/library/stdtypes.html#str), [`QubitSparsePauliList`](/docs/api/qiskit/qiskit.quantum_info.QubitSparsePauliList)] + + The Pauli-Lindblad generators for each gate. + + + ### dim + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) | [`float`](https://docs.python.org/3/library/functions.html#float) + + The dimension (cardinality) of the space. + + May be `math.inf` for infinite-dimensional spaces. + + + diff --git a/docs/api/qiskit-noise-learning/generated/models-split-pauli-lindblad-model.mdx b/docs/api/qiskit-noise-learning/generated/models-split-pauli-lindblad-model.mdx new file mode 100644 index 000000000000..34670db05661 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/models-split-pauli-lindblad-model.mdx @@ -0,0 +1,28 @@ +--- +title: split_pauli_lindblad_model (latest version) +description: API reference for qiskit_noise_learning.models.split_pauli_lindblad_model in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: function +python_api_name: qiskit_noise_learning.models.split_pauli_lindblad_model +--- + + + +# qiskit\_noise\_learning.models.split\_pauli\_lindblad\_model + + + Split a map around its underlying [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"). + + **Parameters** + + **model** – The map to split. + + **Returns** + + A [`PauliLindbladSplit`](models-pauli-lindblad-split "qiskit_noise_learning.models.PauliLindbladSplit") `(before, model, after)` such that the input map is equivalent to `after @ model @ before`. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If `model` does not contain exactly one [`PauliLindbladModel`](models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"). + + diff --git a/docs/api/qiskit-noise-learning/generated/noise-learner-learning-options.mdx b/docs/api/qiskit-noise-learning/generated/noise-learner-learning-options.mdx new file mode 100644 index 000000000000..8fdfa92be679 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/noise-learner-learning-options.mdx @@ -0,0 +1,133 @@ +--- +title: LearningOptions (latest version) +description: API reference for qiskit_noise_learning.noise_learner.LearningOptions in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.noise_learner.LearningOptions +--- + + + +# qiskit\_noise\_learning.noise\_learner.LearningOptions + + + Bases: `BaseModel` + + Options for the noise learner. + + ### \_\_init\_\_ + + + Create a new model by parsing and validating input data from keyword arguments. + + Raises \[ValidationError]\[pydantic\_core.ValidationError] if the input data cannot be validated to form a valid model. + + self is explicitly positional-only to allow self as a field name. + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.noise_learner.LearningOptions.__init__ "qiskit_noise_learning.noise_learner.LearningOptions.__init__")(\*\*data) | Create a new model by parsing and validating input data from keyword arguments. | + | `construct`(\[\_fields\_set]) | | + | `copy`(\*\[, include, exclude, update, deep]) | Returns a copy of the model. | + | `dict`(\*\[, include, exclude, by\_alias, ...]) | | + | `from_orm`(obj) | | + | `json`(\*\[, include, exclude, by\_alias, ...]) | | + | `model_construct`(\[\_fields\_set]) | Creates a new instance of the Model class with validated data. | + | `model_copy`(\*\[, update, deep]) | !!! abstract "Usage Documentation" | + | `model_dump`(\*\[, mode, include, exclude, ...]) | !!! abstract "Usage Documentation" | + | `model_dump_json`(\*\[, indent, ensure\_ascii, ...]) | !!! abstract "Usage Documentation" | + | `model_json_schema`(by\_alias, ref\_template, ...) | Generates a JSON schema for a model class. | + | `model_parametrized_name`(params) | Compute the class name for parametrizations of generic classes. | + | `model_post_init`(context, /) | Override this method to perform additional initialization after \_\_init\_\_ and model\_construct. | + | `model_rebuild`(\*\[, force, raise\_errors, ...]) | Try to rebuild the pydantic-core schema for the model. | + | `model_validate`(obj, \*\[, strict, extra, ...]) | Validate a pydantic model instance. | + | `model_validate_json`(json\_data, \*\[, strict, ...]) | !!! abstract "Usage Documentation" | + | `model_validate_strings`(obj, \*\[, strict, ...]) | Validate the given object with string data against the Pydantic model. | + | `parse_file`(path, \*\[, content\_type, ...]) | | + | `parse_obj`(obj) | | + | `parse_raw`(b, \*\[, content\_type, encoding, ...]) | | + | `schema`(\[by\_alias, ref\_template]) | | + | `schema_json`(\*\[, by\_alias, ref\_template]) | | + | `update_forward_refs`(\*\*localns) | | + | `validate`(value) | | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | + | `model_computed_fields` | | + | [`model_config`](#qiskit_noise_learning.noise_learner.LearningOptions.model_config "qiskit_noise_learning.noise_learner.LearningOptions.model_config") | Configuration for the model, should be a dictionary conforming to \[ConfigDict]\[pydantic.config.ConfigDict]. | + | `model_extra` | Get extra fields set during validation. | + | `model_fields` | | + | `model_fields_set` | Returns the set of fields that have been explicitly set on this model instance. | + | [`num_randomizations`](#qiskit_noise_learning.noise_learner.LearningOptions.num_randomizations "qiskit_noise_learning.noise_learner.LearningOptions.num_randomizations") | The number of randomizations to use per learning circuit. | + | [`shots_per_randomizations`](#qiskit_noise_learning.noise_learner.LearningOptions.shots_per_randomizations "qiskit_noise_learning.noise_learner.LearningOptions.shots_per_randomizations") | The number of shots to use per randomization. | + | [`fragment_depths`](#qiskit_noise_learning.noise_learner.LearningOptions.fragment_depths "qiskit_noise_learning.noise_learner.LearningOptions.fragment_depths") | The fragment depths to use (number of repetitions of each path's repeatable fragment). | + | [`k_locality`](#qiskit_noise_learning.noise_learner.LearningOptions.k_locality "qiskit_noise_learning.noise_learner.LearningOptions.k_locality") | The locality of the terms to include in the noise model. | + | [`path_generator`](#qiskit_noise_learning.noise_learner.LearningOptions.path_generator "qiskit_noise_learning.noise_learner.LearningOptions.path_generator") | The path generator to use. | + | [`analyzer`](#qiskit_noise_learning.noise_learner.LearningOptions.analyzer "qiskit_noise_learning.noise_learner.LearningOptions.analyzer") | The analyzer to use. | + + ### num\_randomizations + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + The number of randomizations to use per learning circuit. + + + ### shots\_per\_randomizations + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + The number of shots to use per randomization. + + + ### fragment\_depths + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`int`](https://docs.python.org/3/library/functions.html#int)] + + The fragment depths to use (number of repetitions of each path’s repeatable fragment). + + + ### model\_config + + + Default value: `{}` + + Configuration for the model, should be a dictionary conforming to \[ConfigDict]\[pydantic.config.ConfigDict]. + + + ### k\_locality + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) + + The locality of the terms to include in the noise model. + + + ### path\_generator + + + Type: [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)\[`'even_depth'`] + + The path generator to use. + + By default, the generator produces even depth paths for each gate for which to learn the noise. + + + ### analyzer + + + Type: [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)\[`'standard'`] + + The analyzer to use. + + By default, the analyzer pipeline first computes observables, then curve fits exponentials, and finally uses non-negative least squares to solve for model parameters. + + + diff --git a/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner-job.mdx b/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner-job.mdx new file mode 100644 index 000000000000..4d2b8330548b --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner-job.mdx @@ -0,0 +1,59 @@ +--- +title: NoiseLearnerJob (latest version) +description: API reference for qiskit_noise_learning.noise_learner.NoiseLearnerJob in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.noise_learner.NoiseLearnerJob +--- + + + +# qiskit\_noise\_learning.noise\_learner.NoiseLearnerJob + + + Bases: [`object`](https://docs.python.org/3/library/functions.html#object) + + A noise learner job. + + This class is a wrapper around the job returned by the executor that ran the experiment, which also includes attributes to analyze the outcome of a noise learning experiment. + + **Parameters** + + * **runtime\_job** – The job returned by the executor the program was submitted to. This is a [`RuntimeJobV2`](/docs/api/qiskit-ibm-runtime/runtime-job-v2 "(in Qiskit Runtime IBM Client)") unless a different executor was supplied to [`NoiseLearner`](noise-learner-noise-learner "qiskit_noise_learning.noise_learner.NoiseLearner"). + * **data\_mapper** – The data mapper describing the experiment layout. + * **analysis\_stage** – The analysis stage to process the data. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.noise_learner.NoiseLearnerJob.__init__ "qiskit_noise_learning.noise_learner.NoiseLearnerJob.__init__")(runtime\_job, data\_mapper, ...) | | + | [`result`](#qiskit_noise_learning.noise_learner.NoiseLearnerJob.result "qiskit_noise_learning.noise_learner.NoiseLearnerJob.result")(\*args, \*\*kwargs) | Compute the result of the noise learning job. | + + ## Attributes + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | + | [`runtime_job`](#qiskit_noise_learning.noise_learner.NoiseLearnerJob.runtime_job "qiskit_noise_learning.noise_learner.NoiseLearnerJob.runtime_job") | The job returned by the executor the program was submitted to. | + + ### runtime\_job + + + Type: [`ProgramJob`](noise-learner-program-job "qiskit_noise_learning.noise_learner.noise_learner_job.ProgramJob") + + The job returned by the executor the program was submitted to. + + + ### result + + + Compute the result of the noise learning job. + + This method forwards arguments to [`ProgramJob.result()`](noise-learner-program-job#result "qiskit_noise_learning.noise_learner.ProgramJob.result"). + + + diff --git a/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner-result.mdx b/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner-result.mdx new file mode 100644 index 000000000000..7589a58cdcd7 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner-result.mdx @@ -0,0 +1,55 @@ +--- +title: NoiseLearnerResult (latest version) +description: API reference for qiskit_noise_learning.noise_learner.NoiseLearnerResult in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.noise_learner.NoiseLearnerResult +--- + + + +# qiskit\_noise\_learning.noise\_learner.NoiseLearnerResult + + + Bases: [`object`](https://docs.python.org/3/library/functions.html#object) + + Result of noise learning. + + Wraps a [`Fit`](analysis-fit "qiskit_noise_learning.analysis.Fit") container and provides conversion to [`PauliLindbladMap`](/docs/api/qiskit/qiskit.quantum_info.PauliLindbladMap) per gate. + + **Parameters** + + **fit** – The completed fit containing model data. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.noise_learner.NoiseLearnerResult.__init__ "qiskit_noise_learning.noise_learner.NoiseLearnerResult.__init__")(fit) | | + | [`to_dict`](#qiskit_noise_learning.noise_learner.NoiseLearnerResult.to_dict "qiskit_noise_learning.noise_learner.NoiseLearnerResult.to_dict")() | Convert the result to a dictionary mapping gate names to Pauli Lindblad maps. | + + ## Attributes + + | | | + | --------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | + | [`fit`](#qiskit_noise_learning.noise_learner.NoiseLearnerResult.fit "qiskit_noise_learning.noise_learner.NoiseLearnerResult.fit") | The underlying fit container. | + + ### fit + + + Type: [`Fit`](analysis-fit "qiskit_noise_learning.analysis.fit.Fit") + + The underlying fit container. + + + ### to\_dict + + + Convert the result to a dictionary mapping gate names to Pauli Lindblad maps. + + + diff --git a/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner.mdx b/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner.mdx new file mode 100644 index 000000000000..b86db5b91bc7 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/noise-learner-noise-learner.mdx @@ -0,0 +1,80 @@ +--- +title: NoiseLearner (latest version) +description: API reference for qiskit_noise_learning.noise_learner.NoiseLearner in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.noise_learner.NoiseLearner +--- + + + +# qiskit\_noise\_learning.noise\_learner.NoiseLearner + + + Bases: [`object`](https://docs.python.org/3/library/functions.html#object) + + A noise learner. + + + The arguments `backend` and `executor` are redundant. This is a temporary measure to enable simulated execution with an [`AerExecutor`](aer-executor-aer-executor "qiskit_noise_learning.aer_executor.AerExecutor") instance, and is not a stable interface. + + + **Parameters** + + * **backend** – The backend supplying the compilation target: the gate set, coupling map and qubit count that generated circuits are built against. When `executor` is given, this need not be the device the programs actually run on. + * **options** – Learning options. If `None`, default options are used. + * **executor** – Where generated programs are submitted. If `None` (default), a [`Executor`](/docs/api/qiskit-ibm-runtime/executor "(in Qiskit Runtime IBM Client)") in `backend`’s execution mode is used, so that programs run on `backend` itself. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.noise_learner.NoiseLearner.__init__ "qiskit_noise_learning.noise_learner.NoiseLearner.__init__")(backend\[, options, executor]) | | + | [`run`](#qiskit_noise_learning.noise_learner.NoiseLearner.run "qiskit_noise_learning.noise_learner.NoiseLearner.run")(instructions) | Submit a job to learn the noise of the given instructions. | + + ## Attributes + + | | | + | --------------------------------------------------------------------------------------------------------------------------------- | --------------------- | + | [`backend`](#qiskit_noise_learning.noise_learner.NoiseLearner.backend "qiskit_noise_learning.noise_learner.NoiseLearner.backend") | The backend. | + | [`options`](#qiskit_noise_learning.noise_learner.NoiseLearner.options "qiskit_noise_learning.noise_learner.NoiseLearner.options") | The learning options. | + + ### backend + + + Type: [`BackendV2`](/docs/api/qiskit/qiskit.providers.BackendV2) + + The backend. + + + ### options + + + Type: [`LearningOptions`](noise-learner-learning-options "qiskit_noise_learning.noise_learner.learning_options.LearningOptions") + + The learning options. + + + ### run + + + Submit a job to learn the noise of the given instructions. + + **Parameters** + + **instructions** – The instructions to learn the noise of. Each instruction should contain a [`BoxOp`](/docs/api/qiskit/qiskit.circuit.BoxOp) operation. + + **Returns** + + The submitted job. The result of the job is a [`NoiseLearnerResult`](noise-learner-noise-learner-result "qiskit_noise_learning.noise_learner.NoiseLearnerResult"). + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If any instruction does not contain a `BoxOp`. + + + diff --git a/docs/api/qiskit-noise-learning/generated/noise-learner-program-executor.mdx b/docs/api/qiskit-noise-learning/generated/noise-learner-program-executor.mdx new file mode 100644 index 000000000000..233ef6e59b36 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/noise-learner-program-executor.mdx @@ -0,0 +1,49 @@ +--- +title: ProgramExecutor (latest version) +description: API reference for qiskit_noise_learning.noise_learner.ProgramExecutor in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.noise_learner.ProgramExecutor +--- + + + +# qiskit\_noise\_learning.noise\_learner.ProgramExecutor + + + Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol) + + The executor role that [`NoiseLearner`](noise-learner-noise-learner "qiskit_noise_learning.noise_learner.NoiseLearner") submits programs to. + + Only [`run()`](#qiskit_noise_learning.noise_learner.ProgramExecutor.run "qiskit_noise_learning.noise_learner.ProgramExecutor.run") is required, so both [`Executor`](/docs/api/qiskit-ibm-runtime/executor "(in Qiskit Runtime IBM Client)") and the Aer executor qualify without either declaring conformance. + + + This protocol, and the `executor` argument of [`NoiseLearner`](noise-learner-noise-learner "qiskit_noise_learning.noise_learner.NoiseLearner") that consumes it, are provisional. They exist so that a learning experiment can be run against a locally simulated executor, and this setup is expected to eventually change. + + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- | + | [`__init__`](#qiskit_noise_learning.noise_learner.ProgramExecutor.__init__ "qiskit_noise_learning.noise_learner.ProgramExecutor.__init__")(\*args, \*\*kwargs) | | + | [`run`](#qiskit_noise_learning.noise_learner.ProgramExecutor.run "qiskit_noise_learning.noise_learner.ProgramExecutor.run")(program) | Submit a program for execution. | + + ### run + + + Submit a program for execution. + + **Parameters** + + **program** – The quantum program to submit. + + **Returns** + + A job carrying the program’s result. + + + diff --git a/docs/api/qiskit-noise-learning/generated/noise-learner-program-job.mdx b/docs/api/qiskit-noise-learning/generated/noise-learner-program-job.mdx new file mode 100644 index 000000000000..3be5e9dcdb11 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/noise-learner-program-job.mdx @@ -0,0 +1,41 @@ +--- +title: ProgramJob (latest version) +description: API reference for qiskit_noise_learning.noise_learner.ProgramJob in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.noise_learner.ProgramJob +--- + + + +# qiskit\_noise\_learning.noise\_learner.ProgramJob + + + Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol) + + The job role that [`NoiseLearnerJob`](noise-learner-noise-learner-job "qiskit_noise_learning.noise_learner.NoiseLearnerJob") wraps. + + Only [`result()`](#qiskit_noise_learning.noise_learner.ProgramJob.result "qiskit_noise_learning.noise_learner.ProgramJob.result") is required, so both [`RuntimeJobV2`](/docs/api/qiskit-ibm-runtime/runtime-job-v2 "(in Qiskit Runtime IBM Client)") and the job type returned by the Aer executor qualify without either declaring conformance. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.noise_learner.ProgramJob.__init__ "qiskit_noise_learning.noise_learner.ProgramJob.__init__")(\*args, \*\*kwargs) | | + | [`result`](#qiskit_noise_learning.noise_learner.ProgramJob.result "qiskit_noise_learning.noise_learner.ProgramJob.result")(\*args, \*\*kwargs) | Return the result of the executed program. | + + ### result + + + Return the result of the executed program. + + **Returns** + + The program’s [`QuantumProgramResult`](/docs/api/qiskit-ibm-runtime/results-quantum-program-result "(in Qiskit Runtime IBM Client)"). + + + diff --git a/docs/api/qiskit-noise-learning/generated/sequences-apply-gate.mdx b/docs/api/qiskit-noise-learning/generated/sequences-apply-gate.mdx new file mode 100644 index 000000000000..97c4cee8fe4f --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/sequences-apply-gate.mdx @@ -0,0 +1,105 @@ +--- +title: ApplyGate (latest version) +description: API reference for qiskit_noise_learning.sequences.ApplyGate in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.sequences.ApplyGate +--- + + + +# qiskit\_noise\_learning.sequences.ApplyGate + + + Bases: `Instruction` + + An instruction that applies a fixed gate. + + **Parameters** + + **gate\_name** – The name of the gate to apply. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.sequences.ApplyGate.__init__ "qiskit_noise_learning.sequences.ApplyGate.__init__")(gate\_name) | | + | [`complete`](#qiskit_noise_learning.sequences.ApplyGate.complete "qiskit_noise_learning.sequences.ApplyGate.complete")() | Returns self. | + | [`is_mergeable_with`](#qiskit_noise_learning.sequences.ApplyGate.is_mergeable_with "qiskit_noise_learning.sequences.ApplyGate.is_mergeable_with")(other) | Whether or not this apply gate is mergeable with another one. | + | [`merge`](#qiskit_noise_learning.sequences.ApplyGate.merge "qiskit_noise_learning.sequences.ApplyGate.merge")(other) | Merge self and other into a single instruction. | + + ## Attributes + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- | + | [`gate_name`](#qiskit_noise_learning.sequences.ApplyGate.gate_name "qiskit_noise_learning.sequences.ApplyGate.gate_name") | The name of the gate to apply. | + | [`is_complete`](#qiskit_noise_learning.sequences.ApplyGate.is_complete "qiskit_noise_learning.sequences.ApplyGate.is_complete") | Apply gate instructions are always complete. | + | [`structure_token`](#qiskit_noise_learning.sequences.ApplyGate.structure_token "qiskit_noise_learning.sequences.ApplyGate.structure_token") | A hashable summary of this instruction that constrains mergeability. | + + ### gate\_name + + + Type: [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + The name of the gate to apply. + + + ### is\_complete + + + Type: [`bool`](https://docs.python.org/3/library/functions.html#bool) + + Apply gate instructions are always complete. + + + ### structure\_token + + + Type: [`Hashable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable) + + A hashable summary of this instruction that constrains mergeability. + + This token serves as a cheap check of non-mergeability: instructions with unequal structure tokens are never mergeable. The token must therefore distinguish instruction types from one another. + + + ### complete + + + Returns self. + + + ### is\_mergeable\_with + + + Whether or not this apply gate is mergeable with another one. + + Mergeability of two [`ApplyGate`](#qiskit_noise_learning.sequences.ApplyGate "qiskit_noise_learning.sequences.ApplyGate") instructions is based on equality of the gate names. + + **Parameters** + + **other** – The other instruction to check mergeablitity with. + + **Returns** + + Whether this instruction is mergeable with the other. + + + ### merge + + + Merge self and other into a single instruction. + + **Parameters** + + **other** – The other instruction to merge with. + + **Returns** + + Some instruction (possibly the same instance) that simultaneously implements the action of this instruction and the other instruction. + + + diff --git a/docs/api/qiskit-noise-learning/generated/sequences-fidelity-index.mdx b/docs/api/qiskit-noise-learning/generated/sequences-fidelity-index.mdx new file mode 100644 index 000000000000..6acd5871546e --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/sequences-fidelity-index.mdx @@ -0,0 +1,178 @@ +--- +title: Qiskit noise learning API documentation (latest version) +description: Index of all the modules in the latest version of qiskit-noise-learning. +--- + + + +# qiskit\_noise\_learning.sequences.FidelityIndex + + + Bases: [`object`](https://docs.python.org/3/library/functions.html#object) + + Index data for a fidelity in a Pauli-MCM-reset gate set. + + Let $K$ be the number of qubits, $[K] = \{0, ..., K-1\}$, $M\subset [K]$ denote the measured qubits, and $R \subset [K]$ the reset qubits for the gate. For a given gate, each fidelity is specified by: + + * A Pauli on the unmeasured and unreset qubits $Q \in P^{[K]\setminus (M \cup R)}$, + * A $Z$-type operator $Z^x$ on the measured qubits, $x \in Z_2^M$, and + * A $Z$-type operator $Z^y$ on the measured and reset qubits, $y \in Z_2^{M \cup R}$. + + This list constitutes the “index data” for a generalized fidelity for a given gate, in the sense that there is a bijection between all generalized fidelities and the above set of all objects satisfying the above description. See Equation [(3)](/docs/addons/qiskit-noise-learning/guides/formalism#equation-clifford-mcm-reset-form) of the [mathematical formalism](/docs/addons/qiskit-noise-learning/guides/formalism) for the decomposition in which these appear. + + The exponents $x$ and $y$ are stored as the sets of qubit indices on which they are non-zero, namely [`in_z_idxs`](#qiskit_noise_learning.sequences.FidelityIndex.in_z_idxs "qiskit_noise_learning.sequences.FidelityIndex.in_z_idxs") and [`out_z_idxs`](#qiskit_noise_learning.sequences.FidelityIndex.out_z_idxs "qiskit_noise_learning.sequences.FidelityIndex.out_z_idxs") – equivalently, the qubits on which $Z^x$ and $Z^y$ act non-trivially. + + The constructor [`FidelityIndex.from_gate()`](#qiskit_noise_learning.sequences.FidelityIndex.from_gate "qiskit_noise_learning.sequences.FidelityIndex.from_gate") builds a [`FidelityIndex`](#qiskit_noise_learning.sequences.FidelityIndex "qiskit_noise_learning.sequences.FidelityIndex") from a [`ModelGate`](gate-sets-model-gate "qiskit_noise_learning.gate_sets.ModelGate") and the above unique index data. Alternatively, [`FidelityIndex.from_transition()`](#qiskit_noise_learning.sequences.FidelityIndex.from_transition "qiskit_noise_learning.sequences.FidelityIndex.from_transition") can be used to build an instance from the Pauli transition implied by the index data. The [`FidelityIndex.__init__()`](#qiskit_noise_learning.sequences.FidelityIndex.__init__ "qiskit_noise_learning.sequences.FidelityIndex.__init__") is viewed as a “low-level” constructor which takes all stored properties without validation. + + **Parameters** + + * **gate\_name** – The name of the gate. + * **pauli** – A Pauli operator with support on unmeasured and unreset qubits. Note that `pauli.num_qubits` controls the size of the operators returned by `self.transition`. + * **in\_z\_idxs** – The qubit indices on which $x$ is non-zero. + * **out\_z\_idxs** – The qubit indices on which $y$ is non-zero. + * **input\_pauli** – The input Pauli of the transition. + * **output\_pauli** – The output Pauli of the transition. + * **sign\_flip** – Whether the transition involves a sign flip. + * **meas\_idxs** – The measurement qubit indices for the gate. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.sequences.FidelityIndex.__init__ "qiskit_noise_learning.sequences.FidelityIndex.__init__")(gate\_name, pauli, in\_z\_idxs, ...) | | + | [`from_gate`](#qiskit_noise_learning.sequences.FidelityIndex.from_gate "qiskit_noise_learning.sequences.FidelityIndex.from_gate")(gate, pauli\[, in\_z\_idxs, out\_z\_idxs]) | Construct a fidelity index from a gate and unique index data. | + | [`from_transition`](#qiskit_noise_learning.sequences.FidelityIndex.from_transition "qiskit_noise_learning.sequences.FidelityIndex.from_transition")(gate, in\_pauli, out\_pauli) | Construct a fidelity index from a Pauli transition on the quantum registers. | + | [`is_valid_for_gate`](#qiskit_noise_learning.sequences.FidelityIndex.is_valid_for_gate "qiskit_noise_learning.sequences.FidelityIndex.is_valid_for_gate")(gate, pauli\[, in\_z\_idxs, ...]) | Whether the given index data forms a valid fidelity index for the gate. | + + ## Attributes + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | + | [`gate_name`](#qiskit_noise_learning.sequences.FidelityIndex.gate_name "qiskit_noise_learning.sequences.FidelityIndex.gate_name") | The name of the gate. | + | [`in_z_idxs`](#qiskit_noise_learning.sequences.FidelityIndex.in_z_idxs "qiskit_noise_learning.sequences.FidelityIndex.in_z_idxs") | The measured qubits carrying a $Z$ on the instrument input. | + | [`mask`](#qiskit_noise_learning.sequences.FidelityIndex.mask "qiskit_noise_learning.sequences.FidelityIndex.mask") | The mask for marginalizing measurement outcomes. | + | [`observable_idxs`](#qiskit_noise_learning.sequences.FidelityIndex.observable_idxs "qiskit_noise_learning.sequences.FidelityIndex.observable_idxs") | Qubit indices of the associated $Z$ observable in ascending order. | + | [`out_z_idxs`](#qiskit_noise_learning.sequences.FidelityIndex.out_z_idxs "qiskit_noise_learning.sequences.FidelityIndex.out_z_idxs") | The measured and reset qubits carrying a $Z$ on the instrument output. | + | [`pauli`](#qiskit_noise_learning.sequences.FidelityIndex.pauli "qiskit_noise_learning.sequences.FidelityIndex.pauli") | The Pauli operator on the Clifford portion of the model gate. | + | [`sign_flip`](#qiskit_noise_learning.sequences.FidelityIndex.sign_flip "qiskit_noise_learning.sequences.FidelityIndex.sign_flip") | Whether the transition associated with this fidelity involves a sign flip. | + | [`transition`](#qiskit_noise_learning.sequences.FidelityIndex.transition "qiskit_noise_learning.sequences.FidelityIndex.transition") | The phaseless Pauli operator transition associated with this fidelity index. | + + ### from\_gate + + + Construct a fidelity index from a gate and unique index data. + + **Parameters** + + * **gate** – The model gate. + * **pauli** – A Pauli operator with support on unmeasured and unreset qubits. + * **in\_z\_idxs** – The subset of measurement qubit indices carrying a $Z$ on the instrument input. + * **out\_z\_idxs** – The subset of the union of measurement and reset qubit indices carrying a $Z$ on the instrument output. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the provided data is inconsistent with the gate. + + + ### is\_valid\_for\_gate + + + Whether the given index data forms a valid fidelity index for the gate. + + This performs the same (side-effect-free) consistency checks as [`from_gate()`](#qiskit_noise_learning.sequences.FidelityIndex.from_gate "qiskit_noise_learning.sequences.FidelityIndex.from_gate"), without constructing the index or computing its transition. + + **Parameters** + + * **gate** – The model gate. + * **pauli** – A Pauli operator with support on unmeasured and unreset qubits. + * **in\_z\_idxs** – The subset of measurement qubit indices carrying a $Z$ on the instrument input. + * **out\_z\_idxs** – The subset of the union of measurement and reset qubit indices carrying a $Z$ on the instrument output. + + + ### from\_transition + + + Construct a fidelity index from a Pauli transition on the quantum registers. + + This constructor deduces the Pauli and $Z$ index sets of a [`FidelityIndex`](#qiskit_noise_learning.sequences.FidelityIndex "qiskit_noise_learning.sequences.FidelityIndex") from the given Pauli transition. + + **Parameters** + + * **gate** – The model gate. + * **in\_pauli** – The input Pauli on the quantum register. + * **out\_pauli** – The output Pauli on the quantum register. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the pair of Pauli operators do not imply a valid [`FidelityIndex`](#qiskit_noise_learning.sequences.FidelityIndex "qiskit_noise_learning.sequences.FidelityIndex"). + + + ### gate\_name + + + Type: [`str`](https://docs.python.org/3/library/stdtypes.html#str) + + The name of the gate. + + + ### pauli + + + Type: [`QubitSparsePauli`](/docs/api/qiskit/qiskit.quantum_info.QubitSparsePauli) + + The Pauli operator on the Clifford portion of the model gate. + + + ### in\_z\_idxs + + + Type: [`frozenset`](https://docs.python.org/3/library/stdtypes.html#frozenset)\[[`int`](https://docs.python.org/3/library/functions.html#int)] + + The measured qubits carrying a $Z$ on the instrument input. + + + ### out\_z\_idxs + + + Type: [`frozenset`](https://docs.python.org/3/library/stdtypes.html#frozenset)\[[`int`](https://docs.python.org/3/library/functions.html#int)] + + The measured and reset qubits carrying a $Z$ on the instrument output. + + + ### sign\_flip + + + Type: [`bool`](https://docs.python.org/3/library/functions.html#bool) + + Whether the transition associated with this fidelity involves a sign flip. + + + ### transition + + + Type: [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple)\[[`QubitSparsePauli`](/docs/api/qiskit/qiskit.quantum_info.QubitSparsePauli), [`QubitSparsePauli`](/docs/api/qiskit/qiskit.quantum_info.QubitSparsePauli)] + + The phaseless Pauli operator transition associated with this fidelity index. + + + ### mask + + + Type: [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)\[[`bool`](https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.bool)] + + The mask for marginalizing measurement outcomes. + + + ### observable\_idxs + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`int`](https://docs.python.org/3/library/functions.html#int)] + + Qubit indices of the associated $Z$ observable in ascending order. + + + diff --git a/docs/api/qiskit-noise-learning/generated/sequences-group-mergeable-instruction-sequences.mdx b/docs/api/qiskit-noise-learning/generated/sequences-group-mergeable-instruction-sequences.mdx new file mode 100644 index 000000000000..12b852bd07d3 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/sequences-group-mergeable-instruction-sequences.mdx @@ -0,0 +1,47 @@ +--- +title: group_mergeable_instruction_sequences (latest version) +description: API reference for qiskit_noise_learning.sequences.group_mergeable_instruction_sequences in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: function +python_api_name: qiskit_noise_learning.sequences.group_mergeable_instruction_sequences +--- + + + +# qiskit\_noise\_learning.sequences.group\_mergeable\_instruction\_sequences + + + Group the positions of instruction sequences that can be merged with each other. + + The returned groups partition the positions of `sequences`: every position appears in exactly one group, and the sequences within a group can all be merged together, in any order, into a single sequence via [`merge()`](sequences-instruction-sequence#merge "qiskit_noise_learning.sequences.InstructionSequence.merge"). + + In terms of strategy, the list of sequences is first partitioned into sets according to [`structure_key`](sequences-instruction-sequence#structure_key "qiskit_noise_learning.sequences.InstructionSequence.structure_key"). Each set is then further partitioned into the returned groups via a family of greedy algorithms. A single member of this family is specified by a grouping strategy, which pairs an order to visit the instruction sequences in with a strategy for choosing which group to merge each one into. Every grouping strategy in `grouping_strategies` is applied to every set, and the fewest groups found for a set are the ones returned for it, ties going to the earlier strategy. Because the sets are treated independently, supplying an additional grouping strategy can only decrease the total number of groups returned. + + A sequence is called more constrained if it specifies more Pauli mappings. The first entry of a grouping strategy, the order to visit the instruction sequences in, is one of: + + * `"most-constrained-first"`: ordered from most-constrained to least-constrained. + * `"least-constrained-first"`: ordered from least-constrained to most-constrained. + * `"qubitwise-lexicographic"`: ordered so that sequences agreeing on the Pauli mappings they specify, qubit by qubit from the first onwards, are considered consecutively. Which of two differing sequences comes first follows a fixed but arbitrary convention, making this one of many possible orderings that place sequences specifying similar mappings near each other. + * `"input"`: the order in which they were given. + + The second entry selects which of the groups a sequence can join it is merged into: + + * `"first"`: the group created earliest. + * `"most-constrained"`: the group that already admits the fewest complete permutations, which leaves the more flexible groups intact for later sequences. + * `"least-impacted"`: the group whose admissible complete permutations the instruction sequence rules out the fewest of. + + **Parameters** + + * **sequences** – The instruction sequences to group. + * **grouping\_strategies** – The grouping strategies to take the fewest groups found by any of. If `None`, an empirically determined default set of strategies is used. + + **Returns** + + The groups of positions of mergeable sequences. + + **Raises** + + * [**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError) – If any sequence contains an instruction that is neither a gate application nor a partial Pauli permutation. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If `grouping_strategies` is empty, or if any of its entries is not a pairing of a documented instruction sequence order with a documented merging strategy. + + diff --git a/docs/api/qiskit-noise-learning/generated/sequences-instruction-sequence.mdx b/docs/api/qiskit-noise-learning/generated/sequences-instruction-sequence.mdx new file mode 100644 index 000000000000..21fdb460bc85 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/sequences-instruction-sequence.mdx @@ -0,0 +1,134 @@ +--- +title: InstructionSequence (latest version) +description: API reference for qiskit_noise_learning.sequences.InstructionSequence in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.sequences.InstructionSequence +--- + + + +# qiskit\_noise\_learning.sequences.InstructionSequence + + + Bases: `BaseSequence`\[`Instruction`] + + A sequence of instructions. + + **Parameters** + + * **start\_fragment** – The start of the sequence. + * **repeatable\_fragment** – The repeatable middle of the sequence. + * **end\_fragment** – The end of the sequence. + * **fragment\_depth** – The number of repetitions of the repeatable fragment. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | + | [`__init__`](#qiskit_noise_learning.sequences.InstructionSequence.__init__ "qiskit_noise_learning.sequences.InstructionSequence.__init__")(start\_fragment, ...\[, fragment\_depth]) | | + | `bind_at`(fragment\_depth) | Return a new instance with the same fragments bound to the fragment depth. | + | [`complete`](#qiskit_noise_learning.sequences.InstructionSequence.complete "qiskit_noise_learning.sequences.InstructionSequence.complete")() | Return a new instance whose data is the same as `self` except that all contained instructions are completed. | + | [`is_mergeable_with`](#qiskit_noise_learning.sequences.InstructionSequence.is_mergeable_with "qiskit_noise_learning.sequences.InstructionSequence.is_mergeable_with")(other) | Check if this instruction sequence is mergeable with another instruction sequence. | + | [`merge`](#qiskit_noise_learning.sequences.InstructionSequence.merge "qiskit_noise_learning.sequences.InstructionSequence.merge")(other) | Merge this instruction sequence with another instruction sequence. | + | `unbind`() | Return a new instance with the same fragments but fragment depth set to `None`. | + + ## Attributes + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | + | `end_fragment` | The ending fragment. | + | `fragment_depth` | The number of repetitions of the repeatable fragment. | + | [`gate_key`](#qiskit_noise_learning.sequences.InstructionSequence.gate_key "qiskit_noise_learning.sequences.InstructionSequence.gate_key") | A hashable summary of the gate applications in this instruction sequence. | + | [`is_complete`](#qiskit_noise_learning.sequences.InstructionSequence.is_complete "qiskit_noise_learning.sequences.InstructionSequence.is_complete") | Whether all contained instructions are completely specified. | + | `is_unbound` | Whether the sequence is unbound. | + | `repeatable_fragment` | The repeatable fragment. | + | `start_fragment` | The starting fragment. | + | [`structure_key`](#qiskit_noise_learning.sequences.InstructionSequence.structure_key "qiskit_noise_learning.sequences.InstructionSequence.structure_key") | A hashable summary of the instruction structure of this sequence. | + + ### is\_complete + + + Type: [`bool`](https://docs.python.org/3/library/functions.html#bool) + + Whether all contained instructions are completely specified. + + + ### complete + + + Return a new instance whose data is the same as `self` except that all contained instructions are completed. + + **Returns** + + A new [`InstructionSequence`](#qiskit_noise_learning.sequences.InstructionSequence "qiskit_noise_learning.sequences.InstructionSequence") instance. + + + ### gate\_key + + + Type: [`Hashable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable) + + A hashable summary of the gate applications in this instruction sequence. + + Two instruction sequences have equal gate keys exactly when they have the same fragment depth and each of their fragments applies the same gates in the same order, however else they differ; every instruction that is not a gate application is ignored. The value itself is opaque, with only equality and hashability guaranteed. + + + ### structure\_key + + + Type: [`Hashable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable) + + A hashable summary of the instruction structure of this sequence. + + This key comes with the following guarantees: + + * If two instruction sequences have different keys, they are not mergeable. + * If two instruction sequences have the same key, they have the same fragment depth, and their fragments contain the same sequence of instruction types on the same qubits. + + **Raises** + + [**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError) – If this instruction sequence contains an object that is not an instruction. + + + ### is\_mergeable\_with + + + Check if this instruction sequence is mergeable with another instruction sequence. + + Two instruction sequences are mergeable if they have compatible fragment depths and their fragments are element-wise mergeable. + + **Parameters** + + **other** – The other [`InstructionSequence`](#qiskit_noise_learning.sequences.InstructionSequence "qiskit_noise_learning.sequences.InstructionSequence"). + + **Returns** + + Whether this instance is mergeable with another. + + + ### merge + + + Merge this instruction sequence with another instruction sequence. + + Assuming this instance is mergeable with `other`, the returned merged sequence is constructed by merging each corresponding fragment element-wise. + + **Parameters** + + **other** – The instruction sequence to merge this with. + + **Returns** + + The merged sequence of self and other. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the sequences are not mergeable. + + + diff --git a/docs/api/qiskit-noise-learning/generated/sequences-log-path-map.mdx b/docs/api/qiskit-noise-learning/generated/sequences-log-path-map.mdx new file mode 100644 index 000000000000..a16e991ff580 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/sequences-log-path-map.mdx @@ -0,0 +1,60 @@ +--- +title: LogPathMap (latest version) +description: API reference for qiskit_noise_learning.sequences.LogPathMap in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.sequences.LogPathMap +--- + + + +# qiskit\_noise\_learning.sequences.LogPathMap + + + Bases: [`LinearMap`](math-linear-map "qiskit_noise_learning.math.linear_map.LinearMap")\[[`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.fidelity_index.FidelityIndex"), [`Path`](sequences-path "qiskit_noise_learning.sequences.path.Path")] + + The linear map from a space of log fidelities to its associated log path space. + + This map is purely combinatorial: the row of a path is the fragment-depth-weighted multiplicity of each fidelity index appearing in the path. It does not depend on any noise model, only on the [`Path`](sequences-path "qiskit_noise_learning.sequences.Path") structure and the fidelity indices’ membership in the input space. + + **Parameters** + + **fidelity\_space** – The space of log fidelities. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.sequences.LogPathMap.__init__ "qiskit_noise_learning.sequences.LogPathMap.__init__")(fidelity\_space) | | + | `compose`(outer) | Post-compose: self maps I->O, outer maps O->C, result maps I->C. | + | `left_multiply`(matrix) | Multiply on the left by an explicit matrix. | + | `pre_compose`(inner) | Pre-compose: inner maps A->I, self maps I->O, result maps A->O. | + | `projected_output`(output\_indices, vector) | Compute a projection of the map applied to a vector. | + | [`rows`](#qiskit_noise_learning.sequences.LogPathMap.rows "qiskit_noise_learning.sequences.LogPathMap.rows")(output\_indices) | Construct the sub-matrix whose rows are the given output indices. | + + ## Attributes + + | | | + | -------------- | ----------------- | + | `input_space` | The input space. | + | `output_space` | The output space. | + + ### rows + + + Construct the sub-matrix whose rows are the given output indices. + + **Parameters** + + **output\_indices** – The labels for the desired rows of the matrix. + + **Returns** + + [`IndexedMatrix`](math-indexed-matrix "qiskit_noise_learning.math.IndexedMatrix") + + + diff --git a/docs/api/qiskit-noise-learning/generated/sequences-log-path-space.mdx b/docs/api/qiskit-noise-learning/generated/sequences-log-path-space.mdx new file mode 100644 index 000000000000..4872e1135746 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/sequences-log-path-space.mdx @@ -0,0 +1,66 @@ +--- +title: LogPathSpace (latest version) +description: API reference for qiskit_noise_learning.sequences.LogPathSpace in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.sequences.LogPathSpace +--- + + + +# qiskit\_noise\_learning.sequences.LogPathSpace + + + Bases: [`IndexedSpace`](math-indexed-space "qiskit_noise_learning.math.indexed_space.IndexedSpace")\[[`Path`](sequences-path "qiskit_noise_learning.sequences.path.Path")] + + The (infinite-dimensional) space of log path-fidelities. + + For a [`Path`](sequences-path "qiskit_noise_learning.sequences.Path"), the “path-fidelity” is: + + * If the path is unbound, the product of the fidelities in the repeatable fragment. + * If the path is bound, the product of all fidelities in the path (counting multiplicities). + + This corresponds to the sign-corrected observable of an experiment traversing the path. + + The log path space represents the vector space of such log path-fidelities, indexed by the paths themselves. It is defined relative to a space of log fidelities: a path is a member if all of the fidelity indices in its fragments are members of that fidelity space. + + **Parameters** + + **fidelity\_space** – The space of log fidelities whose fidelity indices the paths are built from. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------- | - | + | [`__init__`](#qiskit_noise_learning.sequences.LogPathSpace.__init__ "qiskit_noise_learning.sequences.LogPathSpace.__init__")(fidelity\_space) | | + + ## Attributes + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | + | [`dim`](#qiskit_noise_learning.sequences.LogPathSpace.dim "qiskit_noise_learning.sequences.LogPathSpace.dim") | The dimension (cardinality) of the space. | + | [`fidelity_space`](#qiskit_noise_learning.sequences.LogPathSpace.fidelity_space "qiskit_noise_learning.sequences.LogPathSpace.fidelity_space") | The space of log fidelities whose fidelity indices the paths are built from. | + + ### fidelity\_space + + + Type: [`IndexedSpace`](math-indexed-space "qiskit_noise_learning.math.indexed_space.IndexedSpace")\[[`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.fidelity_index.FidelityIndex")] + + The space of log fidelities whose fidelity indices the paths are built from. + + + ### dim + + + Type: [`int`](https://docs.python.org/3/library/functions.html#int) | [`float`](https://docs.python.org/3/library/functions.html#float) + + The dimension (cardinality) of the space. + + May be `math.inf` for infinite-dimensional spaces. + + + diff --git a/docs/api/qiskit-noise-learning/generated/sequences-partial-pauli-permutation.mdx b/docs/api/qiskit-noise-learning/generated/sequences-partial-pauli-permutation.mdx new file mode 100644 index 000000000000..eee8a4c0f033 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/sequences-partial-pauli-permutation.mdx @@ -0,0 +1,264 @@ +--- +title: PartialPauliPermutation (latest version) +description: API reference for qiskit_noise_learning.sequences.PartialPauliPermutation in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.sequences.PartialPauliPermutation +--- + + + +# qiskit\_noise\_learning.sequences.PartialPauliPermutation + + + Bases: `Instruction` + + Partially-specified permutations of the single-qubit phaseless Paulis on `n` qubits. + + A [`PartialPauliPermutation`](#qiskit_noise_learning.sequences.PartialPauliPermutation "qiskit_noise_learning.sequences.PartialPauliPermutation") represents a partial-specification of a layer of single qubit Cliffords for situations where the specific phases of the Pauli group need not be constrained. The partial nature of the specification is to enable progressively building such layers. Once a partial permutation is “complete” in the sense that is a full specification of a permutation, as indicated by the `bool` property [`PartialPauliPermutation.is_complete`](#qiskit_noise_learning.sequences.PartialPauliPermutation.is_complete "qiskit_noise_learning.sequences.PartialPauliPermutation.is_complete"), a default Clifford implementing the permutation is assigned to each qubit according to the ordering in `COMPLETE_TO_C1_TABLEAU`. + + Two partial permutations on a qubit are mergeable (see [`is_mergeable_with()`](#qiskit_noise_learning.sequences.PartialPauliPermutation.is_mergeable_with "qiskit_noise_learning.sequences.PartialPauliPermutation.is_mergeable_with") and [`merge()`](#qiskit_noise_learning.sequences.PartialPauliPermutation.merge "qiskit_noise_learning.sequences.PartialPauliPermutation.merge")) if there exists a single-qubit Clifford that implements both of their permutations, which without loss of generality is the statement that one doesn’t map a Pauli to a different Pauli than the other. + + The main data representation of the class is a list of integers, where each integer indexes a particular single-qubit partial Pauli permutation given in `partial_permutation_sets()`, which provides a fixed ordering. + + However, a human-readable `set`-based representation can also be used for construction via the [`PartialPauliPermutation.from_sets()`](#qiskit_noise_learning.sequences.PartialPauliPermutation.from_sets "qiskit_noise_learning.sequences.PartialPauliPermutation.from_sets") class method, or can be retrieved from an instance via the [`PartialPauliPermutation.to_sets()`](#qiskit_noise_learning.sequences.PartialPauliPermutation.to_sets "qiskit_noise_learning.sequences.PartialPauliPermutation.to_sets") method. For a single qubit, the partial permutation is specified as a `set` whose entries are `tuple`s of the form `(p0, p1)`, where `p0` and `p1` are strings drawn from `["Z", "X", "Y"]`. This `tuple` indicates that `p0` is mapped by the permutation to `p1`. + + **Parameters** + + **partial\_permutation\_indices** – A numpy array of index-specified partial permutations. The number of qubits is determined from the length. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.sequences.PartialPauliPermutation.__init__ "qiskit_noise_learning.sequences.PartialPauliPermutation.__init__")(partial\_permutation\_indices) | | + | [`complete`](#qiskit_noise_learning.sequences.PartialPauliPermutation.complete "qiskit_noise_learning.sequences.PartialPauliPermutation.complete")() | Return a new partial Permutation that is complete and consistent with self. | + | [`compose`](#qiskit_noise_learning.sequences.PartialPauliPermutation.compose "qiskit_noise_learning.sequences.PartialPauliPermutation.compose")(other) | Compose with another partial permutation. | + | [`empty`](#qiskit_noise_learning.sequences.PartialPauliPermutation.empty "qiskit_noise_learning.sequences.PartialPauliPermutation.empty")(num\_qubits) | Generate the completely unspecified instance on `num_qubits`. | + | [`from_qubit_sparse_pauli_lists`](#qiskit_noise_learning.sequences.PartialPauliPermutation.from_qubit_sparse_pauli_lists "qiskit_noise_learning.sequences.PartialPauliPermutation.from_qubit_sparse_pauli_lists")(in\_paulis, ...) | Construct a `PartialPauliPermutation` that maps `in_paulis` to `out_paulis`. | + | [`from_qubit_sparse_paulis`](#qiskit_noise_learning.sequences.PartialPauliPermutation.from_qubit_sparse_paulis "qiskit_noise_learning.sequences.PartialPauliPermutation.from_qubit_sparse_paulis")(in\_pauli, out\_pauli) | Construct a `PartialPauliPermutation` that maps `in_pauli` to `out_pauli`. | + | [`from_sets`](#qiskit_noise_learning.sequences.PartialPauliPermutation.from_sets "qiskit_noise_learning.sequences.PartialPauliPermutation.from_sets")(sets) | Construct from a list of sets. | + | [`is_mergeable_with`](#qiskit_noise_learning.sequences.PartialPauliPermutation.is_mergeable_with "qiskit_noise_learning.sequences.PartialPauliPermutation.is_mergeable_with")(other) | Whether or not this instruction is mergeable with another one. | + | [`merge`](#qiskit_noise_learning.sequences.PartialPauliPermutation.merge "qiskit_noise_learning.sequences.PartialPauliPermutation.merge")(other) | Merge self and other into a single instruction. | + | [`propagate`](#qiskit_noise_learning.sequences.PartialPauliPermutation.propagate "qiskit_noise_learning.sequences.PartialPauliPermutation.propagate")(...) | Given a Pauli, propagate it through the Clifford implied by this permutation. | + | [`to_sets`](#qiskit_noise_learning.sequences.PartialPauliPermutation.to_sets "qiskit_noise_learning.sequences.PartialPauliPermutation.to_sets")() | Return the set representation. | + + ## Attributes + + | | | + | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | + | [`inverse`](#qiskit_noise_learning.sequences.PartialPauliPermutation.inverse "qiskit_noise_learning.sequences.PartialPauliPermutation.inverse") | Return the inversion of this partial permutation. | + | [`is_complete`](#qiskit_noise_learning.sequences.PartialPauliPermutation.is_complete "qiskit_noise_learning.sequences.PartialPauliPermutation.is_complete") | Whether self represents a complete specification of single-qubit Pauli permutations. | + | `num_qubits` | | + | [`partial_permutation_indices`](#qiskit_noise_learning.sequences.PartialPauliPermutation.partial_permutation_indices "qiskit_noise_learning.sequences.PartialPauliPermutation.partial_permutation_indices") | Raw numerical format of the partial permutation. | + | [`structure_token`](#qiskit_noise_learning.sequences.PartialPauliPermutation.structure_token "qiskit_noise_learning.sequences.PartialPauliPermutation.structure_token") | A hashable summary of this instruction that constrains mergeability. | + + ### inverse + + + Type: [`Self`](https://docs.python.org/3/library/typing.html#typing.Self) + + Return the inversion of this partial permutation. + + This returns a partially-specified inversion: only the existing mappings in this instance will be inverted. Note that the completion convention has been chosen to be consistent with inversion, in the sense that `self.inverse.complete() == self.complete().inverse`. Furthermore, the Clifford implied by `COMPLETE_TO_C1_TABLEAU` is the inverse of the implied Clifford. + + + ### is\_complete + + + Type: [`bool`](https://docs.python.org/3/library/functions.html#bool) + + Whether self represents a complete specification of single-qubit Pauli permutations. + + + ### partial\_permutation\_indices + + + Type: `NDArray`\[`int8`] + + Raw numerical format of the partial permutation. + + + ### structure\_token + + + Type: [`Hashable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable) + + A hashable summary of this instruction that constrains mergeability. + + This token serves as a cheap check of non-mergeability: instructions with unequal structure tokens are never mergeable. The token must therefore distinguish instruction types from one another. + + + ### complete + + + Return a new partial Permutation that is complete and consistent with self. + + Note that the conventions have been chosen to ensure that: + + * Any partially-specified permutation consistent with the identity is mapped to the identity, and + * `self.inverse.complete() == self.complete().inverse`. + + **Returns** + + A new [`PartialPauliPermutation`](#qiskit_noise_learning.sequences.PartialPauliPermutation "qiskit_noise_learning.sequences.PartialPauliPermutation") containing the completion of `self`. + + + ### compose + + + Compose with another partial permutation. + + For complete permutations, `self.compose(other)` returns the permutation assciated with `C1 @ C2`, where `C1` and `C2` are the Cliffords associated, respectively, with `self` and `other`. Partially specified permutations only contain a single mapping, and the composition is defined in the natural way only when the output of `other` is the input of `self`. Note finally that composition is not defined if one of `self` and `other` is incomplete, and the other is complete. This is due to the inability to ensure the commutation of completion and composition, described below. + + Note that the completion convention has been chosen to be consistent with composition, in the sense that `self.compose(other).complete() == self.complete().compose(other.complete())`. Furthermore, for complete permutations, the mapping to the Clifford implied by `COMPLETE_TO_C1_TABLEAU` is a group homomorphism (preserves multiplication). + + **Parameters** + + **other** – The other to compose with. + + **Returns** + + The composed permutation. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the composition of `self` with `other` is undefined. + + + ### empty + + + Generate the completely unspecified instance on `num_qubits`. + + **Parameters** + + **num\_qubits** – Number of qubits. + + **Returns** + + A new, trivial [`PartialPauliPermutation`](#qiskit_noise_learning.sequences.PartialPauliPermutation "qiskit_noise_learning.sequences.PartialPauliPermutation"). + + + ### from\_qubit\_sparse\_paulis + + + Construct a `PartialPauliPermutation` that maps `in_pauli` to `out_pauli`. + + **Parameters** + + * **in\_pauli** – The Pauli to be mapped. + * **out\_pauli** – The Pauli to be mapped to. + + **Returns** + + A new [`PartialPauliPermutation`](#qiskit_noise_learning.sequences.PartialPauliPermutation "qiskit_noise_learning.sequences.PartialPauliPermutation") that maps `in_pauli` to `out_pauli`. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If `in_pauli` and `out_pauli` are not on the same number of qubits, or if they do not act on the same qubits. + + + ### from\_qubit\_sparse\_pauli\_lists + + + Construct a `PartialPauliPermutation` that maps `in_paulis` to `out_paulis`. + + **Parameters** + + * **in\_paulis** – The Paulis to be mapped. + * **out\_paulis** – The Paulis to be mapped to. + + **Returns** + + A new [`PartialPauliPermutation`](#qiskit_noise_learning.sequences.PartialPauliPermutation "qiskit_noise_learning.sequences.PartialPauliPermutation"). + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the number of qubits are inconsistent, or the implied permutations are inconsistent. + + + ### from\_sets + + + Construct from a list of sets. + + See the class documentation for a description of the expected format. + + **Parameters** + + **sets** – The sets specifying the partial permutation. + + **Returns** + + A new instance. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If any of the sets are not valid. + + + ### is\_mergeable\_with + + + Whether or not this instruction is mergeable with another one. + + Two instructions are mergeable if a third instruction exists that simultaneously implements both of their actions. The trivial case is when the instructions are equal: the third instruction can be a third instance of the same instruction. However, non-trivial cases are possible because some instruction types, notably [`PartialPauliPermutation`](#qiskit_noise_learning.sequences.PartialPauliPermutation "qiskit_noise_learning.sequences.PartialPauliPermutation"), do not necessarily fully specify their own action, so that unequal instances can nevertheless still have their constraints simultaneously satisfied by a single third instance. + + If this method returns `True`, then the method [`merge()`](#qiskit_noise_learning.sequences.PartialPauliPermutation.merge "qiskit_noise_learning.sequences.PartialPauliPermutation.merge") should succeed. + + **Parameters** + + **other** – The other instruction to check mergeablitity with. + + **Returns** + + Whether this instruction is mergeable with the other. + + + ### merge + + + Merge self and other into a single instruction. + + **Parameters** + + **other** – The other instruction to merge with. + + **Returns** + + Some instruction (possibly the same instance) that simultaneously implements the action of this instruction and the other instruction. + + + ### propagate + + + Given a Pauli, propagate it through the Clifford implied by this permutation. + + This method works for both phased and unphased propagation depending on the type of the Pauli supplied. Unphased propagation can be performed on incomplete permutations, so long as the permutation is defined on the Pauli. Phased propagation requires `self` to be complete, so that an explicit Clifford can be associated with this instance. + + **Parameters** + + **pauli** – The Pauli to apply the layer to. + + **Returns** + + The evolved Pauli. + + **Raises** + + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If `pauli.num_qubits != self.num_qubits`, or if `isinstance(pauli, PhasedQubitSparsePauli and not self.is_complete`, or if `pauli` is unphased and this instance is undefined on it. + * [**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError) – If `pauli` is an invalid type. + + + ### to\_sets + + + Return the set representation. + + + diff --git a/docs/api/qiskit-noise-learning/generated/sequences-path.mdx b/docs/api/qiskit-noise-learning/generated/sequences-path.mdx new file mode 100644 index 000000000000..0508fa31878f --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/sequences-path.mdx @@ -0,0 +1,155 @@ +--- +title: Path (latest version) +description: API reference for qiskit_noise_learning.sequences.Path in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: class +python_api_name: qiskit_noise_learning.sequences.Path +--- + + + +# qiskit\_noise\_learning.sequences.Path + + + Bases: `BaseSequence`\[[`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.fidelity_index.FidelityIndex")] + + A sequence of fidelity indices. + + **Parameters** + + * **start\_fragment** – The start of the sequence. + * **repeatable\_fragment** – The repeatable middle of the sequence. + * **end\_fragment** – The end of the sequence. + * **fragment\_depth** – The number of repetitions of the repeatable fragment. + + ### \_\_init\_\_ + + + + ## Methods + + | | | + | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | + | [`__init__`](#qiskit_noise_learning.sequences.Path.__init__ "qiskit_noise_learning.sequences.Path.__init__")(start\_fragment, ...\[, fragment\_depth]) | | + | `bind_at`(fragment\_depth) | Return a new instance with the same fragments bound to the fragment depth. | + | [`extend_permutations`](#qiskit_noise_learning.sequences.Path.extend_permutations "qiskit_noise_learning.sequences.Path.extend_permutations")(instruction\_sequence) | Return an instruction sequence with extended permutations to traverse self. | + | [`fragment_sign_flips`](#qiskit_noise_learning.sequences.Path.fragment_sign_flips "qiskit_noise_learning.sequences.Path.fragment_sign_flips")(instruction\_sequence) | Whether the instruction sequence fragments flip the observable sign when traversing self. | + | [`is_traversed_by`](#qiskit_noise_learning.sequences.Path.is_traversed_by "qiskit_noise_learning.sequences.Path.is_traversed_by")(instruction\_sequence) | Whether or not this path is traversed by the instruction sequence. | + | [`to_instruction_sequence`](#qiskit_noise_learning.sequences.Path.to_instruction_sequence "qiskit_noise_learning.sequences.Path.to_instruction_sequence")() | Return a minimally-specified instruction sequence that traverses this path. | + | `unbind`() | Return a new instance with the same fragments but fragment depth set to `None`. | + + ## Attributes + + | | | + | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | + | `end_fragment` | The ending fragment. | + | [`end_fragment_observable_idxs`](#qiskit_noise_learning.sequences.Path.end_fragment_observable_idxs "qiskit_noise_learning.sequences.Path.end_fragment_observable_idxs") | The observable indices of the end fragment. | + | `fragment_depth` | The number of repetitions of the repeatable fragment. | + | `is_unbound` | Whether the sequence is unbound. | + | `repeatable_fragment` | The repeatable fragment. | + | [`repeatable_fragment_observable_idxs`](#qiskit_noise_learning.sequences.Path.repeatable_fragment_observable_idxs "qiskit_noise_learning.sequences.Path.repeatable_fragment_observable_idxs") | The observable indices of the repeatable fragment. | + | `start_fragment` | The starting fragment. | + | [`start_fragment_observable_idxs`](#qiskit_noise_learning.sequences.Path.start_fragment_observable_idxs "qiskit_noise_learning.sequences.Path.start_fragment_observable_idxs") | The observable indices of the start fragment. | + + ### start\_fragment\_observable\_idxs + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`int`](https://docs.python.org/3/library/functions.html#int)]] + + The observable indices of the start fragment. + + + ### repeatable\_fragment\_observable\_idxs + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`int`](https://docs.python.org/3/library/functions.html#int)]] + + The observable indices of the repeatable fragment. + + + ### end\_fragment\_observable\_idxs + + + Type: [`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`list`](https://docs.python.org/3/library/stdtypes.html#list)\[[`int`](https://docs.python.org/3/library/functions.html#int)]] + + The observable indices of the end fragment. + + + ### extend\_permutations + + + Return an instruction sequence with extended permutations to traverse self. + + Given an `instruction_sequence`, this method attempts to extend its definition by constructing a new instruction sequence with the same structure as the input, but for which the [`PartialPauliPermutation`](sequences-partial-pauli-permutation "qiskit_noise_learning.sequences.PartialPauliPermutation")s are extended to specify the minimal superset of mappings required to traverse this path. If this is not possible, the function will return `None`, indicating that the procedure failed. + + In terms of the specific algorithm, when encountering a [`PartialPauliPermutation`](sequences-partial-pauli-permutation "qiskit_noise_learning.sequences.PartialPauliPermutation") while jointly iterating through `self` and `instruction_sequence`, this method will attempt to extend the permutation to map the current Pauli in the path to the Pauli in the next relevant [`FidelityIndex`](sequences-fidelity-index "qiskit_noise_learning.sequences.FidelityIndex"). Note that this can lead to failures in instances when multiple permutations occur in a row, even if it is technically possible to find a super instruction sequence that traverses the path. + + **Parameters** + + **instruction\_sequence** – The base instruction sequence. + + **Returns** + + The extended instruction sequence, or `None` if an extension is not possible. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the transitions of `self` do not start and end with the identity. + + + ### is\_traversed\_by + + + Whether or not this path is traversed by the instruction sequence. + + Whether or not a [`Path`](#qiskit_noise_learning.sequences.Path "qiskit_noise_learning.sequences.Path") is traversed by an [`InstructionSequence`](sequences-instruction-sequence "qiskit_noise_learning.sequences.InstructionSequence") is determined on a fragment-by-fragment basis. + + Requires the path starts and ends at the identity. + + **Parameters** + + **instruction\_sequence** – The instruction sequence. + + **Returns** + + Whether or not the path is traversed. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the path does not start and end at the identity. + + + ### fragment\_sign\_flips + + + Whether the instruction sequence fragments flip the observable sign when traversing self. + + Requires the path starts and ends at the identity. This method ignores the fragment depths of the path and instruction sequence, operating only on the fragment structure. + + **Parameters** + + **instruction\_sequence** – An instruction sequence that traverses this path. + + **Returns** + + A tuple of booleans, the first indicating whether the combined action of the start and end fragments flip the sign, and the second indicating whether the repeatable fragment flips the sign. + + **Raises** + + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the path does not satisfy the assumptions. + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the instruction sequence does not traverse the path. + + + ### to\_instruction\_sequence + + + Return a minimally-specified instruction sequence that traverses this path. + + The single-qubit Clifford layers between gate set elements are given as [`PartialPauliPermutation`](sequences-partial-pauli-permutation "qiskit_noise_learning.sequences.PartialPauliPermutation")s specifying only the mappings required to traverse this path. The fragment depth of the returned instruction sequence is `self.fragment_depth`. + + **Returns** + + An instruction sequence traversing this path. + + + diff --git a/docs/api/qiskit-noise-learning/generated/visualizations-fidelity-index-math-label.mdx b/docs/api/qiskit-noise-learning/generated/visualizations-fidelity-index-math-label.mdx new file mode 100644 index 000000000000..ee170ac1b10e --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/visualizations-fidelity-index-math-label.mdx @@ -0,0 +1,32 @@ +--- +title: fidelity_index_math_label (latest version) +description: API reference for qiskit_noise_learning.visualizations.fidelity_index_math_label in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: function +python_api_name: qiskit_noise_learning.visualizations.fidelity_index_math_label +--- + + + +# qiskit\_noise\_learning.visualizations.fidelity\_index\_math\_label + + + Return a math-mode LaTeX label for a fidelity index. + + **Parameters** + + * **gate\_set** – The gate set the fidelity index belongs to, used to look up the gate’s [`math_label`](gate-sets-gate#math_label "qiskit_noise_learning.gate_sets.Gate.math_label"). + * **fidelity\_index** – The fidelity index to label. + * **style** – Either `"transition"` (shows input $\to$ output Pauli) or `"formula"` (shows the index data [`pauli`](sequences-fidelity-index#pauli "qiskit_noise_learning.sequences.FidelityIndex.pauli") alongside the $Z$ exponents $x$ and $y$, displayed as the qubit indices on which they are non-zero, i.e. [`in_z_idxs`](sequences-fidelity-index#in_z_idxs "qiskit_noise_learning.sequences.FidelityIndex.in_z_idxs") and [`out_z_idxs`](sequences-fidelity-index#out_z_idxs "qiskit_noise_learning.sequences.FidelityIndex.out_z_idxs")). + * **noise\_site** – An optional mapping from gate name to `"before"` or `"after"`, indicating the gate noise is modelled as a Pauli-channel occuring either before or after the gate. This simplifies the `style="formula"` label to only display the Pauli passing through the Pauli channel. + * **qubit\_labels** – An optional mapping from qubit index to a display symbol, used to relabel the qubit subscripts (e.g. `{25: "i", 26: "j"}` renders `X_{25}` as `X_{i}`). Indices absent from the mapping render as their integer value. + + **Returns** + + A math-mode LaTeX label. + + **Raises** + + [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If `style` is not `"transition"` or `"formula"`. + + diff --git a/docs/api/qiskit-noise-learning/generated/visualizations-gate-set-topology.mdx b/docs/api/qiskit-noise-learning/generated/visualizations-gate-set-topology.mdx new file mode 100644 index 000000000000..446d0c1b4037 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/visualizations-gate-set-topology.mdx @@ -0,0 +1,35 @@ +--- +title: gate_set_topology (latest version) +description: API reference for qiskit_noise_learning.visualizations.gate_set_topology in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: function +python_api_name: qiskit_noise_learning.visualizations.gate_set_topology +--- + + + +# qiskit\_noise\_learning.visualizations.gate\_set\_topology + + + Draw the device topology with per-gate coloring. + + Gates with 2-qubit interactions are drawn as colored edges on the device coupling graph. Gates that act only on individual qubits (such as preparation and measurement) are shown as colored arcs around the relevant nodes, with one arc sector per gate per qubit. The arc sectors are arranged so that the first gate in the set occupies the right-hand side of the circle (angle 0), and subsequent gates proceed counter-clockwise. Qubits that are idling in a given gate receive a slightly transparent arc. + + Two legends switch what is shown: one per gate, and one per kind of mark. Gates that only prepare or only measure open switched off, since they touch every qubit at once and would otherwise bury the rest; their legend entry brings them back. + + Qubits are placed in the device’s conventional layout where it has one, and laid out from its coupling graph otherwise. A target that constrains connectivity nowhere – an ideal or all-to-all device – has no topology to draw and no graph to lay out from, so its qubits are drawn without edges, in the conventional layout if its size has one. + + **Parameters** + + **gate\_set** – The gate set to visualize. Must have a non-`None` [`target`](gate-sets-gate-set#target "qiskit_noise_learning.gate_sets.GateSet.target") so that qubit coordinates and the device topology can be determined. + + **Returns** + + The figure. + + **Raises** + + * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If `gate_set.target` is `None`, or if the device’s size is not one of the conventionally drawn ones and its target constrains connectivity nowhere, leaving no coupling graph to derive a layout from. + * [**ImportError**](https://docs.python.org/3/library/exceptions.html#ImportError) – If `matplotlib` is not installed. + + diff --git a/docs/api/qiskit-noise-learning/generated/visualizations-path-math-label.mdx b/docs/api/qiskit-noise-learning/generated/visualizations-path-math-label.mdx new file mode 100644 index 000000000000..8a39db806019 --- /dev/null +++ b/docs/api/qiskit-noise-learning/generated/visualizations-path-math-label.mdx @@ -0,0 +1,29 @@ +--- +title: path_math_label (latest version) +description: API reference for qiskit_noise_learning.visualizations.path_math_label in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 1 +python_api_type: function +python_api_name: qiskit_noise_learning.visualizations.path_math_label +--- + + + +# qiskit\_noise\_learning.visualizations.path\_math\_label + + + Return a math-mode LaTeX label for a path. + + **Parameters** + + * **gate\_set** – The gate set the path’s fidelity indices belong to, used to look up each gate’s [`math_label`](gate-sets-gate#math_label "qiskit_noise_learning.gate_sets.Gate.math_label"). + * **path** – The path to label. + * **style** – The style to use for each fidelity index label. `"transition"` displays the Pauli operator transitions induced by each gate, and `"formula"` displays the fidelity label formula associated with this path. + * **noise\_site** – An optional noise-site mapping forwarded to [`fidelity_index_math_label()`](visualizations-fidelity-index-math-label "qiskit_noise_learning.visualizations.fidelity_index_math_label") for the `"formula"` style (see that function for details). + * **repeatable\_only** – If `True`, only render the repeatable fragment without brackets or fragment-depth exponent. + * **qubit\_labels** – An optional mapping from qubit index to a display symbol, used to relabel the qubit subscripts (e.g. `{25: "i", 26: "j"}` renders `X_{25}` as `X_{i}`). Indices absent from the mapping render as their integer value. + + **Returns** + + A math-mode LaTeX label. + + diff --git a/docs/api/qiskit-noise-learning/index.mdx b/docs/api/qiskit-noise-learning/index.mdx new file mode 100644 index 000000000000..54bb421dc0a3 --- /dev/null +++ b/docs/api/qiskit-noise-learning/index.mdx @@ -0,0 +1,19 @@ +--- +title: Qiskit noise learning API documentation (latest version) +description: Index of all the modules in the latest version of qiskit-noise-learning. +--- + +# API reference + +* [Aer executor (`qiskit_noise_learning.aer_executor`)](aer-executor) +* [Analysis (`qiskit_noise_learning.analysis`)](analysis) +* [Circuit generator (`qiskit_noise_learning.circuit_generator`)](circuit-generator) +* [Data (`qiskit_noise_learning.data`)](data) +* [Experiment builder (`qiskit_noise_learning.experiment_builder`)](experiment-builder) +* [Gate sets (`qiskit_noise_learning.gate_sets`)](gate-sets) +* [Math (`qiskit_noise_learning.math`)](math) +* [Models (`qiskit_noise_learning.models`)](models) +* [Noise learner (`qiskit_noise_learning.noise_learner`)](noise-learner) +* [Sequences (`qiskit_noise_learning.sequences`)](sequences) +* [Visualizations (`qiskit_noise_learning.visualizations`)](visualizations) + diff --git a/docs/api/qiskit-noise-learning/math.mdx b/docs/api/qiskit-noise-learning/math.mdx new file mode 100644 index 000000000000..d4b5001b9606 --- /dev/null +++ b/docs/api/qiskit-noise-learning/math.mdx @@ -0,0 +1,29 @@ +--- +title: math (latest version) +description: API reference for qiskit_noise_learning.math in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 2 +python_api_type: module +python_api_name: qiskit_noise_learning.math +--- + + + + + +# Math + +`qiskit_noise_learning.math` + +General mathematical objects. + +## Classes + +| | | +| ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | +| [`IndexedMatrix`](generated/math-indexed-matrix "qiskit_noise_learning.math.IndexedMatrix") | A matrix with float entries and arbitrary row and column index data. | +| [`EnumeratedIndexedSpace`](generated/math-enumerated-indexed-space "qiskit_noise_learning.math.EnumeratedIndexedSpace") | An indexed space backed by an explicit finite collection of indices. | +| [`IndexedSpace`](generated/math-indexed-space "qiskit_noise_learning.math.IndexedSpace") | Abstract description of a vector space with arbitrary basis index types. | +| [`IndexedVector`](generated/math-indexed-vector "qiskit_noise_learning.math.IndexedVector") | A vector of floats with arbitrary index, or axis label, data. | +| [`ComposedLinearMap`](generated/math-composed-linear-map "qiskit_noise_learning.math.ComposedLinearMap") | A linear map formed by composing a chain of maps. | +| [`LinearMap`](generated/math-linear-map "qiskit_noise_learning.math.LinearMap") | An implicit linear map between two indexed spaces. | + diff --git a/docs/api/qiskit-noise-learning/models.mdx b/docs/api/qiskit-noise-learning/models.mdx new file mode 100644 index 000000000000..2f7e6d3bf09e --- /dev/null +++ b/docs/api/qiskit-noise-learning/models.mdx @@ -0,0 +1,46 @@ +--- +title: models (latest version) +description: API reference for qiskit_noise_learning.models in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 2 +python_api_type: module +python_api_name: qiskit_noise_learning.models +--- + + + + + +# Models + +`qiskit_noise_learning.models` + +Gate set noise models. + +## Classes + +| | | +| ------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`IdentityFidelityModel`](generated/models-identity-fidelity-model "qiskit_noise_learning.models.IdentityFidelityModel") | A fidelity model whose parameters are the log fidelities themselves. | +| [`LogFidelitySpace`](generated/models-log-fidelity-space "qiskit_noise_learning.models.LogFidelitySpace") | The space of log fidelities of a gate set. | +| [`GeneratorIndex`](generated/models-generator-index "qiskit_noise_learning.models.GeneratorIndex") | | +| [`PauliLindbladModel`](generated/models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel") | A linear mapping from Pauli-Lindblad generator rates to log fidelities. | +| [`RateSpace`](generated/models-rate-space "qiskit_noise_learning.models.RateSpace") | Space of Pauli-Lindblad generator rates, indexed by [`GeneratorIndex`](generated/models-generator-index "qiskit_noise_learning.models.GeneratorIndex"). | +| [`PauliLindbladSplit`](generated/models-pauli-lindblad-split "qiskit_noise_learning.models.PauliLindbladSplit") | The decomposition of a map around its underlying [`PauliLindbladModel`](generated/models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"). | + +## Functions + +| | | +| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`contains_pauli_lindblad_model`](generated/models-contains-pauli-lindblad-model "qiskit_noise_learning.models.contains_pauli_lindblad_model")(model) | Whether a map is, or contains, a [`PauliLindbladModel`](generated/models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"). | +| [`get_noise_site`](generated/models-get-noise-site "qiskit_noise_learning.models.get_noise_site")(model) | The noise-site mapping of the map's [`PauliLindbladModel`](generated/models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"), if it has exactly one. | +| [`is_fidelity_model`](generated/models-is-fidelity-model "qiskit_noise_learning.models.is_fidelity_model")(model) | Whether an object is a [`LinearMap`](generated/math-linear-map "qiskit_noise_learning.math.LinearMap") with a [`LogFidelitySpace`](generated/models-log-fidelity-space "qiskit_noise_learning.models.LogFidelitySpace") output space. | +| [`split_pauli_lindblad_model`](generated/models-split-pauli-lindblad-model "qiskit_noise_learning.models.split_pauli_lindblad_model")(model) | Split a map around its underlying [`PauliLindbladModel`](generated/models-pauli-lindblad-model "qiskit_noise_learning.models.PauliLindbladModel"). | + +## Type aliases + +### qiskit\_noise\_learning.models.FidelityModel + + + alias of [`LinearMap`](generated/math-linear-map "qiskit_noise_learning.math.linear_map.LinearMap")\[[`Hashable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable), [`FidelityIndex`](generated/sequences-fidelity-index "qiskit_noise_learning.sequences.fidelity_index.FidelityIndex")] + + diff --git a/docs/api/qiskit-noise-learning/noise-learner.mdx b/docs/api/qiskit-noise-learning/noise-learner.mdx new file mode 100644 index 000000000000..13d22d8e7590 --- /dev/null +++ b/docs/api/qiskit-noise-learning/noise-learner.mdx @@ -0,0 +1,29 @@ +--- +title: noise_learner (latest version) +description: API reference for qiskit_noise_learning.noise_learner in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 2 +python_api_type: module +python_api_name: qiskit_noise_learning.noise_learner +--- + + + + + +# Noise learner + +`qiskit_noise_learning.noise_learner` + +Noise learner. + +## Classes + +| | | +| ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [`LearningOptions`](generated/noise-learner-learning-options "qiskit_noise_learning.noise_learner.LearningOptions") | Options for the noise learner. | +| [`NoiseLearner`](generated/noise-learner-noise-learner "qiskit_noise_learning.noise_learner.NoiseLearner") | A noise learner. | +| [`NoiseLearnerJob`](generated/noise-learner-noise-learner-job "qiskit_noise_learning.noise_learner.NoiseLearnerJob") | A noise learner job. | +| [`NoiseLearnerResult`](generated/noise-learner-noise-learner-result "qiskit_noise_learning.noise_learner.NoiseLearnerResult") | Result of noise learning. | +| [`ProgramExecutor`](generated/noise-learner-program-executor "qiskit_noise_learning.noise_learner.ProgramExecutor") | The executor role that [`NoiseLearner`](generated/noise-learner-noise-learner "qiskit_noise_learning.noise_learner.NoiseLearner") submits programs to. | +| [`ProgramJob`](generated/noise-learner-program-job "qiskit_noise_learning.noise_learner.ProgramJob") | The job role that [`NoiseLearnerJob`](generated/noise-learner-noise-learner-job "qiskit_noise_learning.noise_learner.NoiseLearnerJob") wraps. | + diff --git a/docs/api/qiskit-noise-learning/sequences.mdx b/docs/api/qiskit-noise-learning/sequences.mdx new file mode 100644 index 000000000000..3e157dd18036 --- /dev/null +++ b/docs/api/qiskit-noise-learning/sequences.mdx @@ -0,0 +1,36 @@ +--- +title: sequences (latest version) +description: API reference for qiskit_noise_learning.sequences in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 2 +python_api_type: module +python_api_name: qiskit_noise_learning.sequences +--- + + + + + +# Sequences + +`qiskit_noise_learning.sequences` + +Path and instruction sequences. + +## Classes + +| | | +| ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| [`ApplyGate`](generated/sequences-apply-gate "qiskit_noise_learning.sequences.ApplyGate") | An instruction that applies a fixed gate. | +| [`FidelityIndex`](generated/sequences-fidelity-index "qiskit_noise_learning.sequences.FidelityIndex") | Index data for a fidelity in a Pauli-MCM-reset gate set. | +| [`InstructionSequence`](generated/sequences-instruction-sequence "qiskit_noise_learning.sequences.InstructionSequence") | A sequence of instructions. | +| [`LogPathMap`](generated/sequences-log-path-map "qiskit_noise_learning.sequences.LogPathMap") | The linear map from a space of log fidelities to its associated log path space. | +| [`LogPathSpace`](generated/sequences-log-path-space "qiskit_noise_learning.sequences.LogPathSpace") | The (infinite-dimensional) space of log path-fidelities. | +| [`PartialPauliPermutation`](generated/sequences-partial-pauli-permutation "qiskit_noise_learning.sequences.PartialPauliPermutation") | Partially-specified permutations of the single-qubit phaseless Paulis on `n` qubits. | +| [`Path`](generated/sequences-path "qiskit_noise_learning.sequences.Path") | A sequence of fidelity indices. | + +## Functions + +| | | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| [`group_mergeable_instruction_sequences`](generated/sequences-group-mergeable-instruction-sequences "qiskit_noise_learning.sequences.group_mergeable_instruction_sequences") | Group the positions of instruction sequences that can be merged with each other. | + diff --git a/docs/api/qiskit-noise-learning/visualizations.mdx b/docs/api/qiskit-noise-learning/visualizations.mdx new file mode 100644 index 000000000000..abdafa964ff1 --- /dev/null +++ b/docs/api/qiskit-noise-learning/visualizations.mdx @@ -0,0 +1,26 @@ +--- +title: visualizations (latest version) +description: API reference for qiskit_noise_learning.visualizations in the latest version of qiskit-noise-learning +in_page_toc_min_heading_level: 2 +python_api_type: module +python_api_name: qiskit_noise_learning.visualizations +--- + + + + + +# Visualizations + +`qiskit_noise_learning.visualizations` + +Visualization utilities. + +## Functions + +| | | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | +| [`fidelity_index_math_label`](generated/visualizations-fidelity-index-math-label "qiskit_noise_learning.visualizations.fidelity_index_math_label")(gate\_set, ...\[, ...]) | Return a math-mode LaTeX label for a fidelity index. | +| [`path_math_label`](generated/visualizations-path-math-label "qiskit_noise_learning.visualizations.path_math_label")(gate\_set, path\[, style, ...]) | Return a math-mode LaTeX label for a path. | +| [`gate_set_topology`](generated/visualizations-gate-set-topology "qiskit_noise_learning.visualizations.gate_set_topology")(gate\_set) | Draw the device topology with per-gate coloring. | + diff --git a/docs/guides/addons.mdx b/docs/guides/addons.mdx index 7bd38794af9a..e3623129f2a0 100644 --- a/docs/guides/addons.mdx +++ b/docs/guides/addons.mdx @@ -68,15 +68,15 @@ These capabilities are useful for reducing circuit depth and typically come with /> -## Manage noise for expectation value estimation -Use the following addons to manage noise when building quantum workloads that estimate expectation values of observables. +## Learn noise models +Use the following tools for learning and refining noise models as part of your error mitigation strategy +## Manage noise for expectation value estimation +Use the following addons to manage noise when building quantum workloads that estimate expectation values of observables. + + + + + + ## Manage noise for sampling results These techniques are useful for managing noise on sampling results. diff --git a/public/docs/api/qiskit-noise-learning/objects.inv b/public/docs/api/qiskit-noise-learning/objects.inv new file mode 100644 index 000000000000..f560111d4d8e Binary files /dev/null and b/public/docs/api/qiskit-noise-learning/objects.inv differ diff --git a/public/docs/images/addons/qiskit-noise-learning/cbfeb7989573772757ac81e9b3a0665f8a0513450d76bfc5ab63e24f40c6b8f6.avif b/public/docs/images/addons/qiskit-noise-learning/cbfeb7989573772757ac81e9b3a0665f8a0513450d76bfc5ab63e24f40c6b8f6.avif new file mode 100644 index 000000000000..a366873d0c33 Binary files /dev/null and b/public/docs/images/addons/qiskit-noise-learning/cbfeb7989573772757ac81e9b3a0665f8a0513450d76bfc5ab63e24f40c6b8f6.avif differ diff --git a/scripts/config/api-html-artifacts.json b/scripts/config/api-html-artifacts.json index 2ab461d8eb8e..cea0fcc878c5 100644 --- a/scripts/config/api-html-artifacts.json +++ b/scripts/config/api-html-artifacts.json @@ -136,6 +136,9 @@ "qiskit-addon-slc": { "0.1": "https://ibm.box.com/shared/static/87gic8sr1vc85y4g6g1h0x6gk1eb1sqw.zip" }, + "qiskit-noise-learning": { + "0.1": "https://ibm.box.com/shared/static/pv4b1gvfivkbsceup6kkveov15k0naqi.zip" + }, "qiskit-addon-utils": { "0.4": "https://ibm.box.com/shared/static/j9qms9f2wfzo7fdfwnm2ns8rdjrhje7h.zip", "0.3": "https://ibm.box.com/shared/static/921yb7b7162e20a9b7ojgzhc1erxhgzd.zip", diff --git a/scripts/config/historical-pages-to-latest.json b/scripts/config/historical-pages-to-latest.json index 78ba660cb4f2..d281ef8001df 100644 --- a/scripts/config/historical-pages-to-latest.json +++ b/scripts/config/historical-pages-to-latest.json @@ -1587,5 +1587,89 @@ "qiskit-fermions": {}, "qiskit-fermions-c": {}, "pauli-prop": {}, - "qiskit-addon-slc": {} + "qiskit-addon-slc": {}, + "qiskit-noise-learning": { + "generated": { + "aer-executor-aer-executor": "/", + "aer-executor-aer-runtime-job": "/", + "aer-executor-inline-samplexes": "/", + "analysis-analysis-pipeline": "/", + "analysis-analysis-stage": "/", + "analysis-average-observables": "/", + "analysis-compute-observables": "/", + "analysis-curve-fit-observables": "/", + "analysis-fit": "/", + "analysis-flip-post-select": "/", + "analysis-legacy-solve": "/", + "analysis-linear-system-data": "/", + "analysis-lsq-linear-solve": "/", + "analysis-nnls-solve": "/", + "analysis-positivity-min-solve": "/", + "analysis-symmetrize-fidelities": "/", + "analysis-symmetrize-generators": "/", + "analysis-zero-post-select": "/", + "circuit-generator-executor-circuit-generator": "/", + "circuit-generator-executor-data-mapper": "/", + "data-aggregated-observable-data": "/", + "data-leveled-data": "/", + "data-model-data": "/", + "data-observable-data": "/", + "data-raw-data": "/", + "experiment-builder-add-instruction-sequences": "/", + "experiment-builder-add-paths": "/", + "experiment-builder-bind-fragment-depths": "/", + "experiment-builder-complete-sequences": "/", + "experiment-builder-depth-1-paths": "/", + "experiment-builder-even-depth-paths": "/", + "experiment-builder-even-depth-vanilla-paths": "/", + "experiment-builder-experiment-builder-stage": "/", + "experiment-builder-experiment-builder": "/", + "experiment-builder-experiment": "/", + "experiment-builder-generate-instruction-sequences": "/", + "experiment-builder-identify-relations": "/", + "experiment-builder-merge-instruction-sequences": "/", + "experiment-builder-rank-reduce-paths": "/", + "experiment-builder-spam-paths": "/", + "experiment-builder-vanilla-instruction-sequences": "/", + "gate-sets-gate-set": "/", + "gate-sets-gate": "/", + "gate-sets-model-gate-set": "/", + "gate-sets-model-gate": "/", + "gate-sets-qiskit-gate-set": "/", + "gate-sets-qiskit-gate": "/", + "math-composed-linear-map": "/", + "math-enumerated-indexed-space": "/", + "math-indexed-matrix": "/", + "math-indexed-space": "/", + "math-indexed-vector": "/", + "math-linear-map": "/", + "models-contains-pauli-lindblad-model": "/", + "models-generator-index": "/", + "models-get-noise-site": "/", + "models-identity-fidelity-model": "/", + "models-is-fidelity-model": "/", + "models-log-fidelity-space": "/", + "models-pauli-lindblad-model": "/", + "models-pauli-lindblad-split": "/", + "models-rate-space": "/", + "models-split-pauli-lindblad-model": "/", + "noise-learner-learning-options": "/", + "noise-learner-noise-learner-job": "/", + "noise-learner-noise-learner-result": "/", + "noise-learner-noise-learner": "/", + "noise-learner-program-executor": "/", + "noise-learner-program-job": "/", + "sequences-apply-gate": "/", + "sequences-fidelity-index": "/", + "sequences-group-mergeable-instruction-sequences": "/", + "sequences-instruction-sequence": "/", + "sequences-log-path-map": "/", + "sequences-log-path-space": "/", + "sequences-partial-pauli-permutation": "/", + "sequences-path": "/", + "visualizations-fidelity-index-math-label": "/", + "visualizations-gate-set-topology": "/", + "visualizations-path-math-label": "/" + } + } } diff --git a/scripts/js/lib/api/Pkg.ts b/scripts/js/lib/api/Pkg.ts index 06c2ec7ec703..76918c2490d8 100644 --- a/scripts/js/lib/api/Pkg.ts +++ b/scripts/js/lib/api/Pkg.ts @@ -74,6 +74,7 @@ export class Pkg { "qiskit-fermions-c", "pauli-prop", "qiskit-addon-slc", + "qiskit-noise-learning", ]; static VALID_NAMES = [ @@ -290,6 +291,15 @@ export class Pkg { language: "Python", }); } + if (name === "qiskit-noise-learning") { + return new Pkg({ + ...args, + title: "Qiskit noise learning", + githubSlug: "Qiskit/qiskit-noise-learning", + kebabCaseAndShortenUrls: true, + language: "Python", + }); + } if (name === "qiskit-c") { return new Pkg({ diff --git a/scripts/js/lib/api/apiDocsPipeline.ts b/scripts/js/lib/api/apiDocsPipeline.ts index 7538fcd04a44..4ac6a827acd7 100644 --- a/scripts/js/lib/api/apiDocsPipeline.ts +++ b/scripts/js/lib/api/apiDocsPipeline.ts @@ -85,8 +85,13 @@ async function determineFilePaths( : ObjectsInv.fromFile(htmlPath, pkg.language)); const extraFiles = pkg.isCApi() - ? [`${C_API_BASE_PATH}/**.html`, "apidocs/**.html"] - : ["apidocs/**.html", "apidoc/**.html", "stubs/**.html", "pydoc/**.html"]; + ? [`${C_API_BASE_PATH}/**.html`, "apidocs/**/**.html"] + : [ + "apidocs/**/**.html", + "apidoc/**/**.html", + "stubs/**/**.html", + "pydoc/**/**.html", + ]; const files = await globby( [...extraFiles, "release_notes.html", "release-notes.html"], { diff --git a/scripts/js/lib/api/htmlToMd.ts b/scripts/js/lib/api/htmlToMd.ts index df6f15289d03..47efc19a19e2 100644 --- a/scripts/js/lib/api/htmlToMd.ts +++ b/scripts/js/lib/api/htmlToMd.ts @@ -137,7 +137,12 @@ function prepareHandlers(meta: Metadata): Record { return buildApiVersionAdmonition(node, handlers, "info"); } - return node.properties.id && nodeClasses.includes("section") + // `math-wrapper` divs carry the anchor ID for numbered Sphinx equations + // (e.g. `id="equation-foo"`), which is otherwise dropped by the default + // div handler since it isn't a `section`. + return node.properties.id && + (nodeClasses.includes("section") || + nodeClasses.includes("math-wrapper")) ? [buildSpanId(node.properties.id), ...all(h, node)] : defaultHandlers.div(h, node); }, @@ -264,7 +269,7 @@ function buildAdmonition( { type: "mdxJsxAttribute", name: "title", - value: toText(titleNode), + value: titleNode ? toText(titleNode) : "", }, { type: "mdxJsxAttribute", diff --git a/scripts/js/lib/api/pipelineStages.ts b/scripts/js/lib/api/pipelineStages.ts index 6f2682817609..4e2cdafa9175 100644 --- a/scripts/js/lib/api/pipelineStages.ts +++ b/scripts/js/lib/api/pipelineStages.ts @@ -163,8 +163,16 @@ function rewriteApiDocsLinks(results: HtmlToMdResultWithUrl[], pkg: Pkg) { const targetPkg = pkg.isCApi() ? pythonSiblingPkg : pkg.name; const targetUsesKebab = pkg.kebabCaseAndShortenUrls && targetPkg !== "qiskit"; + // `page` may include a nested folder, e.g. `generated/qiskit_pkg.Foo`. + // Kebab-case only the final segment so folder separators survive — + // kebabCase() itself would otherwise turn `generated/foo` into + // `generated-foo`. + const pageParts = page.split("/"); const kebabPage = targetUsesKebab - ? kebabCaseAndShortenPage(page, targetPkg) + ? [ + ...pageParts.slice(0, -1), + kebabCaseAndShortenPage(pageParts.at(-1)!, targetPkg), + ].join("/") : page; return `](${pythonApiBase}/${kebabPage}${anchor ?? ""})`; }, @@ -178,6 +186,16 @@ function rewriteApiDocsLinks(results: HtmlToMdResultWithUrl[], pkg: Pkg) { "g", ), `](${apiBase}/release-notes$1)`, + ) + // Addon API reference pages link back to guides with paths relative to + // the sphinx source tree (e.g. `../../guides/formalism#anchor`). + // Rewrite these to the guide's absolute path under docs/addons. + .replace( + /\]\((?:\.\.\/)*guides\/([^)#]+)(#[^)]+)?\)/g, + (match, page, anchor) => + pkg.isAddon() + ? `](${DOCS_BASE_PATH}/addons/${pkg.name}/guides/${page}${anchor ?? ""})` + : match, ); } }