IBM Hardware How To

Published by strangeworks (06/10/2021)

Someday has come, the future is now, rejoice workers of strange. You can now run quantum code on actual quantum computers. We’re talking about turning those quantum circuits into pulses on superconducting qubits!

In this guide we are going to write some quantum code on the strangeworks platform and run it on quantum computing hardware made freely available by our partners at IBM. Be sure to check back as we continue to expand our community hardware offerings! Here’s the plan:

  1. Get an IBM Quantum API key
  2. Add your key to quantumcomputing.com
  3. Run code on some Big Blue transmons

Get IBM quantum key

The first step is connecting quantumcomputing.com to your IBM account. We are going to do this by manually copying your API key from IBM Quantum to your strangeworks hardware profile.

From the strangeworks dashboard select Hardware, the dilution refrigerator icon (oh you didn’t know that is what it was? Well it is and it is objectively the best icon ever).

At the quantum computing hardware page we are going to use IBM hardware. First we need to add our IBM keys to our quantumcomputing.com account. Click “Add Account” to get to the linking page.

If you already have an IBM Quantum account you add your keys now. If you do not have an IBM account click the “your IBM Dashboard” link and set up an IBMQ account.

Once you are at the IBM Quantum site, create an account or login to your exiting account.

When you have logged in you can find and copy your API key from your account.

Add your key to quantumcomputing.com

Once you have logged in to your IBM account, copy the key to the clipboard and paste it back into the account info section on quantumcomputing.com. Paste in your key and give you new account a useful name.

Click “Next”. This will take you to the IBM end user agreement. Check the box and click “Finish”.

Once you click finish you will arrive at a final success screen with some sample code. Clone this code to a new project, we are going to use it in the next step.

Run code on some Big Blue transmons

To test that everything works we are going to flip a quantum coin. This code will create a Bell state circuit, then run it on an IBM quantum computer.

import strangeworks.qiskit
import qiskit

qc = qiskit.QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])

backend = strangeworks.qiskit.get_backend("ibmqx2") 

job = qiskit.execute(qc, backend, shots=50)
result = job.result()
print("result:", result)
counts = result.get_counts()
print("counts:", counts)

The first part of this program creates the circuit, the second part submits the circuit to the backend ibmqx2. The strangeworks sdk uses your new hardware account to submit jobs to a particular IBM backend. This code will run your code on the IBMQ 5 Yorktown. You can run this on other IBM hardware by changing the name of the backend.If you want to try another quantum computer or simulator you only need to change the backend in your program. For example, if you want to run your program on the IBMQ Quito processor you would change the backend to

backend = strangeworks.qiskit.get_backend("ibmq_quito")

To view details about your IBM Hardware account, including your account name and all the IBM backends, check out the IBM Hardware page. You can see the backends that are active on your account from the IBM Quantum Services Page.

From the new project that was created in the last step you can test your connection by running the code we have copied over. Click the big green “Run Code” button and put those qubits to work!

Since this is running on shared hardware there may be a wait while your program is in the queue. Just hang tight, your results are coming!

That’s all there is to it! Thanks to our friends at IBM in a few simple steps you are running code on a quantum computer and we think that is freaking fantastic!