Simulator
DetectorResult
dataclass
DetectorResult(
_detector_error_model: DetectorErrorModel,
_fidelity_min: float,
_fidelity_max: float,
_detectors: list[list[bool]],
_observables: list[list[bool]],
)
Result from the detector sampler containing only detector and observable outcomes.
detector_error_model
property
detector_error_model: DetectorErrorModel
The STIM detector error model corresponding to the physical noise circuit.
Returns:
| Name | Type | Description |
|---|---|---|
DetectorErrorModel |
DetectorErrorModel
|
The STIM detector error model. |
detectors
property
detectors: tuple[tuple[bool, ...], ...]
The detector outcomes from the simulation.
Returns:
| Type | Description |
|---|---|
tuple[tuple[bool, ...], ...]
|
tuple[tuple[bool, ...], ...]: The detector outcomes, one tuple per shot. |
observables
property
observables: tuple[tuple[bool, ...], ...]
The observable outcomes from the simulation.
Returns:
| Type | Description |
|---|---|
tuple[tuple[bool, ...], ...]
|
tuple[tuple[bool, ...], ...]: The observable outcomes, one tuple per shot. |
fidelity_bounds
fidelity_bounds() -> tuple[float, float]
Return the upper and lower fidelity bounds.
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
tuple[float, float]: The (min, max) fidelity bounds. |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
60 61 62 63 64 65 66 67 | |
GeminiLogicalSimulator
dataclass
GeminiLogicalSimulator(
noise_model: LogicalNoiseModelABC = _default_noise_model(),
)
Logical simulator targeting the Gemini neutral-atom architecture.
This is the primary entry point for compiling and simulating logical quantum
circuits on the Gemini architecture. Use :meth:task to compile a kernel into
a reusable :class:GeminiLogicalSimulatorTask, or :meth:run for one-shot
compile-and-execute convenience.
noise_model
class-attribute
instance-attribute
noise_model: LogicalNoiseModelABC = field(
default_factory=_default_noise_model
)
The noise model used for simulation. Defaults to :func:generate_logical_noise_model.
fidelity_bounds
fidelity_bounds(
logical_squin_kernel: Method[[], RetType],
) -> tuple[float, float]
Get the fidelity bounds for the logical squin kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logical_squin_kernel
|
Method[[], RetType]
|
The logical squin kernel to analyze. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
tuple[float, float]: The (min, max) fidelity bounds. |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
691 692 693 694 695 696 697 698 699 700 701 702 703 | |
physical_move_kernel
physical_move_kernel(
logical_squin_kernel: Method[[], RetType],
) -> ir.Method[[], RetType]
Compile the logical squin kernel to the physical move kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logical_squin_kernel
|
Method[[], RetType]
|
The logical squin kernel to compile. |
required |
Returns:
| Type | Description |
|---|---|
Method[[], RetType]
|
ir.Method[[], RetType]: The physical move kernel. |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
659 660 661 662 663 664 665 666 667 668 669 670 671 | |
physical_squin_kernel
physical_squin_kernel(
logical_squin_kernel: Method[[], RetType],
) -> ir.Method[[], RetType]
Compile the logical squin kernel to the physical squin kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logical_squin_kernel
|
Method[[], RetType]
|
The logical squin kernel to compile. |
required |
Returns:
| Type | Description |
|---|---|
Method[[], RetType]
|
ir.Method[[], RetType]: The physical squin kernel. |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
645 646 647 648 649 650 651 652 653 654 655 656 657 | |
run
run(
logical_squin_kernel: Method[[], RetType],
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: Literal[False] = ...
) -> Result[RetType]
run(
logical_squin_kernel: Method[[], RetType],
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: Literal[True]
) -> DetectorResult
run(
logical_squin_kernel: Method[[], RetType],
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: bool
) -> Result[RetType] | DetectorResult
run(
logical_squin_kernel: Method[[], RetType],
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: bool = False
) -> Result[RetType] | DetectorResult
Run the kernel and get simulation results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logical_squin_kernel
|
Method[[], RetType]
|
The logical squin kernel to run. |
required |
shots
|
int
|
Number of shots to run. Defaults to 1. |
1
|
with_noise
|
bool
|
Whether to include noise in the simulation. Defaults to True. |
True
|
run_detectors
|
bool
|
When |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Result[RetType] | DetectorResult
|
Result[RetType]: When |
|
DetectorResult |
Result[RetType] | DetectorResult
|
When |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |
run_async
run_async(
logical_squin_kernel: Method[[], RetType],
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: Literal[False] = ...
) -> Future[Result[RetType]]
run_async(
logical_squin_kernel: Method[[], RetType],
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: Literal[True]
) -> Future[DetectorResult]
run_async(
logical_squin_kernel: Method[[], RetType],
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: bool = False
) -> Future[Result[RetType]] | Future[DetectorResult]
Run the kernel asynchronously and get simulation results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logical_squin_kernel
|
Method[[], RetType]
|
The logical squin kernel to run. |
required |
shots
|
int
|
Number of shots to run. Defaults to 1. |
1
|
with_noise
|
bool
|
Whether to include noise in the simulation. Defaults to True. |
True
|
run_detectors
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
Future[Result[RetType]] | Future[DetectorResult]
|
Future[Result[RetType]]: When |
Future[Result[RetType]] | Future[DetectorResult]
|
Future[DetectorResult]: When |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | |
task
task(
logical_kernel: Union[
Method[[], RetType], Callable[..., Any]
],
m2dets: list[list[int]] | None = None,
m2obs: list[list[int]] | None = None,
) -> GeminiLogicalSimulatorTask[RetType]
Create a simulation task for the given kernel.
Eagerly compiles the kernel through squin-to-move and extracts post-processing. For CUDA-Q kernels, detector and observable annotation matrices default to Steane [[7,1,3]] parity checks when not provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logical_kernel
|
Union[Method[[], RetType], Callable[..., Any]]
|
The logical squin or CUDA-Q kernel to compile and run. |
required |
m2dets
|
list[list[int]] | None
|
Binary measurement-to-detector matrix.
For CUDA-Q kernels, defaults to Steane [[7,1,3]] detectors if |
None
|
m2obs
|
list[list[int]] | None
|
Binary measurement-to-observable matrix.
For CUDA-Q kernels, defaults to Steane [[7,1,3]] observables if |
None
|
Returns:
| Type | Description |
|---|---|
GeminiLogicalSimulatorTask[RetType]
|
GeminiLogicalSimulatorTask[RetType]: The compiled simulation task. |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | |
tsim_circuit
tsim_circuit(
logical_squin_kernel: Method[[], RetType],
with_noise: bool = True,
) -> tsim_backend.Circuit
Compile the logical squin kernel to the tsim circuit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logical_squin_kernel
|
Method[[], RetType]
|
The logical squin kernel to compile. |
required |
with_noise
|
bool
|
Whether to include noise in the tsim circuit. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
Circuit
|
tsim.Circuit: The compiled tsim circuit. |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 | |
visualize
visualize(
logical_squin_kernel: Method[[], RetType],
animated: bool = False,
interactive: bool = True,
)
Visualize the physical move kernel using the built-in debugger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logical_squin_kernel
|
Method[[], RetType]
|
The logical squin kernel to visualize. |
required |
animated
|
bool
|
Whether to use the animated debugger. Defaults to False. |
False
|
interactive
|
bool
|
Whether to enable interactive mode. Defaults to True. |
True
|
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | |
GeminiLogicalSimulatorTask
dataclass
GeminiLogicalSimulatorTask(
logical_squin_kernel: Method[[], RetType],
noise_model: LogicalNoiseModelABC,
physical_arch_spec: ArchSpec,
physical_move_kernel: Method[[], RetType],
_post_processing: PostProcessing[RetType],
)
Bases: Generic[RetType]
flowchart TD
bloqade.gemini.device.simulator.GeminiLogicalSimulatorTask[GeminiLogicalSimulatorTask]
click bloqade.gemini.device.simulator.GeminiLogicalSimulatorTask href "" "bloqade.gemini.device.simulator.GeminiLogicalSimulatorTask"
A compiled simulation task for the Gemini logical simulator.
Created by :meth:GeminiLogicalSimulator.task. The squin-to-move compilation
and post-processing extraction are performed eagerly at construction time.
Simulation artifacts (physical squin kernel, stim circuits, samplers, detector
error model) are computed lazily on first access since they depend on the
noise model.
detector_error_model
cached
property
detector_error_model
The STIM detector error model corresponding to the tsim circuit.
detector_sampler
cached
property
detector_sampler
The tsim detector sampler.
logical_squin_kernel
instance-attribute
logical_squin_kernel: Method[[], RetType]
The input logical squin kernel to be executed on the Gemini architecture.
measurement_sampler
cached
property
measurement_sampler
The tsim measurement sampler.
noise_model
instance-attribute
noise_model: LogicalNoiseModelABC
The noise model to be inserted into the physical squin kernel.
noiseless_detector_sampler
cached
property
noiseless_detector_sampler
The noiseless tsim detector sampler.
noiseless_measurement_sampler
cached
property
noiseless_measurement_sampler
The noiseless tsim measurement sampler.
noiseless_physical_squin_kernel
cached
property
noiseless_physical_squin_kernel: Method[[], RetType]
The physical squin kernel without noise channels.
noiseless_tsim_circuit
cached
property
noiseless_tsim_circuit: Circuit
The noiseless tsim circuit compiled without noise channels.
physical_arch_spec
class-attribute
instance-attribute
physical_arch_spec: ArchSpec = field(repr=False)
The physical architecture specification.
physical_move_kernel
class-attribute
instance-attribute
physical_move_kernel: Method[[], RetType] = field(
repr=False
)
The physical move kernel that executes the logical squin kernel on the physical architecture.
physical_squin_kernel
cached
property
physical_squin_kernel: Method[[], RetType]
The physical squin kernel with noise channels.
tsim_circuit
cached
property
tsim_circuit: Circuit
The tsim circuit corresponding to the physical squin kernel.
fidelity_bounds
fidelity_bounds() -> tuple[float, float]
Compute the fidelity bounds for the physical squin kernel.
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
tuple[float, float]: The (min, max) fidelity bounds. |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
run
run(
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: Literal[False] = ...
) -> Result[RetType]
run(
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: Literal[True]
) -> DetectorResult
run(
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: bool
) -> Result[RetType] | DetectorResult
run(
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: bool = False
) -> Result[RetType] | DetectorResult
Run the kernel and get simulation results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shots
|
int
|
Number of shots to run. Defaults to 1. |
1
|
with_noise
|
bool
|
Whether to include noise in the simulation. Defaults to True. |
True
|
run_detectors
|
bool
|
When |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Result[RetType] | DetectorResult
|
Result[RetType]: When |
|
DetectorResult |
Result[RetType] | DetectorResult
|
When |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
run_async
run_async(
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: Literal[False] = ...
) -> Future[Result[RetType]]
run_async(
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: Literal[True]
) -> Future[DetectorResult]
run_async(
shots: int = 1,
with_noise: bool = True,
*,
run_detectors: bool = False
) -> Future[Result[RetType]] | Future[DetectorResult]
Run the kernel asynchronously and get simulation results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shots
|
int
|
Number of shots to run. Defaults to 1. |
1
|
with_noise
|
bool
|
Whether to include noise in the simulation. Defaults to True. |
True
|
run_detectors
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
Future[Result[RetType]] | Future[DetectorResult]
|
Future[Result[RetType]]: When |
Future[Result[RetType]] | Future[DetectorResult]
|
Future[DetectorResult]: When |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | |
visualize
visualize(animated: bool = False, interactive: bool = True)
Visualize the physical move kernel using the built-in debugger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
animated
|
bool
|
Whether to use the animated debugger. Defaults to False. |
False
|
interactive
|
bool
|
Whether to enable interactive mode. Defaults to True. |
True
|
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
Result
dataclass
Result(
_raw_measurements: list[list[bool]],
_detector_error_model: DetectorErrorModel,
_post_processing: PostProcessing[RetType],
_fidelity_min: float,
_fidelity_max: float,
)
Bases: Generic[RetType]
flowchart TD
bloqade.gemini.device.simulator.Result[Result]
click bloqade.gemini.device.simulator.Result href "" "bloqade.gemini.device.simulator.Result"
Simulation result including measurement outcomes, detector error model, post-processing, and fidelity bounds.
detector_error_model
property
detector_error_model: DetectorErrorModel
The STIM detector error model corresponding to the physical noise circuit.
Returns:
| Name | Type | Description |
|---|---|---|
DetectorErrorModel |
DetectorErrorModel
|
The STIM detector error model. |
detectors
cached
property
detectors: list[list[bool]]
The detector outcomes from the simulation.
Returns:
| Type | Description |
|---|---|
list[list[bool]]
|
list[list[bool]]: The detector outcomes, one list per shot. |
measurements
cached
property
measurements: list[list[bool]]
The raw measurement outcomes used to compute detectors and observables.
Returns:
| Type | Description |
|---|---|
list[list[bool]]
|
list[list[bool]]: The raw measurement outcomes, one list per shot. |
observables
cached
property
observables: list[list[bool]]
The observable outcomes from the simulation.
Returns:
| Type | Description |
|---|---|
list[list[bool]]
|
list[list[bool]]: The observable outcomes, one list per shot. |
return_values
cached
property
return_values: list[RetType]
The return values of the logical kernel.
Returns:
| Type | Description |
|---|---|
list[RetType]
|
list[RetType]: The return values, one per shot. |
fidelity_bounds
fidelity_bounds() -> tuple[float, float]
Return the upper and lower fidelity bounds.
Note: The upper and lower bounds are related to branching logic in the kernel.
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
tuple[float, float]: The (min, max) fidelity bounds. |
Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/device/simulator.py
110 111 112 113 114 115 116 117 118 119 | |