Skip to content

Commit

Permalink
update qiskit version
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeisel committed Jan 8, 2024
1 parent c8aa639 commit b041a8e
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 37 deletions.
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ def create_app(config_name="default"):

@app.route("/")
def heartbeat():
return '<h1>The Error-Mitigation Service is Running</h1> <h3>View the API Docs <a href="/app/swagger-ui">here</a></h3>'
return '<h1>The Error-Mitigation Service is Running</h1> <h3>View the API Docs <a href="/api/swagger-ui">here</a></h3>'

return app
3 changes: 1 addition & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class Config:

API_SPEC_OPTIONS = {
"info": {
"description": "This is the API Specification of the Readout Error Mitigation Service("
"https://readthedocs/readout-error-mitigation-service/TOBERELEASED).",
"description": "This is the API Specification of the Readout Error Mitigation Service",
},
"license": {"name": "Apache v2 License"},
}
Expand Down
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ marshmallow==3.13.0
minio==7.1.3
mthree==1.0.0
pyquil==3.0.1
qiskit==0.37.1
qiskit==0.44.1
qiskit_ionq==0.1.4
symengine==0.9
Werkzeug==2.0.1
qiskit-ignis==0.6.0
qiskit-ignis==0.6.0
qiskit_aer==0.12.2
qiskit_ibm_provider==0.7.1
86 changes: 54 additions & 32 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import json
import re

from qiskit import IBMQ
from tests.utils_test import get_available_qpu

parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(parent_dir)
from app import create_app
Expand All @@ -23,18 +26,19 @@ def test_app_running(self):
self.assertEqual(response.status_code, 200)

