From bc63e26bb6881f65e9c8f51c70cb260008ebf95b Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Thu, 22 Feb 2024 10:00:10 -0500 Subject: [PATCH 1/3] Specify optimization level with generate_preset_pass_manager --- docs/run/primitives-get-started.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/run/primitives-get-started.mdx b/docs/run/primitives-get-started.mdx index 2a83e6de91c..2c03da0b364 100644 --- a/docs/run/primitives-get-started.mdx +++ b/docs/run/primitives-get-started.mdx @@ -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) ``` @@ -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) ``` From e2fcee093a9f63c49decad96d3e502d5ca8e3347 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Thu, 22 Feb 2024 10:09:56 -0500 Subject: [PATCH 2/3] add in optimization_level --- docs/run/configure-runtime-compilation.mdx | 2 +- docs/run/estimate-job-run-time.mdx | 2 +- docs/run/primitives-examples.mdx | 16 ++++++++-------- docs/start/hello-world.ipynb | 10 ++++++++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/run/configure-runtime-compilation.mdx b/docs/run/configure-runtime-compilation.mdx index 62621d35b1f..c673d0ff7a9 100644 --- a/docs/run/configure-runtime-compilation.mdx +++ b/docs/run/configure-runtime-compilation.mdx @@ -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) diff --git a/docs/run/estimate-job-run-time.mdx b/docs/run/estimate-job-run-time.mdx index a8e62c81ec2..fa394be516c 100644 --- a/docs/run/estimate-job-run-time.mdx +++ b/docs/run/estimate-job-run-time.mdx @@ -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 diff --git a/docs/run/primitives-examples.mdx b/docs/run/primitives-examples.mdx index 935d5a6f073..a9500fe2cca 100644 --- a/docs/run/primitives-examples.mdx +++ b/docs/run/primitives-examples.mdx @@ -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) @@ -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] @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 @@ -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) diff --git a/docs/start/hello-world.ipynb b/docs/start/hello-world.ipynb index 12e266688cc..9ab0450b94a 100644 --- a/docs/start/hello-world.ipynb +++ b/docs/start/hello-world.ipynb @@ -34,6 +34,12 @@ "In a quantum program, *quantum circuits* are the native format in which to represent quantum instructions, and *operators* represent the observables to be measured. When creating a circuit, you'll usually create a new [`QuantumCircuit`](/api/qiskit/qiskit.circuit.QuantumCircuit#quantumcircuit) object, then add instructions to it in sequence." ] }, + { + "cell_type": "markdown", + "id": "a109ece0", + "metadata": {}, + "source": [] + }, { "cell_type": "markdown", "id": "21f7a26c", @@ -137,7 +143,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", @@ -321,7 +327,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3" + "version": "3.12.0" }, "title": "Hello world" }, From 2c1d163155a0a0d774763ac6b8cb6dcbe51bf871 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Thu, 22 Feb 2024 10:45:12 -0500 Subject: [PATCH 3/3] tox fix --- docs/start/hello-world.ipynb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/docs/start/hello-world.ipynb b/docs/start/hello-world.ipynb index 9ab0450b94a..2c5b86a1c32 100644 --- a/docs/start/hello-world.ipynb +++ b/docs/start/hello-world.ipynb @@ -34,12 +34,6 @@ "In a quantum program, *quantum circuits* are the native format in which to represent quantum instructions, and *operators* represent the observables to be measured. When creating a circuit, you'll usually create a new [`QuantumCircuit`](/api/qiskit/qiskit.circuit.QuantumCircuit#quantumcircuit) object, then add instructions to it in sequence." ] }, - { - "cell_type": "markdown", - "id": "a109ece0", - "metadata": {}, - "source": [] - }, { "cell_type": "markdown", "id": "21f7a26c", @@ -327,7 +321,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.0" + "version": "3" }, "title": "Hello world" },