-
Notifications
You must be signed in to change notification settings - Fork 361
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
Conversation
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.
Are there any python unit tests for large Pauli's on the stabilizer simulator? If not you should add some (or if so add some more).
A basic one which is similar to the test I saw fail on 0.14 for my repo is something like preparing +1 Pauli eigenstates, measuring them, and checking the expectation value computed from the final counts is close to 1
Eg
@ddt.data(65, 127, 433)
def test_expectation_value_large_paulis(self, num_qubits):
"""Test expectation value circuit with large Pauli objects"""
paulis = qi.PauliList([num_qubits * i for i in ["X", "Y", "Z"]])
circuits = []
for pauli in paulis:
qc = QuantumCircuit(num_qubits, num_qubits)
for i, p in enumerate(pauli):
if p == Pauli("Y"):
qc.sdg(i)
qc.h(i)
elif p == Pauli("X"):
qc.h(i)
if p != Pauli("I"):
qc.measure(i, i)
# Run circuits
...
# Check all expvals are close to 1 where each expval is computed
# expval = sum_i freq_i * (1 - 2 * parity(bitsting_i)) / shots
@chriseclectic I tested with the circuit below but both non-fixed version and this PR returns 1.0
something wrong with my code? |
For this test you need to specifically test the I'm not sure why the failure only occurred when randomizing the output and correcting in post-processing. I did double check the with result metadata used in post-processing to undo the randomization with a fixed generation seed and it was the same both in 0.13 and 0.14, so that leads me to think the issue is the count data itself when randomizing. One thing when randomizing is the stabilizer state being sampled from (which is a simple tensor product state) won't be symmetric over different qubits anymore, when without randomization for this test it was. You should be able to capture this without randomization by Paulis that mix X, Y, Z. |
@@ -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: |
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.
"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"
If basis_gates
is not subset of the above set, simulation will fail. I think it is better to check name
is in the above set.
Also, I guess backend.configuration().basis_gate
is list
and not set
. basis_gates
should be set
because this is one of hot loops.
I think that at the beginning of assemble_circuit()
, basis_gates
should be re-created as a set
(while reducing measure
, reset
and etc). If None
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 by from_backend()
given basis_gates
does not contain all the gates Aer supports, Aer should return error
"""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 comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned the above, list
should be converted to set
here.
if num_qubits == 65: | ||
ref_counts.update( | ||
{ | ||
"00000010101011110100110101101101101100010011000110011100101001010": 1, |
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.
Just to test whether stabilizer can work for large-qubit circuits, we can use GHZ and then validate result with more simpler counts.
* Fixes for dependency issues * lint * lint * lint * fix release note * fix sampler * fix sampler * fix sampler * fix sampler * remove skip cp38 * hide primitives V2 for qiskit < 1.0 * lint * add test case for sampling measure for large stabilizer circuit * reduce warning * replace test case for large stabilizer with GHZ circuit * format * format * convert basis_gates from list to set * fix assemble_circuits
* Fix AerCompiler to use custom pass manager to decompose control flow ops (#2095) * Fix AerCompiler to use basis_gates built from input circuit * use custom pass manager to decompose dontrol flow ops * remove unused import * Use sphinx.ext.linkcode for more precise source code links (#2101) * switched links to using sphinx.ext.linkcode * added release note * added check for qiskit methods * remove whitespace * removed regex subsitution Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> * Update tox.ini Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> * made updates following Eric's review * made final line more readable * cast filename to str * re-added regex sub --------- Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> * Fix noise sampling on shot-branching (#2098) * Fix noise sampling on shot-branching * format * fix runtime noise sampling * remove copying branch * fix batch GPU * format * set initial value to Op structure * format * format * test * test * fix use of additional_ops.size() * fix error * fix remove_empty_branches * test * test * test * test * Fixes for dependency issues caused by 0.14 release (#2094) * Fixes for dependency issues * lint * lint * lint * fix release note * fix sampler * fix sampler * fix sampler * fix sampler * remove skip cp38 * hide primitives V2 for qiskit < 1.0 * lint * add test case for sampling measure for large stabilizer circuit * reduce warning * replace test case for large stabilizer with GHZ circuit * format * format * convert basis_gates from list to set * fix assemble_circuits * resolve conflicts * Replace example in README to using primitives (#2105) * Replace example in README to using primitives * upgrade python version to 3.10 for github actions * fix 3.10 * fix 3.10 * upgrade python version to 3.10 for github actions * skip 3.8 and 3.9 for MacOS arm64 * skip 3.8 and 3.9 for MacOS arm64 * skip 3.8 and 3.9 for MacOS arm64 * replace macos-latest with macos-13 * Revert "Replace example in README to using primitives" This reverts commit b536563. * Revert "Revert "Replace example in README to using primitives"" This reverts commit 807ac6f. * manually merge upstream * add example using noise model * remove print(result) * add release note and set versions * Fix CI failures (#2106) * upgrade github actions for macos_arm64 and windows * skip pp38/39 * exclude pp * fix doc * test * remove CIBW_TEST_SKIP for wheel --------- Co-authored-by: melechlapson <melechlapson@yahoo.com> Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Summary
This PR fixed dependency issues caused by release 0.14.
Also this fix includes fix for #2084
Details and comments