NoiseModel¶
from cascaqit import NoiseModel
NoiseModel ¶
NoiseModel(
noise_model_id: str,
channels: tuple[NoiseChannel, ...],
metadata: dict[str, Any] = dict(),
schema_version: str = "cascaqit.noise.physical.v1",
)
Combine channels for LocalBackend.run(..., noise=model). noise_model_id must be nonempty and channels must contain at least one NoiseChannel. Channel IDs must be unique, and the current model permits only one channel of each channel_type. Two channels of the same type cannot specify different rates on different sites. Metadata and schema version are stored with the configuration.
from cascaqit import NoiseChannel, NoiseModel
noise = NoiseModel("readout-only", channels=(NoiseChannel.readout(0.02, p10=0.04),))
assert noise.channel("readout").parameters["p10"] == 0.04
assert noise.channel("dephasing") is None
assert not noise.requires_trajectory
noise.validate_for(("q0",), has_digital=True, has_analog=False, is_hybrid=False)
The backend configures execution method, trajectory count, integration steps and shots; this model alone does not determine numerical or sampling error. See the Noisy Hybrid project for interpreting state, counts and costs.
Look up channel_type, returning its NoiseChannel or None if absent. Lookup does not run simulation.
Return True when an atom_loss channel exists. False does not bypass numerical planning or imply ideal state-vector execution; other physical noise may still require density matrices or trajectories.
validate_for ¶
validate_for(
logical_order: tuple[str, ...],
*,
has_digital: bool,
has_analog: bool,
is_hybrid: bool,
) -> None
Check targets against logical_order and use the three flags to check required Digital, Analog or Hybrid structure. Return None on success. Unknown targets raise ProgramValidationError; missing prerequisites raise CapabilityError. This does not validate a concrete control schedule; the backend still checks the actual program and execution method.
Restore NoiseModel from a dictionary. Restore channels and recheck unique IDs and channel types. Missing required fields or invalid values can raise KeyError, TypeError or ValueError.
Parse a JSON object and call from_dict(), returning NoiseModel. Invalid JSON raises a parsing error; a non-object root raises TypeError.
Return a JSON-compatible dictionary, serializing nested objects and converting tuples to arrays. This stores the declaration, not an execution result.
Return a JSON string without writing a file. indent=None uses compact formatting; supply an indentation width for readable output.
Return the SHA-256 hex digest of canonical JSON. Fields, identifiers and metadata can affect it. Use it to compare saved content, not to decide physical equivalence.