Noise-Aware Preprocessing¶
quprep.preprocess.noise_aware.NoiseProfile(qubit_error_rates, coupling_map, t1=None, t2=None, cx_error_rates=None)
dataclass
¶
Noise characteristics of a quantum backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qubit_error_rates
|
list of float
|
Per-qubit single-qubit gate or readout error rate (lower = better). Length must equal the number of physical qubits on the device. |
required |
coupling_map
|
list of (int, int)
|
Available two-qubit connections. Each pair |
required |
t1
|
list of float
|
T1 relaxation times in microseconds, one per qubit. Longer is better. |
None
|
t2
|
list of float
|
T2 dephasing times in microseconds, one per qubit. Longer is better. |
None
|
cx_error_rates
|
dict mapping (int, int) → float
|
Per-pair two-qubit (CX/CNOT) gate error rates. Stored for
informational purposes; the qubit-assignment algorithm uses
|
None
|
Examples:
>>> profile = NoiseProfile(
... qubit_error_rates=[0.001, 0.002, 0.003, 0.001, 0.002],
... coupling_map=[(0, 1), (1, 2), (2, 3), (3, 4)],
... t1=[150.0, 120.0, 180.0, 160.0, 140.0],
... t2=[80.0, 70.0, 90.0, 85.0, 75.0],
... )
>>> profile.n_qubits
5
Attributes¶
n_qubits
property
¶
Number of physical qubits described by this profile.
Functions¶
qubit_score(qubit)
¶
Combined quality score for a single qubit. Lower is better.
Combines gate/readout error rate with inverse coherence times so that shorter T1/T2 (noisier qubits) produce a higher (worse) score.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qubit
|
int
|
Physical qubit index. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Quality score. Qubits with lower scores should be preferred for high-variance features. |
Source code in quprep/preprocess/noise_aware.py
quprep.preprocess.noise_aware.NoiseAwarePreprocessor(noise_profile, encoding='angle', angle_deadzone=0.0)
¶
Reorder dataset features for noise-aware qubit assignment.
Given a backend :class:NoiseProfile, this transformer:
- assigns high-variance features to the least-noisy physical qubits,
- reorders the selected qubits to form a path through the hardware coupling map (minimising SWAP overhead for entangled encodings), and
- optionally remaps angle-encoded values away from 0 and π
(requires data already normalised to
[0, π]).
The output is a :class:~quprep.core.dataset.Dataset whose columns
are reordered so that column i maps to the i-th qubit in
:attr:qubit_assignment_. Downstream encoders that follow the
standard feature i → logical qubit i convention will therefore
automatically use the noise-optimised assignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
noise_profile
|
NoiseProfile
|
Noise characteristics of the target backend. |
required |
encoding
|
str
|
Target encoding name. Used to select the interaction graph for
SWAP minimisation and to decide whether angle remapping applies.
Recognised values: |
'angle'
|
angle_deadzone
|
float
|
Fraction of the encoding range to exclude at each pole. For example,
|
0.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
permutation_ |
np.ndarray of int, shape (n_features,)
|
|
qubit_assignment_ |
list of int, length n_features
|
|
estimated_swaps_before_ |
int
|
Estimated number of SWAP gates needed without topology optimisation.
Available after :meth: |
estimated_swaps_after_ |
int
|
Estimated number of SWAP gates needed after topology optimisation.
Always ≤ |
Examples:
>>> import numpy as np
>>> from quprep.core.dataset import Dataset
>>> from quprep.preprocess.noise_aware import NoiseAwarePreprocessor, NoiseProfile
>>>
>>> profile = NoiseProfile(
... qubit_error_rates=[0.001, 0.005, 0.002, 0.003],
... coupling_map=[(0, 1), (1, 2), (2, 3)],
... )
>>> rng = np.random.default_rng(0)
>>> data = rng.standard_normal((100, 3))
>>> data[:, 2] *= 5 # feature 2 has highest variance
>>> ds = Dataset(data=data, feature_names=["a", "b", "c"])
>>> prep = NoiseAwarePreprocessor(profile, encoding="entangled_angle")
>>> result = prep.fit_transform(ds)
>>> prep.qubit_assignment_[2] # high-variance feature → low-error qubit
0
Source code in quprep/preprocess/noise_aware.py
Functions¶
fit(dataset)
¶
Compute the noise-optimal feature permutation from dataset variances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
Input dataset. Per-feature variances are computed from
|
required |
Returns:
| Type | Description |
|---|---|
NoiseAwarePreprocessor
|
Returns |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dataset has more features than qubits in the noise profile. |
Source code in quprep/preprocess/noise_aware.py
fit_transform(dataset)
¶
transform(dataset)
¶
Reorder columns according to the fitted permutation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
Input dataset. Must have the same feature count as the dataset
used in :meth: |
required |
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset with columns reordered so that column i corresponds
to |
Raises:
| Type | Description |
|---|---|
NotFittedError
|
If :meth: |
ValueError
|
If the dataset's feature count differs from the fitted count. |
Source code in quprep/preprocess/noise_aware.py
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 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |