Observe dephasing with a readout rotation¶
Add dephasing to the one-qubit H–Analog–H experiment from shared state. Compare the noisy probabilities with an ideal run and a closed-form prediction. Read noise and numerical precision first; run the script in the installed environment.
Predict the loss of coherence¶
The first H prepares |+⟩. During the Analog interval the Hamiltonian is ΩX/2, with Ω = 0.4 rad/us and duration t = 0.1 us. Without noise, this input only acquires a global phase, so the final H returns it to |0⟩.
CASCAQit's NoiseChannel.dephasing(γ) uses a rate in 1/us. For this channel, an off-diagonal density-matrix element decays as exp(−γt) in the absence of other competing effects. In this experiment the Bloch vector remains on X, so the drive does not compete with that decay. The final H converts the remaining X coherence to a Z population difference:
P(1) = [1 − exp(−γt)] / 2
γ = 0.3 /us, t = 0.1 us → P(1) ≈ 0.01477723
Rate conventions differ between noise models and papers. Use this decay equation when comparing parameters; a symbol called γ elsewhere can differ by a factor of two.
Run the noisy and ideal experiments¶
"""Execute physical dephasing on a continuous Hybrid state.
``NoiseModel`` selects a noisy-state engine instead of post-processing counts.
The result records the selected method, simulation classification, ordered
channel applications, and the same Hybrid state lineage used by ideal runs.
"""
from __future__ import annotations
import json
from cascaqit import (
AHSProgram,
AtomRegister,
Circuit,
HybridProgram,
LocalBackend,
Waveform,
)
from cascaqit.simulators import NoiseChannel, NoiseModel, SimulationOptions
def main() -> None:
"""Run a one-site D-A-D program with exact density-matrix dephasing."""
analog = AHSProgram(
AtomRegister.line(count=1, spacing=5.0),
program_id="lesson.hybrid.noise.analog",
).drive(
rabi=Waveform.constant(0.4, duration=0.1),
detuning=Waveform.constant(0.0, duration=0.1),
phase=0.0,
)
program = (
HybridProgram("lesson.hybrid.noise")
.digital("prepare", Circuit(1).h(0))
.analog("evolve", analog)
.digital("readout_rotation", Circuit(1).h(0))
.measure_all()
)
noise = NoiseModel("lesson.hybrid.dephasing", (NoiseChannel.dephasing(0.3),))
result = (
LocalBackend(seed=104, analog_time_steps=4)
.run(
program,
noise=noise,
shots=32,
options=SimulationOptions(
method="density_matrix",
integrator="fixed_step_krylov",
max_steps=4,
),
)
.result()
)
report = result.metadata["noise_report"]
ideal = LocalBackend(seed=104, analog_time_steps=4).run(program, shots=32).result()
payload = {
"track": "hybrid_researcher",
"level": "advanced",
"lesson": "physical_noise",
"facts": {
"method": result.metadata["simulation_execution_config"]["method"],
"truthfulness": result.metadata["simulation_truthfulness"],
"channel_types": report["applied_channel_types"],
"noise_report_hash_present": len(result.metadata["noise_report_hash"])
== 64,
"probabilities": result.probabilities,
"ideal_probabilities": ideal.probabilities,
"physical_application_count": report["physical_application_count"],
"measurement_application_count": report["measurement_application_count"],
"counts_total": sum(result.counts.values()),
},
"boundaries": {
"hardware_execution": False,
"cloud_execution": False,
"network_accessed": False,
"credentials_loaded": False,
},
}
print(json.dumps(payload, sort_keys=True))
if __name__ == "__main__":
main()
python3 examples/user/tracks/hybrid_researcher/04_advanced_physical_noise_en.py
The noise model selects density-matrix evolution and applies dephasing during the Analog block. The Digital preparation and readout gates are ideal in this example. The ideal comparison uses the same program with no noise model. Each run samples 32 shots, for 64 shots across the pair.
{
"boundaries": {
"cloud_execution": false,
"credentials_loaded": false,
"hardware_execution": false,
"network_accessed": false
},
"facts": {
"channel_types": [
"dephasing"
],
"counts_total": 32,
"ideal_probabilities": {
"0": 1.0,
"1": 0.0
},
"measurement_application_count": 0,
"method": "density_matrix",
"noise_report_hash_present": true,
"physical_application_count": 1,
"probabilities": {
"0": 0.9852227667742534,
"1": 0.014777233225746552
},
"truthfulness": "physical_state_evolution"
},
"lesson": "physical_noise",
"level": "advanced",
"track": "hybrid_researcher"
}
Compare probabilities with ideal_probabilities. The noisy P(1) should match the prediction, while the ideal value is zero within numerical precision. A density matrix gives deterministic state probabilities; drawing counts from them still introduces sampling noise.
With only 32 shots and P(1) ≈ 0.01478, the expected number of 1 samples is about 0.47. The chance of seeing none is roughly 62%. Zero observed errors in this short run would not show that the noise channel was absent. Increase shots to estimate this small probability, or compare the simulator probabilities directly when testing the model.
physical_application_count=1 and measurement_application_count=0 describe one reported channel application during state evolution. They are not counts of stochastic jumps, time steps or faulty shots. truthfulness="physical_state_evolution" identifies the simulation path; it does not claim that this rate was measured on hardware. The channel report and its hash help identify which model was executed.
Make the signal larger or change the basis¶
- Set the rate to zero. What should remain different between the noisy-model run and the ideal run?
- Increase the rate to
3.0 /usat the same duration. PredictP(1)and its expected count in 32 shots. - Remove the final H from both programs. Can this Z measurement still distinguish their coherence?
Check your reasoning
At zero rate, the probabilities coincide; the requested method and noise-model records can still differ. At 3.0 /us, P(1) ≈ 0.129591, giving about 4.15 expected 1 samples, not a guaranteed integer count. Without the final H, both states have balanced Z populations. Dephasing changes their off-diagonal elements, which this readout does not reveal. A suitable measurement basis is part of the experiment.
This is a specified local model, not a calibrated device forecast. The four fixed steps do not become adaptive just because tolerance fields exist. See noise models for supported channels, and resource planning for the cost of choosing a state representation.