Bloqade
BloqadeEmulation dataclass
¶
Data class to hold the Hamiltonian and metadata for a given set of parameters
evolve ¶
evolve(
state=None,
solver_name="dop853",
atol=1e-07,
rtol=1e-14,
nsteps=2147483647,
times=(),
interaction_picture=False,
)
Evolve an initial state vector using the Hamiltonian
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state | Optional[StateVector] | The initial state vector to | None |
solver_name | str | Which SciPy Solver to use. Defaults to | 'dop853' |
atol | float | Absolute tolerance for ODE solver. Defaults | 1e-07 |
rtol | float | Relative tolerance for adaptive step in | 1e-14 |
nsteps | int | Maximum number of steps allowed per integration | 2147483647 |
times | Sequence[float] | The times to evaluate the state vector | () |
interaction_picture | bool | Use the interaction picture when | False |
Returns:
Type | Description |
---|---|
Iterator[StateVector] | Iterator[StateVector]: An iterator of the state vectors at each time step. |
Source code in src/bloqade/ir/routine/bloqade.py
fock_state ¶
Return the fock state for the given Hamiltonian.
Source code in src/bloqade/ir/routine/bloqade.py
zero_state ¶
BloqadePythonRoutine ¶
Bases: RoutineBase
hamiltonian ¶
hamiltonian(
*args,
blockade_radius=0.0,
use_hyperfine=False,
waveform_runtime="interpret",
cache_matrices=False
)
Generates a list of BloqadeEmulation objects which contain the Hamiltonian of your program.
If you have a variable(s) in your program you have assigned multiple values via batch_assign()
there will be multiple BloqadeEmulation
objects, one for each value. On the other hand if the program only assumes a singular value per each variable, there will only be one BloqadeEmulation
object but it will still be encapsulated in a list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args | LiteralType | If your program has a variable that was declared as run-time assignable via | () |
blockade_radius | float | The radius in which atoms blockade eachother. Default value is 0.0 micrometers. | 0.0 |
use_hyperfine | bool | Should the Hamiltonian account for hyperfine levels. Default value is False. | False |
waveform_runtime | str | Specify which runtime to use for waveforms. If "numba" is specify the waveform is compiled, otherwise it is interpreted via the "interpret" argument. Defaults to "interpret". | 'interpret' |
cache_matrices | bool | Speed up Hamiltonian generation by reusing data (when possible) from previously generated Hamiltonians. Default value is False. | False |
Returns:
Type | Description |
---|---|
List[BloqadeEmulation] | List[BloqadeEmulation] |
Source code in src/bloqade/ir/routine/bloqade.py
run ¶
run(
shots,
args=(),
name=None,
blockade_radius=0.0,
waveform_runtime="interpret",
interaction_picture=False,
cache_matrices=False,
multiprocessing=False,
num_workers=None,
solver_name="dop853",
atol=1e-07,
rtol=1e-14,
nsteps=2147483647,
)
Run the current program using bloqade python backend
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shots | int | number of shots after running state vector simulation | required |
args | Tuple[LiteralType, ...] | The values for parameters defined | () |
name | Optional[str] | Name to give this run. Defaults to None. | None |
blockade_radius | float | Use the Blockade subspace given a | 0.0 |
waveform_runtime | str | (bool, optional): Use Numba to compile the waveforms, | 'interpret' |
interaction_picture | bool | Use the interaction picture when | False |
cache_matrices | bool | Reuse previously evaluated matrcies when | False |
multiprocessing | bool | Use multiple processes to process the | False |
num_workers | Optional[int] | Number of processes to run with | None |
solver_name | str | Which SciPy Solver to use. Defaults to | 'dop853' |
atol | float | Absolute tolerance for ODE solver. Defaults to | 1e-07 |
rtol | float | Relative tolerance for adaptive step in ODE solver. | 1e-14 |
nsteps | int | Maximum number of steps allowed per integration | 2147483647 |
Raises:
Type | Description |
---|---|
ValueError | Cannot use multiprocessing and cache_matrices at the same time. |
Returns:
Name | Type | Description |
---|---|---|
LocalBatch | LocalBatch | Batch of local tasks that have been executed. |
Source code in src/bloqade/ir/routine/bloqade.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
run_callback ¶
run_callback(
callback,
program_args=(),
callback_args=(),
ignore_exceptions=False,
blockade_radius=0.0,
waveform_runtime="interpret",
interaction_picture=False,
cache_matrices=False,
multiprocessing=False,
num_workers=None,
solver_name="dop853",
atol=1e-07,
rtol=1e-14,
nsteps=2147483647,
use_hyperfine=False,
)
Run state-vector simulation with a callback to access full state-vector from emulator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback | Callable[[StateVector, Metadata, RydbergHamiltonian, Any], Any] | | required |
program_args | Tuple[LiteralType, ...] | The values for parameters | () |
callback_args | Tuple[Any, ...] | Extra arguments to pass into | () |
ignore_exceptions | bool | (bool, optional) If | False |
blockade_radius | float | Use the Blockade subspace given a | 0.0 |
waveform_runtime | str | (str, optional): Specify which runtime to use for | 'interpret' |
interaction_picture | bool | Use the interaction picture when | False |
cache_matrices | bool | Reuse previously evaluated matrcies when | False |
multiprocessing | bool | Use multiple processes to process the | False |
num_workers | Optional[int] | Number of processes to run with | None |
solver_name | str | Which SciPy Solver to use. Defaults to | 'dop853' |
atol | float | Absolute tolerance for ODE solver. Defaults to | 1e-07 |
rtol | float | Relative tolerance for adaptive step in ODE solver. | 1e-14 |
nsteps | int | Maximum number of steps allowed per integration | 2147483647 |
Returns:
Name | Type | Description |
---|---|---|
List | List | List of resulting outputs from the callbacks |
Raises:
Type | Description |
---|---|
RuntimeError | Raises the first error that occurs, only if |
Note
For the callback
function, first argument is the many-body wavefunction as a 1D complex numpy array, the second argument is of type Metadata
which is a Named Tuple where the fields correspond to the parameters of that given task, RydbergHamiltonian is the object that contains the Hamiltonian used to generate the evolution for that task, Finally any optional positional arguments are allowed after that. The return value can be anything, the results will be collected in a list for each task in the batch.
Source code in src/bloqade/ir/routine/bloqade.py
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 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 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 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 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 492 493 494 495 496 |
|
TaskData dataclass
¶
Data class to hold the program ir and metadata for a given set of parameters