Skip to content

QCloudNoiseModel

QCloudNoiseModel represents a noise model for cloud-based quantum simulations. It encapsulates the noise type and its associated parameters for single-qubit and two-qubit gates.

Signature

python
QCloudNoiseModel()
QCloudNoiseModel(model: NOISE_MODEL, single_p: list[float], double_p: list[float])

Parameters

ParameterTypeDefaultDescription
modelNOISE_MODELrequiredThe noise model type
single_plist[float]requiredSingle-qubit gate noise parameters
double_plist[float]requiredTwo-qubit gate noise parameters

The default constructor creates a disabled noise model (no noise applied).

Methods

get_noise_model

python
get_noise_model() -> str

Returns the noise model type as a string.

Returns: The noise model name string.

get_single_params

python
get_single_params() -> list[float]

Returns the single-qubit gate noise parameters.

Returns: A list of floating-point noise parameters for single-qubit gates.

set_single_params

python
set_single_params(single: list[float]) -> None

Sets the single-qubit gate noise parameters.

ParameterTypeDescription
singlelist[float]The single-qubit noise parameters

get_double_params

python
get_double_params() -> list[float]

Returns the two-qubit gate noise parameters.

Returns: A list of floating-point noise parameters for two-qubit gates.

set_double_params

python
set_double_params(double_p: list[float]) -> None

Sets the two-qubit gate noise parameters.

ParameterTypeDescription
double_plist[float]The two-qubit noise parameters

is_enabled

python
is_enabled() -> bool

Checks whether the noise model is enabled (i.e., has been configured with a noise type and parameters).

Returns: True if the noise model is enabled, False otherwise.

print

python
print() -> None

Prints the noise model type and its parameters to standard output.

Operators

OperatorDescription
==Compares two QCloudNoiseModel objects for equality
!=Compares two QCloudNoiseModel objects for inequality

Examples

python
from pyqpanda3.qcloud import QCloudNoiseModel, NOISE_MODEL

# Create a default (disabled) noise model
no_noise = QCloudNoiseModel()
print("Enabled:", no_noise.is_enabled())  # False

# Create a depolarizing noise model
noise = QCloudNoiseModel(
    model=NOISE_MODEL.DEPOLARIZING_KRAUS_OPERATOR,
    single_p=[0.001],       # Single-qubit depolarizing probability
    double_p=[0.01]         # Two-qubit depolarizing probability
)
print("Enabled:", noise.is_enabled())  # True
print("Model:", noise.get_noise_model())

# Use the noise model with a backend
job = backend.run(prog, shots=1000, model=noise)

# Modify noise parameters
noise.set_single_params([0.002])
noise.set_double_params([0.02])
noise.print()

See Also

Released under the MIT License.