Control
inspeqtor.control
inspeqtor.control.BaseControl
dataclass
Source code in src/inspeqtor/v2/control.py
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 | |
to_dict
to_dict() -> dict[str, Union[int, float, str]]
Convert the control configuration to dictionary
Returns:
| Type | Description |
|---|---|
dict[str, Union[int, float, str]]
|
dict[str, typing.Union[int, float, str]]: Configuration of the control |
Source code in src/inspeqtor/v2/control.py
91 92 93 94 95 96 97 | |
to_dict_new
to_dict_new() -> dict[str, Union[int, float, str]]
Convert the control configuration to dictionary
Returns:
| Type | Description |
|---|---|
dict[str, Union[int, float, str]]
|
dict[str, typing.Union[int, float, str]]: Configuration of the control |
Source code in src/inspeqtor/v2/control.py
99 100 101 102 103 104 105 | |
from_dict
classmethod
from_dict(data)
Construct the control instace from the dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
Dictionary for construction of the control instance. |
required |
Returns:
| Type | Description |
|---|---|
|
The instance of the control. |
Source code in src/inspeqtor/v2/control.py
107 108 109 110 111 112 113 114 115 116 117 | |
inspeqtor.control.ControlSequence
dataclass
Control sequence, expect to be sum of atomic control.
Source code in src/inspeqtor/v2/control.py
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 | |
sample_params_v1
sample_params_v1(
key: ndarray,
) -> dict[str, ParametersDictType]
Sample control parameter
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
ndarray
|
Random key |
required |
Returns:
| Type | Description |
|---|---|
dict[str, ParametersDictType]
|
dict[str, ParametersDictType]: control parameters |
Source code in src/inspeqtor/v2/control.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
sample_params_v2
sample_params_v2(
key: ndarray,
) -> dict[str, ParametersDictType]
Sample control parameter
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
ndarray
|
Random key |
required |
Returns:
| Type | Description |
|---|---|
dict[str, ParametersDictType]
|
dict[str, ParametersDictType]: control parameters |
Source code in src/inspeqtor/v2/control.py
168 169 170 171 172 173 174 175 176 177 | |
get_bounds
get_bounds() -> tuple[
dict[str, ParametersDictType],
dict[str, ParametersDictType],
]
Get the bounds of the controls
Returns:
| Type | Description |
|---|---|
tuple[dict[str, ParametersDictType], dict[str, ParametersDictType]]
|
tuple[list[ParametersDictType], list[ParametersDictType]]: tuple of list of lower and upper bounds. |
Source code in src/inspeqtor/v2/control.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
get_envelope
get_envelope(
params_dict: dict[str, ParametersDictType],
) -> Callable
Create envelope function with given control parameters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params_list
|
dict[str, ParametersDictType]
|
control parameter to be used |
required |
Returns:
| Type | Description |
|---|---|
Callable
|
typing.Callable: Envelope function |
Source code in src/inspeqtor/v2/control.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
to_dict_new
to_dict_new() -> dict[str, str | dict[str, str | float]]
Convert self to dict
Returns:
| Type | Description |
|---|---|
dict[str, str | dict[str, str | float]]
|
dict[str, str | dict[str, str | float]]: dict contain argument necessary for re-initialization. |
Source code in src/inspeqtor/v2/control.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
to_dict
to_dict() -> dict[str, str | dict[str, str | float]]
Convert self to dict
Returns:
| Type | Description |
|---|---|
dict[str, str | dict[str, str | float]]
|
dict[str, str | dict[str, str | float]]: dict contain argument necessary for re-initialization. |
Source code in src/inspeqtor/v2/control.py
238 239 240 241 242 243 244 245 246 247 | |
from_dict
classmethod
from_dict(
data: dict[str, str | dict[str, str | float]],
controls: dict[str, type[BaseControl]],
) -> ControlSequence
Construct self with the provided dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, str | dict[str, str | float]]
|
The dictionary contain initialization arguments |
required |
controls
|
dict[str, type[BaseControl]]
|
The map of control name and class of the control |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ControlSequence |
ControlSequence
|
the instance of control sequence |
Source code in src/inspeqtor/v2/control.py
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 | |
to_file
to_file(path: Union[str, Path])
Save configuration of the pulse to file given folder path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
Path to the folder to save sequence, will be created if not existed. |
required |
Source code in src/inspeqtor/v2/control.py
324 325 326 327 328 329 330 331 332 333 | |
from_file
classmethod
from_file(
path: Union[str, Path],
controls: dict[str, type[BaseControl]],
)
Initialize itself from a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
Path to file. |
required |
controls
|
dict[str, type[BaseControl]]
|
The map of control name and class of the control |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ControlSequence |
the instance of control sequence |
Source code in src/inspeqtor/v2/control.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
inspeqtor.control.control_waveform
control_waveform(
param: ParametersDictType,
t_eval: ndarray,
control: BaseControl,
) -> ndarray
Source code in src/inspeqtor/v2/control.py
360 361 362 363 364 365 | |
inspeqtor.control.sequence_waveform
sequence_waveform(
params: dict[str, ParametersDictType],
t_eval: ndarray,
control_seqeunce: ControlSequence,
) -> ndarray
Samples the pulse sequence by generating random parameters for each pulse and computing the total waveform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Key
|
The random key used for generating the parameters. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
tuple[list[ParametersDictType], Complex[Array, "time"]]: A tuple containing a list of parameter dictionaries for each pulse and the total waveform. |
Example
key = jax.random.PRNGKey(0) params, total_waveform = sample(key)
Source code in src/inspeqtor/v2/control.py
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 | |
inspeqtor.control.ravel_unravel_fn
ravel_unravel_fn(structure: Iterable[Iterable[str]])
This function return the ravel and unravel functions for the provided control sequence
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure
|
Iterable[Iterable[str]]
|
The structure of the pytree |
required |
Returns:
| Type | Description |
|---|---|
|
tuple[typing.Callable, typing.Callable]: The first element is the function that convert structured parameter to array, the second is a function that reverse the action of the first. |
Source code in src/inspeqtor/v2/control.py
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |
inspeqtor.control.sample_params
sample_params(
key: ndarray,
lower: ParametersDictType,
upper: ParametersDictType,
) -> ParametersDictType
Sample parameters with the same shape with given lower and upper bounds
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
ndarray
|
Random key |
required |
lower
|
ParametersDictType
|
Lower bound |
required |
upper
|
ParametersDictType
|
Upper bound |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ParametersDictType |
ParametersDictType
|
Dict of the sampled parameters |
Source code in src/inspeqtor/v2/control.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
inspeqtor.control.construct_control_sequence_reader
construct_control_sequence_reader(
controls: list[type[BaseControl]] = [],
) -> Callable[[Union[str, Path]], ControlSequence]
Construct the control sequence reader
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controls
|
list[type[BasePulse]]
|
List of control constructor. Defaults to []. |
[]
|
Returns:
| Type | Description |
|---|---|
Callable[[Union[str, Path]], ControlSequence]
|
typing.Callable[[typing.Union[str, pathlib.Path]], controlsequence]: Control sequence reader that will automatically contruct control sequence from path. |
Source code in src/inspeqtor/v2/control.py
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 | |
inspeqtor.control.ravel_transform
ravel_transform(
fn: Callable,
control_sequence: ControlSequence,
at: int = 0,
) -> Callable
Transform the argument at index at of the function fn with unravel_fn of the control sequence
Note
signal_fn = sq.control.ravel_transform(
sq.physics.signal_func_v5(control_sequence.get_envelope, qubit_info.frequency, dt),
control_sequence,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable
|
The function to be transformed |
required |
control_sequence
|
ControlSequence
|
The control sequence that will use to produce |
required |
Returns:
| Type | Description |
|---|---|
Callable
|
typing.Callable: A function that its first argument is transformed by |
Source code in src/inspeqtor/v2/control.py
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 | |
inspeqtor.control.ParametersDictType
module-attribute
ParametersDictType = PyTree[Union[Float, ndarray]]
inspeqtor.control.nested_sample
nested_sample(
key: ndarray, bounds, sample_fn=uniform_sample
)
Sample from nested bounds with custom sampling function sample_fn
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
ndarray
|
Random key |
required |
bounds
|
_type_
|
Bound of the control parameter |
required |
sample_fn
|
_type_
|
Custom sampling function. Defaults to uniform_sample. |
uniform_sample
|
Returns:
| Name | Type | Description |
|---|---|---|
_type_ |
Control parameter sample from bound |
Source code in src/inspeqtor/v2/control.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
inspeqtor.control.check_bounds
check_bounds(
param: ParametersDictType, bounds: Bounds
) -> bool
Check if the given control parameter violate the bound or not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
_type_
|
Control parameter |
required |
bounds
|
_type_
|
Bound of control parameter |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Source code in src/inspeqtor/v2/control.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 | |
inspeqtor.control.merge_lower_upper
merge_lower_upper(lower: LowerBound, upper: UpperBound)
Merge lower and upper bound into bounds
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lower
|
_type_
|
The lower bound |
required |
upper
|
_type_
|
The upper bound |
required |
Returns:
| Name | Type | Description |
|---|---|---|
_type_ |
Bound from the lower and upper. |
Source code in src/inspeqtor/v2/control.py
398 399 400 401 402 403 404 405 406 407 408 | |
inspeqtor.control.split_bounds
split_bounds(
bounds: Bounds,
) -> tuple[LowerBound, UpperBound]
Create lower and upper bound from bounds
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
_type_
|
The bounds to extract the lower and upper bound |
required |
Returns:
| Name | Type | Description |
|---|---|---|
_type_ |
tuple[LowerBound, UpperBound]
|
The lower and upper bound |
Source code in src/inspeqtor/v2/control.py
411 412 413 414 415 416 417 418 419 420 421 422 | |
inspeqtor.control.get_envelope
get_envelope(
param: ParametersDictType, seq: ControlSequence
)
Return an envelope function create from envelope of all controls in seq with control parameter param
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
_type_
|
Control parameter |
required |
seq
|
ControlSequence
|
Control Sequence |
required |
Returns:
| Name | Type | Description |
|---|---|---|
_type_ |
A function of time which is a sum of all envelope of control in |
Source code in src/inspeqtor/v2/control.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | |
inspeqtor.control.envelope_fn
envelope_fn(
param: ParametersDictType,
t: ndarray,
seq: ControlSequence,
)
Return an envelope of all of the control in control sequence seq given paramter param at time t
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
_type_
|
Control parameter |
required |
t
|
ndarray
|
Time to evaluate the envelope |
required |
seq
|
ControlSequence
|
The control sequence to get the envelope |
required |
Returns:
| Name | Type | Description |
|---|---|---|
_type_ |
Envelope of all control in |
Source code in src/inspeqtor/v2/control.py
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | |
Library
inspeqtor.control.library
inspeqtor.control.library.DragPulse
dataclass
Source code in src/inspeqtor/v1/predefined.py
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 | |
inspeqtor.control.library.DragPulseV2
dataclass
Source code in src/inspeqtor/v2/predefined.py
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 | |
inspeqtor.control.library.MultiDragPulseV3
dataclass
Source code in src/inspeqtor/v1/predefined.py
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 | |
inspeqtor.control.library.GaussianPulse
dataclass
Source code in src/inspeqtor/v2/predefined.py
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 | |
inspeqtor.control.library.TwoAxisGaussianPulse
dataclass
Source code in src/inspeqtor/v1/predefined.py
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 | |
inspeqtor.control.library.gaussian_envelope
gaussian_envelope(amp, center, sigma)
Source code in src/inspeqtor/v1/predefined.py
100 101 102 103 104 105 106 | |
inspeqtor.control.library.polynomial_feature_map
polynomial_feature_map(x: ndarray, degree: int)
Source code in src/inspeqtor/v1/predefined.py
812 813 | |
inspeqtor.control.library.predefined_controls
module-attribute
predefined_controls = [
DragPulse,
MultiDragPulseV3,
GaussianPulse,
DragPulseV2,
TwoAxisGaussianPulse,
]
inspeqtor.control.library.default_control_reader
module-attribute
default_control_reader = construct_control_sequence_reader(
controls=predefined_controls
)
inspeqtor.control.library.get_drag_pulse_v2_sequence
get_drag_pulse_v2_sequence(
qubit_info_drive_strength: float,
max_amp: float = 0.5,
min_theta=0.0,
max_theta=2 * pi,
min_beta=-2.0,
max_beta=2.0,
dt=2 / 9,
)
Get predefined DRAG control sequence with single DRAG pulse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qubit_info
|
QubitInformation
|
Qubit information |
required |
max_amp
|
float
|
The maximum amplitude. Defaults to 0.5. |
0.5
|
Returns:
| Name | Type | Description |
|---|---|---|
ControlSequence |
Control sequence instance |
Source code in src/inspeqtor/v2/predefined.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 | |
inspeqtor.control.library.drag_feature_map
drag_feature_map(
x: ndarray,
degree: int = 4,
correction: tuple[float, ...] = (2 * pi, 10),
) -> ndarray
Source code in src/inspeqtor/v2/predefined.py
643 644 645 646 647 648 649 650 651 | |