Skip to content

Commit

Permalink
Specify optimization level with generate_preset_pass_manager (#868)
Browse files Browse the repository at this point in the history
Closes #866
  • Loading branch information
abbycross authored Feb 22, 2024
1 parent 1fb3fdf commit 9e6a7e2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/run/configure-runtime-compilation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ psi = RealAmplitudes(num_qubits=2, reps=2)
H = SparsePauliOp.from_list([("II", 1), ("IZ", 2), ("XI", 3)])
theta = [0, 1, 1, 2, 3, 5]

pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
psi = pm.run(psi)
H = H.apply_layout(psi.layout)

Expand Down
2 changes: 1 addition & 1 deletion docs/run/estimate-job-run-time.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ qc.measure(1, 1)
backend = service.least_busy(simulator=False,operational=True)

# Generate ISA circuits
pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(qc)

# Create a Sampler object
Expand Down
16 changes: 8 additions & 8 deletions docs/run/primitives-examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mat = np.real(random_hermitian(n_qubits, seed=1234))
circuit = IQP(mat)
observable = SparsePauliOp("Z" * n_qubits)

pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(circuit)
isa_observable = observable.apply_layout(isa_circuit.layout)

Expand Down Expand Up @@ -81,7 +81,7 @@ observables = [
SparsePauliOp("Z" * n_qubits),
]

pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuits = pm.run(circuits)
isa_observables = [ob.apply_layout(isa_circuits[0].layout) for ob in observables]

Expand Down Expand Up @@ -115,7 +115,7 @@ parameter_values = [
]
observable = SparsePauliOp("Z" * 127)

pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(circuit)
isa_observable = observable.apply_layout(isa_circuit.layout)

Expand Down Expand Up @@ -146,7 +146,7 @@ another_circuit = IQP(mat)
observable = SparsePauliOp("X" * n_qubits)
another_observable = SparsePauliOp("Y" * n_qubits)

pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(circuit)
another_isa_circuit = pm.run(another_circuit)
isa_observable = observable.apply_layout(isa_circuit.layout)
Expand Down Expand Up @@ -199,7 +199,7 @@ mat = np.real(random_hermitian(n_qubits, seed=1234))
circuit = IQP(mat)
circuit.measure_all()

pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(circuit)

sampler = Sampler(backend)
Expand Down Expand Up @@ -233,7 +233,7 @@ circuits = [IQP(mat) for mat in mats]
for circuit in circuits:
circuit.measure_all()

pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuits = pm.run(circuits)

sampler = Sampler(backend)
Expand All @@ -260,7 +260,7 @@ backend = service.get_backend("ibm_brisbane")
circuit = RealAmplitudes(num_qubits=127, reps=2)
circuit.measure_all()

pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(circuit)

# Define three sets of parameters for the circuit
Expand Down Expand Up @@ -297,7 +297,7 @@ mat = np.real(random_hermitian(n_qubits, seed=rng))
another_circuit = IQP(mat)
another_circuit.measure_all()

pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(circuit)
another_isa_circuit = pm.run(another_circuit)

Expand Down
4 changes: 2 additions & 2 deletions docs/run/primitives-get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ print(f">>> Observable: {observable.paulis}")
The circuit and observable need to be transformed to only use instructions supported by the system. We'll use the transpiler to do this.

```python
pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(circuit)
isa_observable = observable.apply_layout(isa_circuit.layout)
```
Expand Down Expand Up @@ -123,7 +123,7 @@ circuit.measure_all()
Again, we use the transpiler to get an ISA circuit.

```python
pm = generate_preset_pass_manager(backend=backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(circuit)
```

Expand Down
2 changes: 1 addition & 1 deletion docs/start/hello-world.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"source": [
"from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager\n",
"\n",
"pm = generate_preset_pass_manager(backend=backend)\n",
"pm = generate_preset_pass_manager(backend=backend, optimization_level=1)\n",
"isa_circuit = pm.run(qc)\n",
"ZZ = ZZ.apply_layout(isa_circuit.layout)\n",
"ZI = ZI.apply_layout(isa_circuit.layout)\n",
Expand Down

0 comments on commit 9e6a7e2

Please sign in to comment.