Device
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.py
49 50 51 52 53 54 55 56 | |
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.py
664 665 666 667 668 669 670 671 672 673 674 675 676 | |
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.py
632 633 634 635 636 637 638 639 640 641 642 643 644 | |
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.py
618 619 620 621 622 623 624 625 626 627 628 629 630 | |
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.py
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | |
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.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | |
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.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | |
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.py
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 | |
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.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | |
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]
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.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
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.py
320 321 322 323 324 325 326 327 328 329 330 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 | |
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.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | |
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.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
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]
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.py
99 100 101 102 103 104 105 106 107 108 | |