Skip to content

Simulation result

QuEraSimulationResult dataclass

QuEraSimulationResult(
    flair_visual_version: str,
    counts: dict[str, int],
    logs: DataFrame,
    atom_animation_state: AnimateQPUState,
    noise_model: NoiseModel,
)

Results of the QuEra hardware model simulation.

Fields

flair_visual_version (str): The version of the Flair Visual package used to generate the simulation result. counts (dict[str, int]): The measurement bitstrings of the simulation. logs (DataFrame): Grainular logs events of what happened to each atom during the simulation. atom_animation_state (vis_qpustate.AnimateQPUState): Object used to play back atom trajectories and events during the simulation. noise_model (NoiseModel): The noise model used in the simulation.

animate

animate(
    dilation_rate: float = 0.05,
    fps: int = 30,
    gate_display_dilation: float = 1.0,
    save_mpeg: bool = False,
    filename: str = "vqpu_animation",
    start_block: int = 0,
    n_blocks: Optional[int] = None,
)

animate the qpu state

Parameters:

Name Type Description Default
dilation_rate float

Conversion factor from the qpu time to animation time units. when dilation_rate=1.0, 1 (us) of qpu exec time corresponds to 1 second of animation time.

0.05
fps int

frame per second. Defaults to 30.

30
gate_display_dilation float

relative dilation rate of a gate event. Defaults to 1. When setting higher value, the gate event will be displayed longer.

1.0
save_mpeg bool

Save as mpeg. Defaults to False.

False
filename str

The file name of saved mpeg file. Defaults to "vqpu_animation". When save_mpeg is False, this argument is ignored.

'vqpu_animation'
start_block int

The start block to animate. Defaults to 0.

0
n_blocks int

number of blocks to animate. Defaults to None. When None, animate all blocks after start_block.

None

Returns: ani: matplotlib animation object

Source code in .venv/lib/python3.12/site-packages/bloqade/qbraid/simulation_result.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
def animate(
    self,
    dilation_rate: float = 0.05,
    fps: int = 30,
    gate_display_dilation: float = 1.0,
    save_mpeg: bool = False,
    filename: str = "vqpu_animation",
    start_block: int = 0,
    n_blocks: Optional[int] = None,
):
    """animate the qpu state

    Args:
        dilation_rate (float): Conversion factor from the qpu time to animation time units. when dilation_rate=1.0, 1 (us) of qpu exec time corresponds to 1 second of animation time.
        fps (int, optional): frame per second. Defaults to 30.
        gate_display_dilation (float, optional): relative dilation rate of a gate event. Defaults to 1. When setting higher value, the gate event will be displayed longer.
        save_mpeg (bool, optional): Save as mpeg. Defaults to False.
        filename (str, optional): The file name of saved mpeg file. Defaults to "vqpu_animation". When `save_mpeg` is False, this argument is ignored.
        start_block (int, optional): The start block to animate. Defaults to 0.
        n_blocks (int, optional): number of blocks to animate. Defaults to None. When None, animate all blocks after `start_block`.
    Returns:
        ani: matplotlib animation object
    """
    from bloqade.visual.animation.animate import animate_qpu_state

    ani = animate_qpu_state(
        state=self.atom_animation_state,
        dilation_rate=dilation_rate,
        fps=fps,
        gate_display_dilation=gate_display_dilation,
        start_block=start_block,
        n_blocks=n_blocks,
        save_mpeg=save_mpeg,
        filename=filename,
    )
    return ani

from_json classmethod

from_json(json: dict) -> QuEraSimulationResult

deserialize the object from a JSON serializable dictionary.

Source code in .venv/lib/python3.12/site-packages/bloqade/qbraid/simulation_result.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@classmethod
def from_json(cls, json: dict) -> "QuEraSimulationResult":
    """deserialize the object from a JSON serializable dictionary."""
    flair_visual_version = json["flair_visual_version"]
    counts = json["counts"]
    logs = pd.read_csv(StringIO(json["logs"]), index_col=0)
    atom_animation_state = vis_qpustate.AnimateQPUState.from_json(
        json["atom_animation_state"]
    )
    noise_model = NoiseModel(**json["noise_model"])

    return cls(
        flair_visual_version=flair_visual_version,
        counts=counts,
        logs=logs,
        atom_animation_state=atom_animation_state,
        noise_model=noise_model,
    )

to_json

to_json() -> Dict[str, Any]

Turn the object into a JSON serializable dictionary.

Source code in .venv/lib/python3.12/site-packages/bloqade/qbraid/simulation_result.py
54
55
56
57
58
59
60
61
62
def to_json(self) -> Dict[str, Any]:
    """Turn the object into a JSON serializable dictionary."""
    return {
        "flair_visual_version": self.flair_visual_version,
        "counts": self.counts,
        "logs": self.logs.to_csv(),
        "atom_animation_state": self.atom_animation_state.to_json(),
        "noise_model": self.noise_model.model_dump(mode="json"),
    }