Fermion back-end workflow demonstration¶
In cold atoms, we do not necessarily work with qubits. In cold atoms, we can also work with fermionic atoms the hop through optical lattice systems. The most common examples are Li6 or K40 atoms moving through the optical lattice system. This approach is now used in the FermiQP project to implement a quantum processor.
The fermionic tweezer backend, implements four optical lattice sites with possibility of spin up and down. In the following tutorial, we will present you have to implement computing sequences on this simulator device through our standard API. The communication with the backend happens through the four url
- '.../api/v2/fermions/get_config/'
- '.../api/v2/fermions/post_job/'
- '.../api/v2/fermions/get_job_status/'
- '.../api/v2/fermions/get_job_result/'
An interactive documentation can be also found directly online under the docs.
You can use this tutorial in two ways. For testing of local deployments of qlued
or the hosted version provided by Alqor.
Optional: Preparation for local deployment¶
Some first things that you have to do:
- Apply any migrations to your local server
python manage.py migrate
- Start the server in a tab as
python manage.py runserver
- You created an account and saved this in the local
credentials.py
file
Get the configuration¶
In a first step, we will try to see what are the available backends and what are the capabilities. This can be done through the json API endpoint get_config
for the fermions
backend.
import requests
import json
from pprint import pprint
import numpy as np
import matplotlib.pyplot as plt
This imports the credentials_v2.py
file you received from us.
from credentials_v2 import username, token
# for local deployment uncomment the following line
# host_url = 'http://localhost:8000/'
# for work with the cloud version uncomment the following line
host_url = "https://qlued.alqor.io/"
url_prefix = host_url + "api/v2/fermions/"
url = url_prefix + "get_config"
pprint(url)
r = requests.get(url, params={"username": username, "token": token})
r_dict = json.loads(r.text)
pprint(r_dict)
'https://qlued.alqor.io/api/v2/fermions/get_config' {'backend_name': 'alqor_fermionic_tweezer_simulator', 'backend_version': '0.0.1', 'basis_gates': ['fhop', 'fint', 'fphase'], 'cold_atom_type': 'fermion', 'conditional': False, 'coupling_map': 'linear', 'description': 'simulator of a fermionic tweezer hardware. The even wires ' 'denote the occupations of the spin-up fermions and the odd ' 'wires denote the spin-down fermions', 'display_name': 'fermions', 'dynamic_reprate_enabled': False, 'gates': [{'coupling_map': [[0, 1, 2, 3], [2, 3, 4, 5], [4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]], 'description': 'hopping of atoms to neighboring tweezers', 'name': 'fhop', 'parameters': ['j_i'], 'qasm_def': '{}'}, {'coupling_map': [[0, 1, 2, 3, 4, 5, 6, 7]], 'description': 'on-site interaction of atoms of opposite spin ' 'state', 'name': 'fint', 'parameters': ['u'], 'qasm_def': '{}'}, {'coupling_map': [[0, 1], [2, 3], [4, 5], [6, 7], [0, 1, 2, 3, 4, 5, 6, 7]], 'description': 'Applying a local phase to tweezers through an ' 'external potential', 'name': 'fphase', 'parameters': ['mu_i'], 'qasm_def': '{}'}], 'local': False, 'max_experiments': 1000, 'max_shots': 1000000, 'memory': True, 'n_qubits': 8, 'num_species': 2, 'open_pulse': False, 'simulator': True, 'supported_instructions': ['load', 'barrier', 'fhop', 'fint', 'fphase', 'measure'], 'url': 'https://qlued.alqor.io/api/v2/fermions/', 'wire_order': 'interleaved'}
The above json gives us all the necessary information. The system four optical lattice sites, which are represented on eight wires. Alternating wires then represent the alternating spin occupation. For those wires we have implemente the following gates.
We have implemented:
load
which adds a Fermion to the wire.fhop
which lets Fermions hop.fint
which describes interactions between fermions.fphase
which is the chemical potential on the gate.measure
which reads out the occupation.
Load gate¶
In a first step, we have to have to load fermions into the tweezer. Let us start out with that in the following json
:
- We load atoms into the wire 0, 2 and 7.
- We read out the occupation of wires 0, 2,6 ,7
- We repeat the experiment for 4 shots.
job_payload = {
"experiment_0": {
"instructions": [
("load", [7], []),
("load", [2], []),
("load", [0], []),
("measure", [0], []),
("measure", [2], []),
("measure", [6], []),
("measure", [7], []),
],
"num_wires": 8,
"shots": 4,
"wire_order": "interleaved",
},
}
Now, that we set up the instruction, we can submit it via the post_job
endpoint.
url = url_prefix + "post_job"
pprint(url)
job_response = requests.post(
url,
json={"job": json.dumps(job_payload), "username": username, "token": token},
)
job_id = (job_response.json())["job_id"]
print(job_response.json())
'https://qlued.alqor.io/api/v2/fermions/post_job' {'job_id': '20230429_084630-fermions-fred-26af2', 'status': 'INITIALIZING', 'detail': 'Got your json.', 'error_message': 'None'}
The simulator has now put the job into the queue and we will have to wait until the calculation is finished. To see its test the job status through get_job_status
.
url = url_prefix + "get_job_status"
status_response = requests.get(
url, params={"job_id": job_id, "username": username, "token": token}
)
print(status_response.text)
{"job_id": "20230429_084630-fermions-fred-26af2", "status": "DONE", "detail": "None; Passed json sanity check; Compilation done. Shots sent to solver.", "error_message": "None"}
As we can see the job is finished, so let us see the results the get_job_result
endpoint.
url = url_prefix + "get_job_result"
result_response = requests.get(
url, params={"job_id": job_id, "username": username, "token": token}
)
pprint(result_response.json())
{'backend_name': 'alqor_fermionic_tweezer_simulator', 'backend_version': '0.0.2', 'experiments': [{'experiment_0': {'instructions': [['load', [7], []], ['load', [2], []], ['load', [0], []], ['measure', [0], []], ['measure', [2], []], ['measure', [6], []], ['measure', [7], []]], 'num_wires': 8, 'shots': 4, 'wire_order': 'interleaved'}}], 'header': {}, 'job_id': '20230429_084630-fermions-fred-26af2', 'qobj_id': None, 'results': [{'data': {'memory': ['1 1 0 1', '1 1 0 1', '1 1 0 1', '1 1 0 1']}, 'header': {'extra metadata': 'text', 'name': 'experiment_0'}, 'shots': 4, 'success': True}], 'status': 'finished', 'success': True}
Hopping¶
Next we can implement a hopping sequence, where the atoms move from site to site as described in the json below.
n_phases = 11 # number of phases we would like to investigate
phases = np.linspace(0, np.pi, n_phases) # array of phases
job_payload = {}
for ii in range(n_phases):
exp_str = "experiment_" + str(ii)
dummy_exp = {
"instructions": [
("load", [0], []),
("load", [1], []),
("fhop", [0, 1, 2, 3], [phases[ii]]),
("measure", [0], []),
("measure", [1], []),
("measure", [2], []),
("measure", [3], []),
],
"num_wires": 8,
"shots": 9,
"wire_order": "interleaved",
}
job_payload[exp_str] = dummy_exp
pprint(job_payload)
{'experiment_0': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.0]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 9, 'wire_order': 'interleaved'}, 'experiment_1': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.3141592653589793]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 9, 'wire_order': 'interleaved'}, 'experiment_10': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [3.141592653589793]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 9, 'wire_order': 'interleaved'}, 'experiment_2': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.6283185307179586]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 9, 'wire_order': 'interleaved'}, 'experiment_3': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.9424777960769379]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 9, 'wire_order': 'interleaved'}, 'experiment_4': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [1.2566370614359172]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 9, 'wire_order': 'interleaved'}, 'experiment_5': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [1.5707963267948966]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 9, 'wire_order': 'interleaved'}, 'experiment_6': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [1.8849555921538759]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 9, 'wire_order': 'interleaved'}, 'experiment_7': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [2.199114857512855]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 9, 'wire_order': 'interleaved'}, 'experiment_8': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [2.5132741228718345]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 9, 'wire_order': 'interleaved'}, 'experiment_9': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [2.827433388230814]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 9, 'wire_order': 'interleaved'}}
url = url_prefix + "post_job"
pprint(url)
job_response = requests.post(
url,
json={"job": json.dumps(job_payload), "username": username, "token": token},
)
job_id = (job_response.json())["job_id"]
print(job_response.json())
'https://qlued.alqor.io/api/v2/fermions/post_job' {'job_id': '20230429_084657-fermions-fred-fe539', 'status': 'INITIALIZING', 'detail': 'Got your json.', 'error_message': 'None'}
url = url_prefix + "get_job_status"
status_response = requests.get(
url, params={"job_id": job_id, "username": username, "token": token}
)
pprint(status_response.json())
{'detail': 'None; Passed json sanity check; Compilation done. Shots sent to ' 'solver.', 'error_message': 'None', 'job_id': '20230429_084657-fermions-fred-fe539', 'status': 'DONE'}
url = url_prefix + "get_job_result"
result_response = requests.get(
url, params={"job_id": job_id, "username": username, "token": token}
)
results_dict = result_response.json()
Once, we obtained the results, we can format them for a nice print out and plot up the time evolution of the hopping atoms.
measurements = []
for res in results_dict["results"]:
shots = np.array(res["data"]["memory"])
shots = [shot.split(" ") for shot in shots]
# print(shots.shape)
for ii, el in enumerate(shots):
shots[ii] = [int(meas) for meas in el]
measurements.append(shots)
measurements = np.array(measurements)
n0s = measurements[:, :, 0]
n1s = measurements[:, :, 1]
n2s = measurements[:, :, 2]
n3s = measurements[:, :, 3]
f, (ax1, ax2) = plt.subplots(2, 1, sharex=True)
ax1.plot(phases, n0s, "rx", alpha=0.1)
ax1.plot(phases, n0s.mean(axis=1), "ro")
# ax1.plot(phases, n0s, 'ro', alpha = 0.3)
ax1.plot(phases, (1 + np.cos(2 * phases)) / 2, "r-", lw=3)
ax1.plot(phases, n2s, "bx", alpha=0.3)
ax1.plot(phases, n2s.mean(axis=1), "bo")
ax1.plot(phases, 1 - (1 + np.cos(2 * phases)) / 2, "b-", lw=3)
ax1.set_ylabel(r"spin up occupations")
ax2.plot(phases, n1s, "rx", alpha=0.1)
ax2.plot(phases, n1s.mean(axis=1), "ro")
ax2.plot(phases, (1 + np.cos(2 * phases)) / 2, "r-", lw=3)
ax2.plot(phases, n3s, "bx", alpha=0.1)
ax2.plot(phases, n3s.mean(axis=1), "bo")
ax2.plot(phases, 1 - (1 + np.cos(2 * phases)) / 2, "b-", lw=3)
ax2.set_ylabel("spin down occupations")
ax2.set_xlabel("$\\theta$");
Interaction a la Selim¶
In this section we reproduce the results from the experiments that were performed in Heidelberg.
n_phases = 11 # number of phases we would like to investigate
phases = np.linspace(0, np.pi, n_phases) # array of phases
Ntrott = 5
job_payload = {}
for ii in range(n_phases):
exp_str = "experiment_" + str(ii)
dummy_exp = {
"instructions": [
("load", [0], []),
("load", [1], []),
("fhop", [0, 1, 2, 3], [phases[ii] / Ntrott]),
("fint", [0, 1, 2, 3, 4, 5, 6, 7], [phases[ii] / Ntrott]),
("fhop", [0, 1, 2, 3], [phases[ii] / Ntrott]),
("fint", [0, 1, 2, 3, 4, 5, 6, 7], [phases[ii] / Ntrott]),
("fhop", [0, 1, 2, 3], [phases[ii] / Ntrott]),
("fint", [0, 1, 2, 3, 4, 5, 6, 7], [phases[ii] / Ntrott]),
("fhop", [0, 1, 2, 3], [phases[ii] / Ntrott]),
("fint", [0, 1, 2, 3, 4, 5, 6, 7], [phases[ii] / Ntrott]),
("fhop", [0, 1, 2, 3], [phases[ii] / Ntrott]),
("fint", [0, 1, 2, 3, 4, 5, 6, 7], [phases[ii] / Ntrott]),
("measure", [0], []),
("measure", [1], []),
("measure", [2], []),
("measure", [3], []),
],
"num_wires": 8,
"shots": 100,
"wire_order": "interleaved",
}
job_payload[exp_str] = dummy_exp
pprint(job_payload)
{'experiment_0': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.0]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.0]), ('fhop', [0, 1, 2, 3], [0.0]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.0]), ('fhop', [0, 1, 2, 3], [0.0]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.0]), ('fhop', [0, 1, 2, 3], [0.0]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.0]), ('fhop', [0, 1, 2, 3], [0.0]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.0]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 100, 'wire_order': 'interleaved'}, 'experiment_1': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.06283185307179587]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.06283185307179587]), ('fhop', [0, 1, 2, 3], [0.06283185307179587]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.06283185307179587]), ('fhop', [0, 1, 2, 3], [0.06283185307179587]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.06283185307179587]), ('fhop', [0, 1, 2, 3], [0.06283185307179587]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.06283185307179587]), ('fhop', [0, 1, 2, 3], [0.06283185307179587]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.06283185307179587]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 100, 'wire_order': 'interleaved'}, 'experiment_10': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.6283185307179586]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.6283185307179586]), ('fhop', [0, 1, 2, 3], [0.6283185307179586]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.6283185307179586]), ('fhop', [0, 1, 2, 3], [0.6283185307179586]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.6283185307179586]), ('fhop', [0, 1, 2, 3], [0.6283185307179586]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.6283185307179586]), ('fhop', [0, 1, 2, 3], [0.6283185307179586]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.6283185307179586]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 100, 'wire_order': 'interleaved'}, 'experiment_2': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.12566370614359174]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.12566370614359174]), ('fhop', [0, 1, 2, 3], [0.12566370614359174]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.12566370614359174]), ('fhop', [0, 1, 2, 3], [0.12566370614359174]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.12566370614359174]), ('fhop', [0, 1, 2, 3], [0.12566370614359174]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.12566370614359174]), ('fhop', [0, 1, 2, 3], [0.12566370614359174]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.12566370614359174]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 100, 'wire_order': 'interleaved'}, 'experiment_3': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.18849555921538758]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.18849555921538758]), ('fhop', [0, 1, 2, 3], [0.18849555921538758]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.18849555921538758]), ('fhop', [0, 1, 2, 3], [0.18849555921538758]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.18849555921538758]), ('fhop', [0, 1, 2, 3], [0.18849555921538758]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.18849555921538758]), ('fhop', [0, 1, 2, 3], [0.18849555921538758]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.18849555921538758]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 100, 'wire_order': 'interleaved'}, 'experiment_4': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.25132741228718347]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.25132741228718347]), ('fhop', [0, 1, 2, 3], [0.25132741228718347]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.25132741228718347]), ('fhop', [0, 1, 2, 3], [0.25132741228718347]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.25132741228718347]), ('fhop', [0, 1, 2, 3], [0.25132741228718347]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.25132741228718347]), ('fhop', [0, 1, 2, 3], [0.25132741228718347]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.25132741228718347]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 100, 'wire_order': 'interleaved'}, 'experiment_5': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.3141592653589793]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.3141592653589793]), ('fhop', [0, 1, 2, 3], [0.3141592653589793]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.3141592653589793]), ('fhop', [0, 1, 2, 3], [0.3141592653589793]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.3141592653589793]), ('fhop', [0, 1, 2, 3], [0.3141592653589793]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.3141592653589793]), ('fhop', [0, 1, 2, 3], [0.3141592653589793]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.3141592653589793]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 100, 'wire_order': 'interleaved'}, 'experiment_6': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.37699111843077515]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.37699111843077515]), ('fhop', [0, 1, 2, 3], [0.37699111843077515]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.37699111843077515]), ('fhop', [0, 1, 2, 3], [0.37699111843077515]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.37699111843077515]), ('fhop', [0, 1, 2, 3], [0.37699111843077515]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.37699111843077515]), ('fhop', [0, 1, 2, 3], [0.37699111843077515]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.37699111843077515]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 100, 'wire_order': 'interleaved'}, 'experiment_7': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.43982297150257105]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.43982297150257105]), ('fhop', [0, 1, 2, 3], [0.43982297150257105]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.43982297150257105]), ('fhop', [0, 1, 2, 3], [0.43982297150257105]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.43982297150257105]), ('fhop', [0, 1, 2, 3], [0.43982297150257105]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.43982297150257105]), ('fhop', [0, 1, 2, 3], [0.43982297150257105]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.43982297150257105]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 100, 'wire_order': 'interleaved'}, 'experiment_8': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.5026548245743669]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.5026548245743669]), ('fhop', [0, 1, 2, 3], [0.5026548245743669]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.5026548245743669]), ('fhop', [0, 1, 2, 3], [0.5026548245743669]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.5026548245743669]), ('fhop', [0, 1, 2, 3], [0.5026548245743669]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.5026548245743669]), ('fhop', [0, 1, 2, 3], [0.5026548245743669]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.5026548245743669]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 100, 'wire_order': 'interleaved'}, 'experiment_9': {'instructions': [('load', [0], []), ('load', [1], []), ('fhop', [0, 1, 2, 3], [0.5654866776461628]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.5654866776461628]), ('fhop', [0, 1, 2, 3], [0.5654866776461628]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.5654866776461628]), ('fhop', [0, 1, 2, 3], [0.5654866776461628]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.5654866776461628]), ('fhop', [0, 1, 2, 3], [0.5654866776461628]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.5654866776461628]), ('fhop', [0, 1, 2, 3], [0.5654866776461628]), ('fint', [0, 1, 2, 3, 4, 5, 6, 7], [0.5654866776461628]), ('measure', [0], []), ('measure', [1], []), ('measure', [2], []), ('measure', [3], [])], 'num_wires': 8, 'shots': 100, 'wire_order': 'interleaved'}}
url = url_prefix + "post_job"
pprint(url)
job_response = requests.post(
url,
json={"job": json.dumps(job_payload), "username": username, "token": token},
)
job_id = (job_response.json())["job_id"]
print(job_response.json())
'https://qlued.alqor.io/api/v2/fermions/post_job' {'job_id': '20230429_084727-fermions-fred-de694', 'status': 'INITIALIZING', 'detail': 'Got your json.', 'error_message': 'None'}
url = url_prefix + "get_job_status"
status_response = requests.get(
url, params={"job_id": job_id, "username": username, "token": token}
)
pprint(status_response.json())
{'detail': 'None; Passed json sanity check; Compilation done. Shots sent to ' 'solver.', 'error_message': 'None', 'job_id': '20230429_084727-fermions-fred-de694', 'status': 'DONE'}
url = url_prefix + "get_job_result"
result_response = requests.get(
url, params={"job_id": job_id, "username": username, "token": token}
)
results_dict = result_response.json()
measurements = []
for res in results_dict["results"]:
shots = np.array(res["data"]["memory"])
shots = [shot.split(" ") for shot in shots]
for ii, el in enumerate(shots):
shots[ii] = [int(meas) for meas in el]
measurements.append(shots)
measurements = np.array(measurements)
n0s = measurements[:, :, 0]
n1s = measurements[:, :, 1]
n2s = measurements[:, :, 2]
n3s = measurements[:, :, 3]
f, ax = plt.subplots()
ax.plot(phases, 1 + np.cos(2 * phases), "r-")
ax.plot(phases, n0s.mean(axis=1) + n1s.mean(axis=1), "ro")
ax.set_xlabel("$\\theta$")
ax.set_ylabel("occupation of site 1");
We can see a clear effect of the interactions compared to the naive dynamics. For a detailled analysis and comparison o the experimental results, feel free to have a look in this qiskit tutorial.