-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for dependency issues caused by 0.14 release #2094
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
30f219a
Fixes for dependency issues
doichanj b82b5ed
lint
doichanj 27a9ac2
lint
doichanj 6e47bbd
lint
doichanj 275e563
fix release note
doichanj 3de8921
fix sampler
doichanj beb7c16
fix sampler
doichanj 4873a72
fix sampler
doichanj 798d9df
Merge remote-tracking branch 'upstream/main' into fix_release014
doichanj 8ff089c
fix sampler
doichanj 60f5333
remove skip cp38
doichanj 39aaab8
hide primitives V2 for qiskit < 1.0
doichanj e8bd270
lint
doichanj 13fc1fb
add test case for sampling measure for large stabilizer circuit
doichanj e0cf244
Merge remote-tracking branch 'upstream/main' into fix_release014
doichanj ca534ed
reduce warning
doichanj 53cb44f
Merge remote-tracking branch 'upstream/main' into fix_release014
doichanj 177f2f9
replace test case for large stabilizer with GHZ circuit
doichanj 1c59382
Merge remote-tracking branch 'upstream/main' into fix_release014
doichanj 92f3780
format
doichanj ff1db05
format
doichanj debc66c
convert basis_gates from list to set
doichanj 0259537
fix assemble_circuits
doichanj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -605,7 +605,7 @@ def generate_aer_config( | |
return config | ||
|
||
|
||
def assemble_circuit(circuit: QuantumCircuit): | ||
def assemble_circuit(circuit: QuantumCircuit, basis_gates=None): | ||
"""assemble circuit object mapped to AER::Circuit""" | ||
|
||
num_qubits = circuit.num_qubits | ||
|
@@ -687,6 +687,7 @@ def assemble_circuit(circuit: QuantumCircuit): | |
is_conditional, | ||
conditional_reg, | ||
conditional_expr, | ||
basis_gates, | ||
) | ||
index_map.append(num_of_aer_ops - 1) | ||
|
||
|
@@ -792,6 +793,7 @@ def _assemble_op( | |
is_conditional, | ||
conditional_reg, | ||
conditional_expr, | ||
basis_gates, | ||
): | ||
operation = inst.operation | ||
qubits = [qubit_indices[qubit] for qubit in inst.qubits] | ||
|
@@ -812,7 +814,7 @@ def _assemble_op( | |
|
||
num_of_aer_ops = 1 | ||
# fmt: off | ||
if name in { | ||
if basis_gates is None and name in { | ||
"ccx", "ccz", "cp", "cswap", "csx", "cx", "cy", "cz", "delay", "ecr", "h", | ||
"id", "mcp", "mcphase", "mcr", "mcrx", "mcry", "mcrz", "mcswap", "mcsx", | ||
"mcu", "mcu1", "mcu2", "mcu3", "mcx", "mcx_gray", "mcy", "mcz", "p", "r", | ||
|
@@ -912,6 +914,9 @@ def _assemble_op( | |
aer_circ.mark(qubits, params) | ||
elif name == "qerror_loc": | ||
aer_circ.set_qerror_loc(qubits, label if label else name, conditional_reg, aer_cond_expr) | ||
elif basis_gates is not None and name in basis_gates: | ||
aer_circ.gate(name, qubits, params, [], conditional_reg, aer_cond_expr, | ||
label if label else name) | ||
elif name in ("for_loop", "while_loop", "if_else"): | ||
raise AerError( | ||
"control-flow instructions must be converted " f"to jump and mark instructions: {name}" | ||
|
@@ -923,11 +928,12 @@ def _assemble_op( | |
return num_of_aer_ops | ||
|
||
|
||
def assemble_circuits(circuits: List[QuantumCircuit]) -> List[AerCircuit]: | ||
def assemble_circuits(circuits: List[QuantumCircuit], basis_gates: list = None) -> List[AerCircuit]: | ||
"""converts a list of Qiskit circuits into circuits mapped AER::Circuit | ||
|
||
Args: | ||
circuits: circuit(s) to be converted | ||
basis_gates (list): supported gates to be converted | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mentioned the above, |
||
|
||
Returns: | ||
a list of circuits to be run on the Aer backends and | ||
|
@@ -947,5 +953,11 @@ def assemble_circuits(circuits: List[QuantumCircuit]) -> List[AerCircuit]: | |
# Generate AerCircuit from the input circuit | ||
aer_qc_list, idx_maps = assemble_circuits(circuits=[qc]) | ||
""" | ||
aer_circuits, idx_maps = zip(*[assemble_circuit(circuit) for circuit in circuits]) | ||
if basis_gates is not None: | ||
basis_gates_set = set(basis_gates) | ||
aer_circuits, idx_maps = zip( | ||
*[assemble_circuit(circuit, basis_gates_set) for circuit in circuits] | ||
) | ||
else: | ||
aer_circuits, idx_maps = zip(*[assemble_circuit(circuit) for circuit in circuits]) | ||
return list(aer_circuits), list(idx_maps) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
11 changes: 11 additions & 0 deletions
11
releasenotes/notes/fixes_dependency_issues_by0.14-da7f11cb29710f86.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
fixes: | ||
- | | ||
Fixes for dependency issues caused by release 0.14. | ||
|
||
Fix for issue in samplingVector.allocate() when > 63 qubits | ||
|
||
Use basis_gates in AerCompiler when AerBackend is made by from_backend | ||
|
||
Setting number of qubits before transpile for Primitives V1 (issue #2084) | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aer C++ library supports only the following gates natively.
If
basis_gates
is not subset of the above set, simulation will fail. I think it is better to checkname
is in the above set.Also, I guess
backend.configuration().basis_gate
islist
and notset
.basis_gates
should beset
because this is one of hot loops.I think that at the beginning of
assemble_circuit()
,basis_gates
should be re-created as aset
(while reducingmeasure
,reset
and etc). IfNone
is passed, we can use a default set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
AerSimulator
is made byfrom_backend()
givenbasis_gates
does not contain all the gates Aer supports, Aer should return error