> ## Documentation Index
> Fetch the complete documentation index at: https://docs.classiq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Initialize the Logical Noise Model

The engine needs to know how noisy the underlying hardware is. A **logical noise model**
holds the simulated logical error rates of the fundamental operations (Clifford gates and
T gate) as a function of code distance. You can either use a ready-made public model or generate
your own from a physical noise description.

## Use a public logical noise model

Classiq hosts public logical noise models that any user can reference **by name**, with no
simulation to run yourself. This is the fastest way to get started — retrieve one with
`get_logical_noise`:

[comment]: DO_NOT_TEST

```python theme={null}
from classiq.error_correction.logical_noise import get_logical_noise

logical_noise = get_logical_noise("public/depolarize_1e-3")
```

`public/depolarize_1e-3` is the public noise model currently in the list — a general-purpose
depolarizing model, generated from the physical noise model below with `p = 1e-3`. More
public models can be added by request, and will be introduced over time.

[comment]: DO_NOT_TEST

```python theme={null}
from classiq.error_correction import (
    DepolarizeRule,
    PauliRule,
    PhysicalNoiseModel,
)


def custom_noise_model(p: float) -> PhysicalNoiseModel:
    return PhysicalNoiseModel(
        idle=[DepolarizeRule(p=p / 10)],
        long_idle=[DepolarizeRule(p=2 * p)],
        clifford_1q=[DepolarizeRule(p=p / 10)],
        clifford_2q=[DepolarizeRule(p=p)],
        measure={"Z": p * 5, "X": p * 5},
        gates={
            "R": [PauliRule(pauli="X", p=p * 2)],
            "RX": [PauliRule(pauli="Z", p=p * 2)],
        },
    )
```

## Create your own logical noise model

To model different hardware, describe it with a `PhysicalNoiseModel` — composed of
per-operation rules such as `DepolarizeRule` and `PauliRule` — then call
`initialize_logical_noise` to simulate the resulting logical error rates and store them
under a name you choose.

<Note>
  `initialize_logical_noise` runs a logical-noise simulation on the backend and is a
  long-running operation. You only need to run it once per noise model — afterwards, retrieve
  the stored result with `get_logical_noise`.
</Note>

[comment]: DO_NOT_TEST

```python theme={null}
from classiq.error_correction.logical_noise import (
    get_logical_noise,
    initialize_logical_noise,
)

noise_model = custom_noise_model(1e-3)

initialize_logical_noise("my_device", noise_model)
logical_noise = get_logical_noise("my_device")
```

Once retrieved, you can inspect and plot the fitted logical error rates — for example, the
1-qubit Clifford curves as a function of code distance:

[comment]: DO_NOT_TEST

```python theme={null}
logical_noise.plot_clifford()
```

<Frame caption="Logical X and Z error of a 1-qubit Clifford, exponentially suppressed as the code distance grows.">
  <img src="https://mintcdn.com/classiq/HJmfqtcTcF5fjww4/user-guide/error-correction/resources/clifford-logical-error.png?fit=max&auto=format&n=HJmfqtcTcF5fjww4&q=85&s=243d9d3b3eb69f01fd105ed5d77b5e19" alt="Logical errors of a 1-qubit Clifford by code distance" width="1732" height="1728" data-path="user-guide/error-correction/resources/clifford-logical-error.png" />
</Frame>

Each curve is a log-linear fit `10 ** (a * cd + b)`; the legend reports the suppression
factor `Λ` (the improvement per two units of code distance). `LogicalNoise` also provides
`plot_cnot()` and `plot_s()`, and `get_clifford_logical_error`, `get_cnot_logical_error`
and `get_s_logical_error` to read a single rate at a given code distance.

## Remove a logical noise model

When you no longer need a model you created, delete it with `remove_logical_noise`. Public
models (such as `public/depolarize_1e-3`) are shared and cannot be removed this way.

[comment]: DO_NOT_TEST

```python theme={null}
from classiq.error_correction.logical_noise import remove_logical_noise

remove_logical_noise("my_device")
```

Next, [route a program](/user-guide/error-correction/routing) onto the lattice.
