aer
¶
Run shot circuits on Qiskit Aer.
AerCircuitBackend
¶
Run a program on Qiskit Aer and return shot counts.
The program is translated to a Qiskit circuit and transpiled for
AerSimulator. A set seed is passed as seed_simulator.
basis_gates is passed the same way when it is set. z_expectations
and x_expectations estimate Pauli expectations from those counts.
depth, width, gate_count, t_count, and toffoli_count
read that transpiled circuit. A unitary stays one instruction, so t
and ccx counts stay zero unless transpilation emits those names.
Attributes:
-
name–"aer". Stored on simulation result metadata. -
shots–Shot budget passed to each
run_countscall by a simulator. -
basis_gates–Gate names passed to
AerSimulator, orNonefor Aer's own basis. -
BASIS_GATE_NAMES–Gate names
basis_gatesmay contain.
Source code in shadowsim/backends/aer.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
__init__
¶
Store the shot budget and optional compilation basis.
Parameters:
-
shots(int, default:10000) –Number of shots for each circuit. Must be a positive integer.
-
basis_gates(Sequence[str] | None, default:None) –Gate names
transpilemay use.Nonekeeps Aer's own basis. Names are stripped, lowercased, and de-duplicated. Each name must be inBASIS_GATE_NAMES.
Raises:
-
ValueError–shotsis not a positive integer,basis_gatesis not a sequence of gate names, the sequence is empty, or a name is not a gate Aer can compile into.
Source code in shadowsim/backends/aer.py
run_counts
¶
run_counts(
program: Program, *, shots: int, seed: int | None
) -> dict[str, int]
Translate program to Qiskit, transpile that for Aer, and return counts.
Parameters:
-
program(Program) –Program to execute.
-
shots(int) –Number of shots.
-
seed(int | None) –Passed as
seed_simulatorwhen set. Omitted whenNone.
Returns:
-
dict[str, int]–Mapping from bitstring to shot count.
Raises:
-
ValueError–programcannot be compiled intobasis_gates.
Source code in shadowsim/backends/aer.py
z_expectations
¶
z_expectations(
program: Program,
qubits: Sequence[int],
*,
shots: int,
seed: int | None,
) -> list[float]
Estimate ⟨Z⟩ on qubits from computational-basis shots.
Parameters:
-
program(Program) –Program to execute, before the computational-basis measurement.
-
qubits(Sequence[int]) –0-based indexes in
program. The result follows this order. -
shots(int) –Number of shots.
-
seed(int | None) –Passed as
seed_simulatorwhen set. Omitted whenNone.
Returns:
-
list[float]–One estimate per entry of
qubits, each(n0 - n1) / shots.
Raises:
-
ValueError–An index is outside
program, orprogramcannot be compiled intobasis_gates.
Source code in shadowsim/backends/aer.py
x_expectations
¶
x_expectations(
program: Program,
qubits: Sequence[int],
*,
shots: int,
seed: int | None,
) -> list[float]
Estimate ⟨X⟩ on qubits by applying Hadamard and then measuring.
Parameters:
-
program(Program) –Program to execute, before the X-basis measurement.
-
qubits(Sequence[int]) –0-based indexes in
program. The result follows this order. -
shots(int) –Number of shots.
-
seed(int | None) –Passed as
seed_simulatorwhen set. Omitted whenNone.
Returns:
-
list[float]–One estimate per entry of
qubits, each(n0 - n1) / shots.
Raises:
-
ValueError–An index is outside
program, orprogramcannot be compiled intobasis_gates.
Source code in shadowsim/backends/aer.py
depth
¶
depth(program: Program) -> int
Return the depth of program after transpilation for Aer.
Parameters:
-
program(Program) –Program to measure. It is translated and transpiled for this basis.
Returns:
-
int–Length of the critical path on the transpiled circuit.
Raises:
-
ValueError–programcannot be compiled intobasis_gates.
Source code in shadowsim/backends/aer.py
width
¶
width(program: Program) -> int
Return the qubit count of program after transpilation for Aer.
Parameters:
-
program(Program) –Program to measure. It is translated and transpiled for this basis.
Returns:
-
int–Number of qubits on the transpiled circuit. Classical bits are not included.
Raises:
-
ValueError–programcannot be compiled intobasis_gates.
Source code in shadowsim/backends/aer.py
gate_count
¶
gate_count(program: Program) -> int
Return the instruction count of program after transpilation for Aer.
Parameters:
-
program(Program) –Program to measure. It is translated and transpiled for this basis.
Returns:
-
int–Total number of instructions on the transpiled circuit, including
-
int–measurements when
programcontains them.
Raises:
-
ValueError–programcannot be compiled intobasis_gates.
Source code in shadowsim/backends/aer.py
t_count
¶
t_count(program: Program) -> int
Return the number of t gates after transpilation for Aer.
tdg is not included. A multi-qubit unitary stays one instruction, so
a program built only from unitaries reports zero.
Parameters:
-
program(Program) –Program to measure. It is translated and transpiled for this basis.
Returns:
-
int–Count of instructions named
t.
Raises:
-
ValueError–programcannot be compiled intobasis_gates.
Source code in shadowsim/backends/aer.py
toffoli_count
¶
toffoli_count(program: Program) -> int
Return the number of ccx and ccz gates after transpilation for Aer.
A multi-qubit unitary stays one instruction, so a program built only from unitaries reports zero.
Parameters:
-
program(Program) –Program to measure. It is translated and transpiled for this basis.
Returns:
-
int–Sum of
ccxandcczinstructions.
Raises:
-
ValueError–programcannot be compiled intobasis_gates.