API documentation of spoolers
This module contains the code for the Spooler classes and its helpers. So it mainly meant to be deployed on the back-end side for people that would like to perform calculations and work through the job queue.
The main class is the Spooler
class. It is the class that is used for the simulators.
The LabscriptSpooler
class is a specialized version of the Spooler
class that allows us to execute
jobs in labscript directly.
BaseSpooler
Bases: ABC
Abstract base class for spoolers. They are the main logic of the back-end.
Attributes:
Name | Type | Description |
---|---|---|
ins_schema_dict |
A dictionary the contains all the allowed instructions for this spooler. |
|
device_config |
A dictionary that some main config params for the experiment. |
|
n_wires |
maximum number of wires for the spooler |
|
n_max_shots |
the maximum number of shots for the spooler |
|
version |
the version of the backend |
|
cold_atom_type |
the type of cold atom that is used in the experiment |
|
n_max_experiments |
the maximum number of experiments that can be executed |
|
wire_order |
the order of the wires |
|
num_species |
the number of atomic species in the experiment |
|
sign |
sign the results of the job |
Source code in src/sqooler/spoolers.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 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 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 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 361 362 363 364 365 366 367 368 369 |
|
display_name: str
property
writable
The name of the spooler.
__init__(ins_schema_dict, device_config, n_wires, description='', n_max_shots=1000, version='0.0.1', cold_atom_type='spin', n_max_experiments=15, wire_order='interleaved', num_species=1, sign=False)
The constructor of the class.
Source code in src/sqooler/spoolers.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
check_dimension(json_dict)
Make sure that the Hilbert space dimension is not too large.
It can be implemented in the class that inherits, but it is not necessary. So this is only a placeholder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_dict |
dict
|
the dictonary with the instructions |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the error message |
bool |
bool
|
is the dimension ok ? |
Source code in src/sqooler/spoolers.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
check_experiment(exper_dict)
Check the validity of the experiment. It checks if the the instructions are valid based on the device configuration of the spooler.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exper_dict |
dict
|
The dictionary that contains the logic and should be verified. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The error message |
bool |
bool
|
Is the experiment ok ? |
Source code in src/sqooler/spoolers.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
check_instructions(ins_list)
Check all the instruction to make sure that they are valid and part of the allowed instructions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ins_list |
list
|
The list of instructions that should be checked. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The error message |
bool |
bool
|
Are the instructions ok ? |
Source code in src/sqooler/spoolers.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
check_json_dict(json_dict)
Check if the json file has the appropiate syntax.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_dict |
dict
|
the dictonary that we will test. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the error message |
bool |
bool
|
is the expression having the appropiate syntax ? |
dict |
dict[str, ExperimentalInputDict]
|
the cleaned dictionary with proper typing |
Source code in src/sqooler/spoolers.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
get_configuration()
Sends back the configuration dictionary of the spooler.
This creates the configuration of the Spooler. However, it does not contain
any information about the operational status. This is not really connected to
the machine but much rather to the queue etc. So items of the BackendConfigSchemaIn
like operational
or last_queue_check
are not set here at just the default values.
``
Returns:
Type | Description |
---|---|
BackendConfigSchemaIn
|
The configuration dictionary of the spooler. |
Source code in src/sqooler/spoolers.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
get_exp_input_dict(json_dict)
Transforms the dictionary into an ExperimentalInputDict object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_dict |
dict
|
The dictionary that should be transformed. |
required |
Returns:
Type | Description |
---|---|
ExperimentalInputDict
|
A ExperimentalInputDict object. |
Source code in src/sqooler/spoolers.py
319 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 |
|
get_private_jwk()
Get the private JWK for the spooler.
Returns:
Type | Description |
---|---|
JWK
|
The private JWK for the spooler. |
Raises:
Type | Description |
---|---|
ValueError
|
If the private JWK is not set. |
Source code in src/sqooler/spoolers.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
LabscriptSpooler
Bases: BaseSpooler
A specialized spooler class that allows us to execute jobs in labscript directly.
The main changes are that we need to add the job in a different way and connect it to a
runmanager.remoteClient
. It adds three new attributes to the BaseSpooler
class.
Attributes:
Name | Type | Description |
---|---|---|
remote_client |
The remote client that is used to connect to the labscript server. |
|
labscript_params |
The parameters that are used to generate the folder for the shots. |
|
run |
The run object that is used to execute the labscript file. |
Source code in src/sqooler/spoolers.py
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 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 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 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 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 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 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
|
__init__(ins_schema_dict, device_config, n_wires, remote_client, labscript_params, run, description='', n_max_shots=1000, version='0.0.1', cold_atom_type='spin', n_max_experiments=15, wire_order='interleaved', num_species=1, sign=False)
The constructor of the class. The arguments are the same as for the Spooler class with two additions.
Source code in src/sqooler/spoolers.py
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 497 498 499 500 501 |
|
add_job(json_dict, job_id)
The function that translates the json with the instructions into some circuit and executes it. It performs several checks for the job to see if it is properly working. If things are fine the job gets added the list of things that should be executed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_dict |
dict[str, dict]
|
The job dictonary of all the instructions. |
required |
job_id |
str
|
the id of the the job we are treating. |
required |
Returns:
Name | Type | Description |
---|---|---|
result_dict |
ResultDict
|
The dictionary with the results of the job. |
status_msg_dict |
StatusMsgDict
|
The status dictionary of the job. |
Source code in src/sqooler/spoolers.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
|
gen_circuit(exp_name, json_dict, job_id)
This is the main script that generates the labscript file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exp_name |
str
|
The name of the experiment |
required |
json_dict |
ExperimentalInputDict
|
The dictionary that contains the instructions for the circuit. |
required |
job_id |
str
|
The user id of the user that is running the experiment. |
required |
Returns:
Type | Description |
---|---|
ExperimentDict
|
The path to the labscript file. |
Source code in src/sqooler/spoolers.py
566 567 568 569 570 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 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 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
|
Spooler
Bases: BaseSpooler
The class for the spooler as it can be used for simulators.
Source code in src/sqooler/spoolers.py
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 |
|
gen_circuit: Callable[[str, ExperimentalInputDict], ExperimentDict]
property
writable
The function that generates the circuit. It can be basically anything that allows the execution of the circuit.
Returns:
Type | Description |
---|---|
Callable[[str, ExperimentalInputDict], ExperimentDict]
|
The function that generates the circuit. |
Raises:
Type | Description |
---|---|
ValueError
|
if the gen_circuit is not a callable function |
add_job(json_dict, job_id)
The function that translates the json with the instructions into some circuit and executes it. It performs several checks for the job to see if it is properly working. If things are fine the job gets added the list of things that should be executed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_dict |
dict[str, dict]
|
The job dictonary of all the instructions. |
required |
job_id |
str
|
the id of the the job we are treating. |
required |
Returns:
Name | Type | Description |
---|---|---|
result_dict |
ResultDict
|
The dictionary with the results of the job. |
status_msg_dict |
StatusMsgDict
|
The status dictionary of the job. |
Source code in src/sqooler/spoolers.py
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 |
|
create_memory_data(shots_array, exp_name, n_shots, instructions=None)
The function to create memory key in results dictionary with proprer formatting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shots_array |
list
|
The array with the shots. |
required |
exp_name |
str
|
The name of the experiment. |
required |
n_shots |
int
|
The number of shots. |
required |
instructions |
Optional[list[GateDict]]
|
The list of instructions that were executed |
None
|
Returns:
Type | Description |
---|---|
ExperimentDict
|
The ExperimentDict object describing the results. |
Source code in src/sqooler/spoolers.py
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 |
|
gate_dict_from_list(inst_list)
Transforms a list into an appropiate dictionnary for instructions. The list is assumed to be in the format [name, wires, params].
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inst_list |
list
|
The list that should be transformed. |
required |
Returns:
Type | Description |
---|---|
GateDict
|
A GateDict object. |
Source code in src/sqooler/spoolers.py
684 685 686 687 688 689 690 691 692 693 694 695 696 |
|
get_file_queue(dir_path)
A function that returns the list of files in the directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir_path |
str
|
The path to the directory. |
required |
Returns:
Type | Description |
---|---|
list[str]
|
A list of files in the directory. It excludes directories. |
Raises:
Type | Description |
---|---|
ValueError
|
If the path is not a directory. |
Source code in src/sqooler/spoolers.py
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 |
|