Skip to content
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

EstimatorV2 extended_stabilizer fails" invalid instructions {"instructions": {save_expval}} #2121

Open
zlatko-minev opened this issue May 3, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@zlatko-minev
Copy link

Informations

  • Qiskit Aer version: 0.14.1
  • Python version: 3.11
  • Operating system: Mac

What is the current behavior?

Can't run extended stabilizer with Estimator, see code:

Steps to reproduce the problem

from qiskit_aer.primitives import EstimatorV2 
qc = QuantumCircuit(2)
qc.sx(0)
qc.cx(0,1)
obs = ['ZI']

options = {
    "backend_options": {  
        "method": "extended_stabilizer",
    }
}
estimator = EstimatorV2(options=options)
print(estimator._backend)
job = estimator.run([(qc, obs)])

Return

AerSimulator('aer_simulator_extended_stabilizer')
Simulation failed and returned the following error message:
ERROR:  [Experiment 0] Circuit circuit-394 contains invalid instructions {"instructions": {save_expval}} for "extended_stabilizer" method.Circuit circuit-394 contains invalid parameters  for "extended_stabilizer" method.

What is the expected behavior?

Should run extended stabilizer with Estimator.

Suggested solutions

NA

@zlatko-minev zlatko-minev added the bug Something isn't working label May 3, 2024
@kevinsung
Copy link

kevinsung commented May 16, 2024

So strange. When I run the code in @zlatko-minev 's repro, I get a different error. I'm using the same Aer version and Python 0.14.1, but my OS is Fedora Linux 40.

Traceback (most recent call last):
  File "/home/kevinsung/projects/documentation/test.py", line 13, in <module>
    estimator = EstimatorV2(options=options)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevinsung/.pyenv/versions/documentation/lib/python3.11/site-packages/qiskit_aer/primitives/estimator_v2.py", line 74, in __init__
    self._backend = AerSimulator(method=method, **self.options.backend_options)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: qiskit_aer.backends.aer_simulator.AerSimulator() got multiple values for keyword argument 'method'

@doichanj
Copy link
Collaborator

I found save_expval is disabled because there are some issue in implementation of save_expval of extended stabilizer.

// Disabled until can fix bug in expval
// case Operations::OpType::save_expval:
// case Operations::OpType::save_expval_var:
// apply_save_expval(op, result, rng);
// break;

@doichanj
Copy link
Collaborator

So strange. When I run the code in @zlatko-minev 's repro, I get a different error. I'm using the same Aer version and Python 0.14.1, but my OS is Fedora Linux 40.

Traceback (most recent call last):
  File "/home/kevinsung/projects/documentation/test.py", line 13, in <module>
    estimator = EstimatorV2(options=options)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevinsung/.pyenv/versions/documentation/lib/python3.11/site-packages/qiskit_aer/primitives/estimator_v2.py", line 74, in __init__
    self._backend = AerSimulator(method=method, **self.options.backend_options)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: qiskit_aer.backends.aer_simulator.AerSimulator() got multiple values for keyword argument 'method'

This is fixed by PR #2120

@zlatko-minev
Copy link
Author

zlatko-minev commented May 28, 2024 via email

@doichanj
Copy link
Collaborator

I'm feeling difficulty to solve expval bug in extended stabilizer, so I think I will not include fix in Aer 014.2

@zlatko-minev
Copy link
Author

Thank you for trying. Can you add a little more on what the issue is? That's tricky to resolve.

I hope somebody else here might be able to contribute as well.

The thing is that we're increasingly moving to using the estimator class and so this is now the default preferred pathway.

@doichanj
Copy link
Collaborator

doichanj commented Jun 3, 2024

I opened PR #2161 for this issue.
I'm fixing bugs in save_expval and now it works for clifford circuits
I think it is not easy because of accuracy for non-clifford circuits

@zlatko-minev
Copy link
Author

zlatko-minev commented Jun 3, 2024 via email

@doichanj
Copy link
Collaborator

doichanj commented Jun 4, 2024

It seems the estimation is unstable for non clifford circuits that causes wrong expectation values

@zlatko-minev
Copy link
Author

zlatko-minev commented Jun 4, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants