Skip to content

Better exchange formats #3

@nelimee

Description

@nelimee

The current process to perform a tomography experiment is the following:

  1. 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,
    )
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions