v2 API
Constant
src.inspeqtor.v2.constant
Control
src.inspeqtor.v2.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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
ravel_unravel_fn_old
ravel_unravel_fn_old(control_sequence: ControlSequence)
This function return the ravel and unravel functions for the provided control sequence
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control_sequence
|
ControlSequence
|
The control sequence |
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
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 | |
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 | |
get_envelope_transformer
get_envelope_transformer(control_sequence: ControlSequence)
Generate get_envelope function with control parameter array as an input instead of list form
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control_sequence
|
ControlSequence
|
Control seqence instance |
required |
Returns:
| Type | Description |
|---|---|
|
typing.Callable[[jnp.ndarray], typing.Any]: Transformed get envelope function |
Source code in src/inspeqtor/v2/control.py
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
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 | |
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 | |
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 | |
Data
src.inspeqtor.v2.data
ExpectationValue
dataclass
Class representing a single experimental setting of state initialization and observable measurement.
Supports both single-qubit and multi-qubit configurations using string representation: - Observable: "XYZ" (instead of ["X", "Y", "Z"]) - Initial state: "+0r" (instead of ["+", "0", "r"])
Source code in src/inspeqtor/v2/data.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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 | |
ExperimentConfiguration
dataclass
Experiment configuration dataclass
Source code in src/inspeqtor/v2/data.py
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 | |
ExperimentalData
dataclass
Dataclass for processing of the characterization dataset. A difference between preprocess and postprocess dataset is that postprocess group expectation values same control parameter id within single row instead of multiple rows.
Source code in src/inspeqtor/v2/data.py
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 | |
tensor_product
tensor_product(*operators) -> ndarray
Create tensor product of multiple operators
Source code in src/inspeqtor/v2/data.py
70 71 72 73 74 75 76 | |
get_observable_operator
get_observable_operator(observable: str) -> ndarray
Get the full observable operator as a tensor product
Source code in src/inspeqtor/v2/data.py
109 110 111 112 113 114 | |
get_initial_state
get_initial_state(
initial_state: str, dm: bool = True
) -> ndarray
Get the initial state as state vector or density matrix
Source code in src/inspeqtor/v2/data.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
get_complete_expectation_values
get_complete_expectation_values(
num_qubits: int,
observables: Iterable[Literal["I", "X", "Y", "Z"]] = [
"I",
"X",
"Y",
"Z",
],
states: Iterable[
Literal["+", "-", "r", "l", "0", "1"]
] = ["+", "-", "r", "l", "0", "1"],
exclude_all_identities: bool = True,
) -> list[ExpectationValue]
Generate a complete set of expectation values for characterizing a multi-qubit system
Source code in src/inspeqtor/v2/data.py
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 | |
check_parity
check_parity(n)
Determines the parity of a number using bitwise_count.
Efficiently computes parity by counting all 1 bits and taking modulo 2. This is much faster than the iterative approach as it uses hardware intrinsics for population count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
The input integer. |
required |
Returns:
| Type | Description |
|---|---|
|
0 if the number has even parity, 1 if it has odd parity. |
Example
check_parity(7) # 0b111 -> three 1s -> odd parity 1 check_parity(6) # 0b110 -> two 1s -> even parity 0
Source code in src/inspeqtor/v2/data.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
Optimize
src.inspeqtor.v2.optimize
BayesOptState
The dataclass holding optimization state for the gaussian process.
Source code in src/inspeqtor/v2/optimize.py
91 92 93 94 95 96 | |
fit_gaussian_process
fit_gaussian_process(D: Dataset)
Fit the Gaussian process given an instance of Dataset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
D
|
Dataset
|
The |
required |
Returns:
| Type | Description |
|---|---|
|
tuple[]: description |
Source code in src/inspeqtor/v2/optimize.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
predict_mean_and_std
predict_mean_and_std(
x: ndarray, D: Dataset
) -> tuple[ndarray, ndarray]
Predict a Gaussian distribution to the given x using the dataset D
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
The array of points to evaluate the gaussian process. |
required |
D
|
Dataset
|
The dataset contain observation from the real process. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[jnp.ndarray, jnp.ndarray]: The array of mean and standard deviation of the Gaussian process at ponits |
Source code in src/inspeqtor/v2/optimize.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
expected_improvement
expected_improvement(
y_best: ndarray,
posterior_mean: ndarray,
posterior_var: ndarray,
exploration_factor: float,
) -> ndarray
The expected improvement calculated using posterior mean and variance of the gaussian process. The exploration factor can be adjust to balance between exploration and exploitation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_best
|
ndarray
|
The current maximum value of y |
required |
posterior_mean
|
ndarray
|
The posterior mean of the gaussian process |
required |
posterior_var
|
ndarray
|
The posterior variance of the gaussian process |
required |
exploration_factor
|
float
|
The factor that balance between exploration and exploitation. Set to 0. to maximize exploitation. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
jnp.ndarray: The expeced improvement corresponding to the points given from array of the posterior. |
Source code in src/inspeqtor/v2/optimize.py
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 | |
init_opt_state
init_opt_state(x, y, control) -> BayesOptState
Function to intialize the optimizer
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
The input arguments |
required |
y
|
ndarray
|
The observation corresponding to the input |
required |
control
|
_type_
|
The intance of control sequence. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BayesOptState |
BayesOptState
|
The state of optimizer. |
Source code in src/inspeqtor/v2/optimize.py
99 100 101 102 103 104 105 106 107 108 109 110 | |
suggest_next_candidates
suggest_next_candidates(
key: ndarray,
opt_state: BayesOptState,
sample_size: int = 1000,
num_suggest: int = 1,
exploration_factor: float = 0.0,
) -> ndarray
Sample new candidates for experiment using expected improvement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
ndarray
|
The jax random key |
required |
opt_state
|
BayesOptState
|
The current optimizer state |
required |
sample_size
|
int
|
The internal number of sample size. Defaults to 1000. |
1000
|
num_suggest
|
int
|
The number of suggestion for next experiment. Defaults to 1. |
1
|
exploration_factor
|
float
|
The factor that balance between exploration and exploitation. Set to 0. to maximize exploitation. Defaults to 0.0. |
0.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
jnp.ndarray: The suggest data points to evalute in the experiment. |
Source code in src/inspeqtor/v2/optimize.py
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 | |
add_observations
add_observations(
opt_state: BayesOptState, x, y
) -> BayesOptState
Function to update the optimization state using new data points x and y
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
opt_state
|
BayesOptState
|
The current optimization state |
required |
x
|
ndarray
|
The input arguments |
required |
y
|
ndarray
|
The observation corresponding to the input |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BayesOptState |
BayesOptState
|
The updated optimization state. |
Source code in src/inspeqtor/v2/optimize.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
Predefined
src.inspeqtor.v2.predefined
HamiltonianSpec
dataclass
Source code in src/inspeqtor/v2/predefined.py
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 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 | |
get_solver
get_solver(
control_sequence: ControlSequence,
qubit_info: QubitInformation,
dt: float,
)
Return Unitary solver from the given specification of the Hamiltonian and solver
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control_sequence
|
ControlSequence
|
The control sequence object |
required |
qubit_info
|
QubitInformation
|
The qubit information object |
required |
dt
|
float
|
The time step size of the device |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
Unsupport Solver method |
Returns:
| Type | Description |
|---|---|
|
typing.Any: The unitary solver |
Source code in src/inspeqtor/v2/predefined.py
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 | |
get_gaussian_control_sequence
get_gaussian_control_sequence(
qubit_info: QubitInformation, max_amp: float = 0.5
)
Get predefined Gaussian control sequence with single Gaussian 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
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 | |
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 | |
load_data_from_path
load_data_from_path(
path: str | Path,
hamiltonian_spec: HamiltonianSpec,
control_reader=default_control_reader,
) -> LoadedData
Load and prepare the experimental data from given path and hamiltonian spec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The path to the folder that contain experimental data. |
required |
hamiltonian_spec
|
HamiltonianSpec
|
The specification of the Hamiltonian |
required |
control_reader
|
Any
|
description. Defaults to default_control_reader. |
default_control_reader
|
Returns:
| Name | Type | Description |
|---|---|---|
LoadedData |
LoadedData
|
The object contatin necessary information for device characterization. |
Source code in src/inspeqtor/v2/predefined.py
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 | |
save_data_to_path
save_data_to_path(
path: str | Path,
experiment_data: ExperimentalData,
control_sequence: ControlSequence,
)
Save the experimental data to the path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The path to folder to save the experimental data |
required |
experiment_data
|
ExperimentData
|
The experimental data object |
required |
control_sequence
|
ControlSequence
|
The control sequence that used to create the experimental data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
|
Source code in src/inspeqtor/v2/predefined.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | |
generate_single_qubit_experimental_data
generate_single_qubit_experimental_data(
key: ndarray,
hamiltonian: Callable[..., ndarray],
sample_size: int = 10,
shots: int = 1000,
strategy: SimulationStrategy = SHOT,
qubit_inforamtion: QubitInformation = get_mock_qubit_information(),
control_sequence: ControlSequence = get_drag_pulse_v2_sequence(
drive_strength
),
max_steps: int = int(2**16),
method: WhiteboxStrategy = ODE,
trotter_steps: int = 1000,
expectation_value_receipt: list[
ExpectationValue
] = get_complete_expectation_values(1),
) -> tuple[
ExperimentalData,
ControlSequence,
ndarray,
Callable[[ndarray], ndarray],
]
Generate simulated dataset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
ndarray
|
Random key |
required |
hamiltonian
|
Callable[..., ndarray]
|
Total Hamiltonian of the device |
required |
sample_size
|
int
|
Sample size of the control parameters. Defaults to 10. |
10
|
shots
|
int
|
Number of shots used to estimate expectation value, will be used if |
1000
|
strategy
|
SimulationStrategy
|
Simulation strategy. Defaults to SimulationStrategy.RANDOM. |
SHOT
|
get_qubit_information_fn
|
Callable[[], QubitInformation]
|
Function that return qubit information. Defaults to get_mock_qubit_information. |
required |
get_control_sequence_fn
|
Callable[[], ControlSequence]
|
Function that return control sequence. Defaults to get_multi_drag_control_sequence_v3. |
required |
max_steps
|
int
|
Maximum step of solver. Defaults to int(2**16). |
int(2 ** 16)
|
method
|
WhiteboxStrategy
|
Unitary solver method. Defaults to WhiteboxStrategy.ODE. |
ODE
|
trotter_steps
|
int
|
Trotterization step. Defualts to 1000 |
1000
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Not support strategy |
Returns:
| Type | Description |
|---|---|
tuple[ExperimentalData, ControlSequence, ndarray, Callable[[ndarray], ndarray]]
|
tuple[ExperimentData, ControlSequence, jnp.ndarray, typing.Callable[[jnp.ndarray], jnp.ndarray]]: tuple of (1) Experiment data, (2) Pulse sequence, (3) Noisy unitary, (4) Noisy solver |
Source code in src/inspeqtor/v2/predefined.py
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 | |
Utilities
src.inspeqtor.v2.utils
LoadedData
dataclass
A utility dataclass holding objects necessary for device characterization.
Source code in src/inspeqtor/v2/utils.py
23 24 25 26 27 28 29 30 31 32 33 34 | |
SyntheticDataModel
dataclass
A utility dataclass holding objects necessary for simulating single qubit quantum device.
Source code in src/inspeqtor/v2/utils.py
37 38 39 40 41 42 43 44 45 46 47 48 | |
prepare_data
prepare_data(
exp_data: ExperimentalData,
control_sequence: ControlSequence,
whitebox: Callable,
) -> LoadedData
Prepare the data for easy accessing from experiment data, control sequence, and Whitebox.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exp_data
|
ExperimentData
|
|
required |
control_sequence
|
ControlSequence
|
Control sequence of the experiment |
required |
whitebox
|
Callable
|
Ideal unitary solver. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
LoadedData |
LoadedData
|
|
Source code in src/inspeqtor/v2/utils.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 | |
single_qubit_shot_quantum_device
single_qubit_shot_quantum_device(
key: ndarray,
control_parameters: ndarray,
solver: Callable[[ndarray], ndarray],
SHOTS: int,
expectation_value_receipt: Sequence[
ExpectationValue
] = get_complete_expectation_values(1),
) -> ndarray
This is the shot estimate expectation value quantum device
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control_parameters
|
ndarray
|
The control parameter to be feed to simlulator |
required |
key
|
ndarray
|
Random key |
required |
solver
|
Callable[[ndarray], ndarray]
|
The ODE solver for propagator |
required |
SHOTS
|
int
|
The number of shots used to estimate expectation values |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
jnp.ndarray: The expectation value of shape (control_parameters.shape[0], 18) |
Source code in src/inspeqtor/v2/utils.py
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 | |
dictorization
dictorization(
expvals: ndarray, order: list[ExpectationValue]
)
This function formats expectation values of shape (18, N) to a dictionary with the initial state as outer key and the observable as inner key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expvals
|
ndarray
|
Expectation values of shape (18, N). Assumes that order is as in default_expectation_values_order. |
required |
Returns:
| Type | Description |
|---|---|
|
dict[str, dict[str, jnp.ndarray]]: A dictionary with the initial state as outer key and the observable as inner key. |
Source code in src/inspeqtor/v2/utils.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
tensor_product
tensor_product(*operators) -> ndarray
Create tensor product of multiple operators
Source code in src/inspeqtor/v2/utils.py
184 185 186 | |
get_measurement_probability
get_measurement_probability(
state: ndarray, operator: str
) -> ndarray
Calculate the probability of measuring each projector of tensor product of Pauli operators
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ndarray
|
The quantum state to measure |
required |
operator
|
str
|
The string representation of the measurement operator, e.g., 'XY' |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
jnp.ndarray: An array of probability where each index is a base 10 representation of base 2 measurement result. |
Source code in src/inspeqtor/v2/utils.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |