The current process to perform a tomography experiment is the following:
- Call
sqt_bloch_tomography_submit that generates a pickle file in
|
backup( |
|
args.backup_dir, |
|
circuits, |
|
backend, |
|
basis, |
|
args.hub, |
|
args.group, |
|
args.project, |
|
job, |
|
args.delay_dt, |
|
qubit_number, |
|
shots, |
|
) |
by calling
|
def backup( |
|
backup_dir: Path, |
|
raw_circuits: list[QuantumCircuit], |
|
backend, |
|
basis: BaseMeasurementBasis, |
|
hub: str, |
|
group: str, |
|
project: str, |
|
job: RuntimeJob, |
|
delay_dt: int, |
|
qubit_number: int, |
|
shots: int, |
|
) -> None: |
|
backup_filename: Path = get_backup_filename( |
|
backup_dir, raw_circuits, backend, basis, job, delay_dt, shots |
|
) |
|
jobid: str = job.job_id() |
|
result = job.result() |
|
print(f"Backing up in '{backup_filename}'.") |
|
with open(backup_filename, "wb") as f: |
|
pickle.dump( |
|
{ |
|
"job_id": jobid, |
|
"raw_circuits": raw_circuits, |
|
"basis": basis, |
|
"backend_name": backend.name, |
|
"provider": {"hub": hub, "group": group, "project": project}, |
|
"delay_dt": delay_dt, |
|
"qubit_number": qubit_number, |
|
"result": result, |
|
"shots": shots, |
|
}, |
|
f, |
|
) |
- Call
sqt_bloch_tomography_recover that reads the pickle file generated in 1., post-process the results and generates a second pickle file with the post-processed results.
The sqmap tool is following the same scheme, reading the post-processed tomography results in a pickle file and generating plots.
This methodology has several drawbacks:
pickle files are not easy to read as humans (need to call python -m pickle [file] and parse the output),
- there might be incompatibilities in the long run if some of the libraries used change their representation,
- both read and write code should exactly agree.
Using JSON as exchange format would solve all these drawbacks at the following costs:
- might need a little more code to generate the JSON,
- the resulting file will be larger in size due to the JSON text encoding (might be mitigated by using compression, but then we would loose the "easy to read for humans" again).
Using JSON might as well help in allowing other tools written in other languages to use the output of sqt.
All in all, using JSON as the only exchange format would be beneficial.
The current process to perform a tomography experiment is the following:
sqt_bloch_tomography_submitthat generates apicklefile insqt/src/sqt/_cli/bloch_tomography_submit.py
Lines 317 to 329 in 3c9fe16
sqt/src/sqt/_cli/bloch_tomography_submit.py
Lines 63 to 96 in 3c9fe16
sqt_bloch_tomography_recoverthat reads thepicklefile generated in 1., post-process the results and generates a secondpicklefile with the post-processed results.The
sqmaptool is following the same scheme, reading the post-processed tomography results in apicklefile and generating plots.This methodology has several drawbacks:
picklefiles are not easy to read as humans (need to callpython -m pickle [file]and parse the output),Using JSON as exchange format would solve all these drawbacks at the following costs:
Using JSON might as well help in allowing other tools written in other languages to use the output of
sqt.All in all, using JSON as the only exchange format would be beneficial.