def test_cm_noisy_simulator(self):
token = os.environ["TOKEN"]
credentials = {"token": os.environ["TOKEN"]}
backend = get_available_qpu(credentials)
response = self.client.post(
"/cm/",
data=json.dumps(
{
"provider": "IBM",
"qpu": "aer_qasm_simulator",
"credentials": {"token": token},
"credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"shots": 1000,
"noise_model": "ibmq_lima",
"noise_model": backend,
"only_measurement_errors": False,
}
),
Expand All @@ -44,24 +48,29 @@ def test_cm_noisy_simulator(self):
self.assertTrue(".pkl" in response.json)

response_get = self.client.get(
"/cm/?noise_model=ibmq_lima&cm_gen_method=standard&qpu=aer_qasm_simulator&qubits=0&qubits=1&qubits=2&qubits=3&qubits=4&max_age=360"
"/cm/?noise_model=" + backend +
"&cm_gen_method=" + "standard" +
"&qpu=aer_qasm_simulator" +
"&qubits=0&qubits=1&qubits=2&qubits=3&qubits=4"+
"&max_age=360"
)
self.assertEqual(response_get.status_code, 200)
self.assertEqual(len(response_get.json), 32)

def test_cm_tpnm_noisy_simulator(self):
token = os.environ["TOKEN"]
credentials = {"token": os.environ["TOKEN"]}
backend = get_available_qpu(credentials)
response = self.client.post(
"/cm/",
data=json.dumps(
{
"provider": "IBM",
"qpu": "aer_qasm_simulator",
"credentials": {"token": token},
"credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "tpnm",
"shots": 1000,
"noise_model": "ibmq_lima",
"noise_model": backend,
"only_measurement_errors": False,
}
),
Expand Down Expand Up @@ -113,18 +122,19 @@ def test_gen_from_counts(self):
self.assertTrue(".pkl" in response.json)

def test_cm_noisy_simulator_only_measure(self):
token = os.environ["TOKEN"]
credentials = {"token": os.environ["TOKEN"]}
backend = get_available_qpu(credentials)
response = self.client.post(
"/cm/",
data=json.dumps(
{
"provider": "IBM",
"qpu": "aer_qasm_simulator",
"credentials": {"token": token},
"credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"shots": 1000,
"noise_model": "ibmq_lima",
"noise_model": backend,
"only_measurement_errors": "True",
}
),
Expand All @@ -134,19 +144,20 @@ def test_cm_noisy_simulator_only_measure(self):
self.assertTrue(".pkl" in response.json)

def test_mm_noisy_simulator(self):
token = os.environ["TOKEN"]
credentials = {"token": os.environ["TOKEN"]}
backend = get_available_qpu(credentials)
response = self.client.post(
"/mm/",
data=json.dumps(
{
"provider": "IBM",
"qpu": "aer_qasm_simulator",
"credentials": {"token": token},
"credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "inversion",
"shots": 1000,
"noise_model": "ibmq_lima",
"noise_model": backend,
"only_measurement_errors": False,
"max_age": 0,
}
Expand All @@ -157,19 +168,20 @@ def test_mm_noisy_simulator(self):
self.assertTrue(".pkl" in response.json)

def test_mm_noisy_simulator_only_measure(self):
token = os.environ["TOKEN"]
credentials = {"token": os.environ["TOKEN"]}
backend = get_available_qpu(credentials)
response = self.client.post(
"/mm/",
data=json.dumps(
{
"provider": "IBM",
"qpu": "aer_qasm_simulator",
"credentials": {"token": token},
"credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "inversion",
"shots": 1000,
"noise_model": "ibmq_lima",
"noise_model": backend,
"only_measurement_errors": "True",
}
),
Expand All @@ -179,13 +191,19 @@ def test_mm_noisy_simulator_only_measure(self):
self.assertTrue(".pkl" in response.json)

response_get = self.client.get(
"/mm/?noise_model=ibmq_lima&cm_gen_method=standard&mitigation_method=inversion&qpu=aer_qasm_simulator&qubits=0&qubits=1&qubits=2&qubits=3&qubits=4&max_age=360"
"/mm/?noise_model=" + backend +
"&cm_gen_method=standard" +
"&mitigation_method=inversion" +
"&qpu=aer_qasm_simulator" +
"&qubits=0&qubits=1&qubits=2&qubits=3&qubits=4"+
"&max_age=360"
)
self.assertEqual(response_get.status_code, 200)
self.assertEqual(len(response_get.json), 32)

def test_rem_noisy_simulator_only_measure_standard_inversion(self):
token = os.environ["TOKEN"]
credentials = {"token": os.environ["TOKEN"]}
backend = get_available_qpu(credentials)
response = self.client.post(
"/rem/",
data=json.dumps(
Expand Down Expand Up @@ -225,12 +243,12 @@ def test_rem_noisy_simulator_only_measure_standard_inversion(self):
},
"provider": "IBM",
"qpu": "aer_qasm_simulator",
"credentials": {"token": token},
"credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "inversion",
"shots": 1000,
"noise_model": "ibmq_lima",
"noise_model": backend,
"only_measurement_errors": "True",
"max_age": 0,
}
Expand All @@ -241,7 +259,8 @@ def test_rem_noisy_simulator_only_measure_standard_inversion(self):
self.assertTrue("11110" in response.json.keys())

def test_rem_noisy_simulator_only_measure_standard_inversion_reuse_mitigator(self):
token = os.environ["TOKEN"]
credentials = {"token": os.environ["TOKEN"]}
backend = get_available_qpu(credentials)
response = self.client.post(
"/rem/",
data=json.dumps(
Expand Down Expand Up @@ -281,12 +300,12 @@ def test_rem_noisy_simulator_only_measure_standard_inversion_reuse_mitigator(sel
},
"provider": "IBM",
"qpu": "aer_qasm_simulator",
"credentials": {"token": token},
"credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "inversion",
"shots": 1000,
"noise_model": "ibmq_lima",
"noise_model": backend,
"only_measurement_errors": "True",
"max_age": 300,
}
Expand All @@ -297,7 +316,8 @@ def test_rem_noisy_simulator_only_measure_standard_inversion_reuse_mitigator(sel
self.assertTrue("11110" in response.json.keys())

def test_rem_noisy_simulator_only_measure_ignis(self):
token = os.environ["TOKEN"]
credentials = {"token": os.environ["TOKEN"]}
backend = get_available_qpu(credentials)
response = self.client.post(
"/rem/",
data=json.dumps(
Expand Down Expand Up @@ -337,12 +357,12 @@ def test_rem_noisy_simulator_only_measure_ignis(self):
},
"provider": "IBM",
"qpu": "aer_qasm_simulator",
"credentials": {"token": token},
"credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "ignis",
"shots": 1000,
"noise_model": "ibmq_lima",
"noise_model": backend,
"only_measurement_errors": "True",
"max_age": 0,
}
Expand All @@ -353,7 +373,8 @@ def test_rem_noisy_simulator_only_measure_ignis(self):
self.assertTrue("11110" in response.json.keys())

def test_rem_noisy_simulator_only_measure_bayes(self):
token = os.environ["TOKEN"]
credentials = {"token": os.environ["TOKEN"]}
backend = get_available_qpu(credentials)
response = self.client.post(
"/rem/",
data=json.dumps(
Expand Down Expand Up @@ -393,12 +414,12 @@ def test_rem_noisy_simulator_only_measure_bayes(self):
},
"provider": "IBM",
"qpu": "aer_qasm_simulator",
"credentials": {"token": token},
"credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "bayes",
"shots": 1000,
"noise_model": "ibmq_lima",
"noise_model": backend,
"only_measurement_errors": "True",
"max_age": 0,
}
Expand All @@ -409,7 +430,8 @@ def test_rem_noisy_simulator_only_measure_bayes(self):
self.assertTrue("11110" in response.json.keys())

def test_rem_noisy_simulator_only_measure_tpnm(self):
token = os.environ["TOKEN"]
credentials = {"token": os.environ["TOKEN"]}
backend = get_available_qpu(credentials)
response = self.client.post(
"/rem/",
data=json.dumps(
Expand Down Expand Up @@ -449,11 +471,11 @@ def test_rem_noisy_simulator_only_measure_tpnm(self):
},
"provider": "IBM",
"qpu": "aer_qasm_simulator",
"credentials": {"token": token},
"credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"mitigation_method": "tpnm",
"shots": 1000,
"noise_model": "ibmq_lima",
"noise_model": backend,
"only_measurement_errors": "True",
"max_age": 0,
}
Expand Down
8 changes: 8 additions & 0 deletions tests/utils_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from qiskit_ibm_provider import IBMProvider

def get_available_qpu(credentials):
provider = IBMProvider(**credentials)
backends = provider.backends()
for backend in backends:
if 'simulator' not in backend.name:
return backend.name

0 comments on commit b041a8e

Please sign in to comment.