allow repeating parameters#911
Closed
hhorii wants to merge 3 commits into
Closed
Conversation
Contributor
Author
|
Just repeating circuits may not satisfy Aqua's use case. Aqua inserts calibration circuits. These inserted circuits should not be repeated. |
b32b46d to
d37708a
Compare
Member
|
I think this is already supported, its just nested differently. The code example in #485 shows how to runs multiple parameterizations for multiple circuits (Which need not have the same number of parameterizations). For the case of a single circuit I want to run with 10 different parameterizations for example I can do: import numpy as np
from qiskit import *
# Example circuit
qc = QuantumCircuit(1, 1)
qc.ry(0, 0)
qc.rx(0, 0)
qc.measure(0, 0)
# Make random parameter values
num_parameterizations = 10
ry_params = np.random.rand(num_parameterizations)
rx_params = np.random.rand(num_parameterizations)
parameterizations = [
[[[0, 0], ry_params], [[1, 0], rx_params]]
]
# Assemble parameterized qobj
qobj = assemble(qc, parameterizations=parameterizations)
# Execute
sim = Aer.get_backend("qasm_simulator")
result = sim.run(qobj).result()
print('Status: {}'.format(result.status))
print("Results for parameterized circuit:")
for j in range(num_parameterizations):
print(result.get_counts(j))Which prints 10 counts: |
Contributor
Author
|
@chriseclectic thanks. you are right. I misunderstood the current impl. Let me close this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow use of a circuit for multiple parameters
Details and comments
Currently, parameterized Qobj allows a circuit to take a parameter set. This PR allows a circuit to take multiple parameter set.