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(NOISE_MODEL, list[float], 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).

NOTE

Positional-only constructor

The three-parameter constructor is positional-only -- keyword arguments are not accepted. Arguments must be passed in order without using parameter names:

python
# Correct: positional arguments only
QCloudNoiseModel(NOISE_MODEL.DEPOLARIZING_KRAUS_OPERATOR, [0.001], [0.01])

# Incorrect -- raises TypeError:
QCloudNoiseModel(model=NOISE_MODEL.DEPOLARIZING_KRAUS_OPERATOR, single_p=[0.001], double_p=[0.01])

Parameter Guidelines ​

The recommended parameter sizes for each noise model type:

Modelsingle_p sizedouble_p size
DECOHERENCE_KRAUS_OPERATOR33
All other models11

For DECOHERENCE_KRAUS_OPERATOR, the three parameters typically represent T1 relaxation time, T2 dephasing time, and gate time. Client-side validation is not enforced at construction time; the server may reject invalid configurations.

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 non-empty single-qubit and double-qubit parameter lists).

Returns: True if both the single-qubit and double-qubit parameter lists are non-empty, 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, QCloudService
from pyqpanda3.core import QProg, QCircuit, H, CNOT, measure

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

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

# Use the noise model with a backend
# Note: QCloudNoiseModel is currently supported only on the full_amplitude
# simulator backend. Real-chip backends (e.g., WK_C180_2) do not accept
# the noise_model parameter in backend.run().
service = QCloudService(api_key="your_api_key")
backend = service.backend("full_amplitude")

prog = QProg()
circ = QCircuit(2)
circ << H(0) << CNOT(0, 1)
prog << circ << measure([0, 1], [0, 1])

job = backend.run(prog, shots=1000, model=noise)
result = job.result()
print(result.get_probs())

# Modify noise parameters
noise.set_single_params([0.002])
noise.set_double_params([0.02])
noise.print()
# Output:
# Noise Model: DEPOLARIZING_KRAUS_OPERATOR
# Single Qubit Noise Parameters: 0.002
# Double Qubit Noise Parameters: 0.02

See Also ​

Released under the MIT License.