4
$\begingroup$

Since Shor's algorithm was deprecated in Qiskit, I'm wondering where to find a generic implementation.

There are some examples over the Internet but factoring of 15 is just hardcoded.

$\endgroup$

3 Answers 3

2
$\begingroup$

You can use the Shor's algorithm which was deprecated from qiskit.algorithms as the starting point and modify it to work with qiskit>1.0.0. Here are a few suggestions on how to do this:

  1. Take the code from the qiskit GitHub.

  2. Now because this code uses QuantumInstance from qiskit.utils.quantum_instance which is also deprecated you will have to replace all the below functions with their alternatives:

    • Replace qiskit.utils.QuantumInstance.execute with qiskit.primitives.Sampler.run or qiskit.primitives.Estimator.run
    • Replace qiskit.utils.QuantumInstance.transpile with qiskit.compiler.transpile
    • Replace qiskit.utils.QuantumInstance.assemble with qiskit.compiler.assemble.

I have not actually done this but I assume that you will get some other errors which you will have to fix by going through the migration guide

Let me know in comments if you get stuck somewhere. Hope this answer guides you in right direction.

$\endgroup$
2
$\begingroup$

The author of this site implements this paper. The implementation's generic. I hope this helps.

$\endgroup$
2
$\begingroup$

You can use Shor's algorithm in Classiq QMOD library (if you want the qiskit version, you can convert the Classiq generated circuit to qasm).

You can do this in one of 2 ways:

  1. With Native QMOD language in Classiq IDE - Search for Shor in the search bar. Currently, there are 2 implementations (regular and Modular Exponentiation).

  2. With Python QMOD - Download the Jupyther Notebook from the user guide here or from here (make sure to authenticate before running).

Both also available in the Git repo

Notice that you should sign-up to the platform to run in both methods

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.