1. Noise¶
graphiq.noise.noise_models ¶
The Noise objects are objects that tell the compiler the noise model of each gate.
A noise can be placed before or after the execution of the gate. It can also alter the behavior of the gate. To allow the flexibility to place the noise, the user needs to specify where to put the noise. Currently, we support placing additional noise before or after a gate as well as replacing a gate.
Currently, we consider only local errors.
REDUCE_STABILIZER_MIXTURE = True module-attribute ¶
Base classes from which any noise model will inherit
AdditionNoiseBase ¶
Bases: NoiseBase
Base class for noise added before the operation
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply the noisy gate to the state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | the state | required |
n_quantum | int | number of qubits | required |
reg_list | list[int] | a list of registers where the noise is applied | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
AmplitudeDampingNoise ¶
Bases: AdditionNoiseBase
Amplitude damping noise described by a depolarizing probability
Source code in graphiq/noise/noise_models.py
__init__(damping_probability) ¶
Construct an amplitude damping noise model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
damping_probability | float | the dampening probability between 0 and 1 | required |
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply the noisy gate to the state representations of state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | the state | required |
n_quantum | int | number of qubits | required |
reg_list | list[int] | a list of registers where the noise is applied | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
CoherentUnitaryError ¶
Bases: AdditionNoiseBase
Coherent unitary error described by a single unitary
TODO: implement this error model¶
Source code in graphiq/noise/noise_models.py
__init__(unitary) ¶
Construct a coherent unitary error described by a single unitary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unitary | numpy.nadrray | str | a unitary that specified the error | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply this noise model to a quantum state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | a quantum state | required |
n_quantum | int | the number of qubits | required |
reg_list | list[int] | a list of register numbers | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
DepolarizingNoise ¶
Bases: AdditionNoiseBase
Depolarizing noise described by a depolarizing probability
Source code in graphiq/noise/noise_models.py
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 | |
__init__(depolarizing_prob) ¶
Construct a depolarizing noise model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depolarizing_prob | float | the depolarizing probability | required |
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply a depolarizing channel to the state, with probability :math:p. The form of the channel (as Kraus operators) is,
:math:\rho \to (1-p) \rho + \frac{p}{4^n - 1} \sum_i P_i \rho P_i
where :math:P_i are the Pauli strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | the state | required |
n_quantum | int | number of qubits | required |
reg_list | list[int] | a list of registers where the noise is applied | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
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 | |
GeneralKrausError ¶
Bases: AdditionNoiseBase
A general error described by Kraus operators
This error may only work for the DensityMatrix backend.
TODO: Implement this noise model by figuring out how to pass parameters¶
Source code in graphiq/noise/noise_models.py
__init__(kraus_ops) ¶
Construct a GeneralKrausError object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kraus_ops | list | a list of Kraus operators | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply the noise model to the state representation state_rep
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | a quantum state | required |
n_quantum | int | the number of qubits | required |
reg_list | list[int] | a list of registers where non-identity gates are applied | required |
Returns:
| Type | Description |
|---|---|
| nothing |
Source code in graphiq/noise/noise_models.py
HadamardPerturbedError ¶
Bases: OneQubitGateReplacement
A noisy version of Hadamard gate is used to replace the original gate. The noise is specified by the perturbation angles that deviate from the original parameters :math:(\pi/2, 0, \pi).
Source code in graphiq/noise/noise_models.py
__init__(theta_pert, phi_pert, lam_pert) ¶
Construct a HadamardPerturbedError object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta_pert | float | the perturbation added to the theta angle | required |
phi_pert | float | the perturbation added to the phi angle | required |
lam_pert | float | the perturbation added to the lambda angle | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
LocalCliffordError ¶
Bases: AdditionNoiseBase
A local Clifford error specified by a list of one-qubit unitary that consists of the local Clifford
Source code in graphiq/noise/noise_models.py
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 | |
__init__(local_clifford) ¶
Construct a one-qubit Clifford gate error
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_clifford | list[str] | a list of elementary gates that compose the local Clifford gate | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply the noise model to a quantum state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | a quantum state | required |
n_quantum | int | the number of qubits | required |
reg_list | list[int] | a list of register numbers | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
MeasurementError ¶
Bases: NoiseBase
a measurement error described by a conditional probability distribution
# TODO: implement this error model
Source code in graphiq/noise/noise_models.py
__init__(prob_dist) ¶
Construct a MeasurementError object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prob_dist | numpy.ndarray | a :math: | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply the noise to the state representation state_rep
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | the quantum state | required |
n_quantum | int | number of qubits | required |
reg_list | list[int] | a list of registers where the noise is applied | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
MixedUnitaryError ¶
Bases: AdditionNoiseBase
Mixed unitary error, described by an ensemble of unitary operations
TODO: implement this error model
Source code in graphiq/noise/noise_models.py
__init__(unitaries_list, prob_list) ¶
Construct a MixedUnitaryError object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unitaries_list | list[numpy.ndarray] | a list of unitary operations | required |
prob_list | list[float] | the corresponding probability distribution for the unitaries | required |
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply the noise to the state representation state_rep
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | the state | required |
n_quantum | int | number of qubits | required |
reg_list | list[int] | a list of registers where the noise is applied | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
NoNoise ¶
Bases: AdditionNoiseBase
No noise, which is the default noise model for all gates.
Source code in graphiq/noise/noise_models.py
__init__() ¶
apply(state, *args) ¶
No action is needed
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | a quantum state | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
NoiseBase ¶
Bases: ABC
Base class from which noise model will inherit
Source code in graphiq/noise/noise_models.py
__init__(noise_parameters=None) ¶
Initialize a base class for noise model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
noise_parameters | dict | a dictionary of parameters to describe the noise model | None |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply the noisy gate to the state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | the state | required |
n_quantum | int | number of qubits | required |
reg_list | list[int] | a list of registers where the noise is applied | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
OneQubitGateReplacement ¶
Bases: ReplacementNoiseBase
A replacement type of noise for one-qubit gates
Source code in graphiq/noise/noise_models.py
__init__(one_qubit_unitary) ¶
This replacement noise replaces the original one-qubit gate by the given one-qubit gate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
one_qubit_unitary | numpy.ndarray | a :math: | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | a quantum state to which the noise is applied | required |
n_quantum | int | the number of quantum registers | required |
reg_list | list[int] | a list of registers involved | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
PauliError ¶
Bases: AdditionNoiseBase
One-qubit Pauli error specified by the name of Pauli
Source code in graphiq/noise/noise_models.py
__init__(pauli_error) ¶
Construct a one-qubit Pauli error
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pauli_error | str | a description of the type of Pauli error | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply the noise to the state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | a quantum state | required |
n_quantum | int | the number of qubits | required |
reg_list | list[int] | a list of register numbers | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
PhasePerturbedError ¶
Bases: OneQubitGateReplacement
A noisy version of Phase gate is used to replace the original gate. The noise is specified by the perturbation angles that deviate from the original parameters :math:(0, 0, \pi/2).
Source code in graphiq/noise/noise_models.py
__init__(theta_pert, phi_pert, lam_pert) ¶
Construct a HadamardPerturbedError object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta_pert | float | the perturbation added to the theta angle | required |
phi_pert | float | the perturbation added to the phi angle | required |
lam_pert | float | the perturbation added to the lambda angle | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
PhotonLoss ¶
Bases: AdditionNoiseBase
Photon loss noise model.
Currently, it supports DensityMatrix/Stabilizer/MixedStabilizer backend.
For the DensityMatrix backend: it uses subnormalized states, i.e., the trace of the state is the probability that no photon is lost.
For the Stabilizer/MixedStabilizer backend: it keeps track of the survival probability (no photon loss) and the tableau corresponding to no photon loss.
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply the photon loss to a quantum state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | a quantum state | required |
n_quantum | int | number of qubits | required |
reg_list | list[int] | a list of registers where the noise is applied | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
ReplacementNoiseBase ¶
Bases: NoiseBase
Base class for noisy gate that replaces the original gate
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply the noisy gate to the state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | the state | required |
n_quantum | int | number of qubits | required |
reg_list | list[int] | a list of registers where the noise is applied | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
ResetError ¶
Bases: NoiseBase
Reset error
TODO: implement this error model¶
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, reg_list) ¶
Apply the noise to the state representation state_rep
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | a quantum state | required |
n_quantum | int | number of qubits | required |
reg_list | list[int] | a list of registers where the noise is applied | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
SigmaXPerturbedError ¶
Bases: OneQubitGateReplacement
A noisy version of :math:\sigma_X gate is used to replace the original gate. The noise is specified by the perturbation angles that deviate from the original parameters :math:(\pi, 0, \pi).
Source code in graphiq/noise/noise_models.py
__init__(theta_pert, phi_pert, lam_pert) ¶
Construct a HadamardPerturbedError object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta_pert | float | the perturbation added to the theta angle | required |
phi_pert | float | the perturbation added to the phi angle | required |
lam_pert | float | the perturbation added to the lambda angle | required |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
TwoQubitControlledGateReplacement ¶
Bases: ReplacementNoiseBase
A replacement type of gate for two-qubit controlled unitary gate, where noises can be added to the control qubit before the gate and after the gate, and the gate applied on the target qubit can be a generic one-qubit gate.
Source code in graphiq/noise/noise_models.py
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 | |
__init__(target_unitary, pre_gate_ctr_noise=np.eye(2), post_gate_ctr_noise=np.eye(2), phase_factor=0) ¶
Construct a TwoQubitControlledGateReplacement noise model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_unitary | numpy.ndarray | the target gate to be applied to the target qubit if the control qubit is in :math: | required |
pre_gate_ctr_noise | numpy.ndarray | the noise (unitary) added to the control qubit before the gate | eye(2) |
post_gate_ctr_noise | numpy.ndarray | the noise (unitary) added to the control qubit after the gate | eye(2) |
phase_factor | float | a phase factor in the range :math: | 0 |
Returns:
| Type | Description |
|---|---|
None | nothing |
Source code in graphiq/noise/noise_models.py
apply(state, n_quantum, ctr_reg, target_reg) ¶
Apply this noise model to a quantum state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state | QuantumState | a quantum state | required |
n_quantum | int | the number of qubits | required |
ctr_reg | int | the control register | required |
target_reg | int | the target register | required |
Returns:
| Type | Description |
|---|---|
None | nothing |