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

Migration to Qiskit Primitives #115

Merged

Conversation

robotastray
Copy link
Contributor

@robotastray robotastray commented Aug 3, 2023

Summary

This PR aims to resolve issue #83.

Details and comments

File: test_braket_backend.py

Function test_vqe():

  • used from qiskit.algorithms.minimum_eigensolvers import VQE, VQEResult (Note: "The old VQE class has been superseded by the qiskit.algorithms.minimum_eigensolvers.VQE class.")

  • substituted QuantumInstance with BackendEstimator

  • used estimator as argument for VQE

  • substituted qiskit.opflow with qiskit.quantum_info

  • used SparsePauliOp to represent Pauli operators

File: test_adapter.py

  • substituted qiskit.opflow with qiskit.quantum_info
  • used SparsePauliOp to represent Pauli operators

File: test_braket_job.py

No changes

File: test_braket_provider.py

No changes

File: docs/tutorials/0_tutorial_qiskit-braket-provider_overview.ipynb

  • used VQE from qiskit.algorithms.minimum_eigensolvers
  • substituted QuantumInstance with BackendEstimator
  • used SparsePauiliOp as alternative to qiskit.opflow operators

File: docs/tutorials/1_tutorial_vqe.ipynb

  • used VQE from qiskit.algorithms.minimum_eigensolvers
  • substituted QuantumInstance with BackendEstimator
  • used SparsePauiliOp as alternative to qiskit.opflow operators

File: docs/tutorials/2_tutorial_hybrid_jobs_byoc.ipynb

  • re-run ! cat ./data/2_hybrid_jobs/job_script.py which displayed the content of the new job_script.py

File: docs/tutorials/3_tutorial_minimum_eigen_optimizer.ipynb

  • substituted QuantumInstance with BackendSampler
  • used COBYLA to be used as optimiser for QAOA
  • used QAOA, NumPyMinimumEigensolver from new qiskit.algorithms.minimum_eigensolvers
  • added options={ "seed_simulator": algorithm_globals.random_seed, "seed_transpiler": algorithm_globals.random_seed, }, as options in BackendSampler()

File: /data/2_hybrid_jobs/job_script.py

  • used VQE from qiskit.algorithms.minimum_eigensolvers
  • substituted QuantumInstance with BackendEstimator
  • used SparsePauiliOp as alternative to qiskit.opflow operators

@robotastray robotastray changed the title Migration to Qiskit Primitives (#83) AWS Braket Provider Migration to Qiskit Primitives Aug 3, 2023
@robotastray robotastray changed the title AWS Braket Provider Migration to Qiskit Primitives Braket Provider Migration to Qiskit Primitives Aug 3, 2023
@robotastray robotastray changed the title Braket Provider Migration to Qiskit Primitives Migration to Qiskit Primitives Aug 3, 2023
@robotastray
Copy link
Contributor Author

robotastray commented Aug 3, 2023

@IceKhan13 I have noticed something that might be unrelated to this issue. There is a problem in test_adaper.py to be specific function test_standard_gate_decomp(). I have made no changes to this function so far, and this error must have been present before this PR started. I have been working with Python 3.11. The tests fails for 3.10 version

======================================================================
ERROR: test_standard_gate_decomp (test_adapter.TestAdapter.test_standard_gate_decomp)
Tests adapter decomposition of all standard gates to forms that can be translated
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/robotastray/Desktop/github/qiskit-braket-provider/tests/providers/test_adapter.py", line 202, in test_standard_gate_decomp
    qiskit_circuit = qiskit_circuit.assign_parameters(parameter_bindings)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/robotastray/Desktop/github/qiskit-braket-provider/venv/lib/python3.11/site-packages/qiskit/circuit/quantumcircuit.py", line 2762, in assign_parameters
    raise CircuitError(
qiskit.circuit.exceptions.CircuitError: 'Cannot bind parameters (0) not present in the circuit.'

----------------------------------------------------------------------

For more info, you can see here

I have also reverted from qiskit_algoritm to qiskit.algorithm. A new issue should be opened for this migration.
Note I had to comment out     XXMinusYYGate(Parameter("ϴ")), and XXPlusYYGate(Parameter("ϴ")) from the standard_gates due to an unrelated bug which causes the test to fail.
@robotastray
Copy link
Contributor Author

robotastray commented Aug 4, 2023

The error with test_standard_gate_decomp() in test_adapter.py is due to the following standard_gates:

XXMinusYYGate(Parameter("ϴ")),
 XXPlusYYGate(Parameter("ϴ")),

Note this is unrelated to this PR, it something I stumbled upon.
If one comments these gates out of the code there are no issues. I have commented them from the array for now. Let me know how you wish to proceed regarding this.

@robotastray robotastray marked this pull request as ready for review August 4, 2023 13:45
@IceKhan13
Copy link
Member

Hey @robotastray ! Thank for this PR!

hmm, something is wrong with this gate specifically. You are right test failing in main branch too https://github.com/qiskit-community/qiskit-braket-provider/actions/runs/5768152751/job/15638813727 and only for python 3.10, but not for 3.7 🤔

Give me couple of days, I will try to figure out what is going on, so we can remove commented gates from this PR.

As a heads-up PR looks great! :)

@IceKhan13
Copy link
Member

@robotastray fixed failing tests in #118. Make sure to merge changes from main, uncomment tests and we can move with PR review!

@robotastray
Copy link
Contributor Author

Hello @IceKhan13,
Thank you for your message and help. I have completed the steps now.

@IceKhan13 IceKhan13 self-requested a review August 7, 2023 00:27
Copy link
Member

@IceKhan13 IceKhan13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

Thank you @robotastray !

@IceKhan13 IceKhan13 merged commit a3e40e2 into qiskit-community:main Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants