feat: noise-native measurement layer + chassis policy seams (QILC port, public substrate)#7
Conversation
Diagonal fast path for the whitened-cost statistics from the QILC noise-native spec: noise_floor = tr(WΣWᵀ), debiased_cost J̃ = Ĵ − floor, cost_std via Var[Ĵ] = 2tr((WΣWᵀ)²) + 4rᵀWᵀWΣWᵀWr (plug-in r), and the difference scale σ_Δ = hypot(σ_A, σ_B) for acceptance/stall comparisons. Also adds test/run_filtered.jl, a local helper for name-filtered testitem runs (this TestItemRunner version has no run_tests function). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…se models
W = W_task·Σ^{-1/2} assembled per element from the model's noise types
(ShotNoise → plug-in covariance_fn(y,n) floored at var_floor/n;
KnownCovariance → diag(Σ), off-diagonals dropped by the diagonal fast
path; Deterministic → σ²=0, identity scaling). Returns (w, σ2) flattened
in model element order; Σ is returned because acceptance statistics need
tr(WΣWᵀ), not just W.
Deviation from plan: default var_floor is 0.05, not 0.25 — the plan's own
acceptance test requires the y=0.9 wigner element (σ²=(1−y²)/n=0.19/n) to
be UNfloored at defaults, which contradicts a 0.25 default (0.25/n floor).
0.05 engages only for |y| ≳ 0.975, matching the stated intent (cap weights
as |y|→1); callers can raise it.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…E parity reconstruction Ports the stanford-bosonics ILC measurement observables into the package: - displaced_parity/displaced_parity_at gain a composite transmon⊗cavity variant via SINGLE-ENTRY-POINT kwarg routing: Julia does not dispatch on keyword arguments, so one method accepts n_max (cavity-only, exact pre-existing behavior) XOR (Nq, Nc) (composite kron(I_q, D†ΠD)) and raises ArgumentError unless exactly one is given. - qubit_sigma_z(_at): ⟨kron(σz_eff, I_c)⟩ with σz_eff = diag(+1, −1, −1, …), the leakage-defense convention (−1 for ALL excited transmon levels). - density_encoding.jl: rho_triangle canonical order, rho_to_measvec (type generic, ForwardDiff-safe) / measvec_to_rho, reduced_cavity_rho, and rho_measurement_functions closures for reconstruction-mode campaigns. - parity_reconstruction.jl: reconstruct_rho_from_parity, an emulation of the lab's MLE cavity-state reconstruction. DIAGNOSTICS-ONLY contract: the PSD/trace projection is a nonlinear state-dependent bias the linear ILC Jacobian cannot track, so it must never be a feedback observable. - test/run_filtered.jl: TEST_FILTER-driven filtered @run_package_tests entry. Coherent-state anchor note: the package/demo convention op = D†(α) Π D(α) displaces the state by +α, so P(α) = exp(−2|β+α|²) for coherent |β⟩; the tests assert this and the equivalent Wigner-point form at −α. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts: # test/run_filtered.jl
…_shots override SimulatedExperiment gains an rng slot (constructor kwarg, default nothing = exactly the legacy deterministic behavior). With an AbstractRNG, each noisy measurement element gets ε ~ N(0, Σ(y)) drawn from its noise model at the evaluated y (variances floored as in whiten); deterministic elements draw nothing, keeping the rng stream layout-stable. run_experiment gains an additive n_shots kwarg on both experiment paths: SimulatedExperiment rebuilds ShotNoiseMeasurement value-copies with the boosted n (noise scales exactly 1/√n for a fixed seed); HardwareExperiment forwards to run closures that accept the kwarg, else warns once and ignores. Replaces the runner's deleted add_measurement_noise/SIM_NOISE contract and gives fixtures seeded reproducibility. Full suite green (193/193). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
y_goal::Union{Nothing,Vector{Measurement}} constructor kwarg: nothing
(default) keeps today's behavior — solve! resolves the goal once at solve
start via the strategy's tuning_goal hook; supplied → used verbatim. The
resolved goal is computed exactly once per solve and never mid-solve (the
chained-loop-drift invariant: per-round y_goal recomputation from the
current command made real campaigns diverge). Campaign scripts pass the
ideal target built from ψ_goal via the public observables.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…avior-preserving) Extracts the chassis's Armijo accept/interpolate block and the γ/tr_scale schedule into an AcceptancePolicy seam: decide(policy, ctx) returns (α, accepted, revert, tr_scale, n_evals); the chassis keeps run-experiment → whitened Ĵ/J̃ (via the noise-stats helpers; identical to raw SSR for deterministic models) → decide → apply α-interpolation (or revert to the last-accepted snapshot) → record. LineSearchAcceptance(γ, line_search) reproduces the pre-seam behavior verbatim — pinned by a hard-coded (α, tr_scale, n_experiments, J) trace regression recorded on the pre-seam chassis across the reject cascade, partial-α accept, and line_search=false paths. PulseTuningProblem gains an acceptance slot (nothing ⇒ legacy kwargs). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…trust scaling The hardware-hardened acceptance policy: no probing (α is always exactly β, one experiment per iteration); reject-and-revert iff Ĵ − J_base > max(ρ_rej·J_base, k·σ_Δ) with σ_Δ = √(σ_J²(trial)+σ_J²(base)) from the plug-in cost statistics — the catastrophe cascade cannot fire on a noise fluctuation, and an all-deterministic model (σ_Δ = 0) reduces to the legacy pure ratio test; tr_scale shrink-only (halve on reject — permanent — and after stall_patience flat trials), floored at tr_scale_min; the first measured trial always establishes the base. The chassis reverts to the last-accepted snapshot on rejection and discards the candidate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ep, dimension-change reset IterateSelector seam: FinalIterate (legacy default), NoiseCorrectedBestJ (argmin J̃ over accepted iterates — debiased selection removes the documented best-J bias), TopKRemeasure(k, reps_factor) (re-measures finalists via the n_shots override at n·reps_factor and picks the re-measured winner; fewer than k accepted ⇒ re-measure all), PolyakAverage (reproduces the former polyak_avg behavior exactly; the kwarg now forwards with a deprecation note). IterationRecord gains J_hat, accepted, F_model (new last_f_model strategy hook), and θ — the measurement-time trajectory snapshot selectors restore. solve! gains a logger kwarg and calls record!(logger, rec) once per iteration (InMemoryExperimentLogger collects them; other loggers opt in). adapt!(device_model, …) now runs BEFORE the strategy step — recalibration must precede Jacobian assembly (ordering inversion per spec). A mid-campaign measurement-dimension drop (lab σ_z fallback) now restricts the active goal/model, resets the acceptance base, and warns. Full suite green (267/267). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
armijo_line_search gains a cost::Function kwarg (default: legacy raw measurement_error). LineSearchAcceptance passes the plug-in whitened cost so backtracking compares like units with its whitened Ĵ reference — a raw trial cost against a whitened J_ref silently accepts every α = 1 step the moment a ShotNoiseMeasurement is declared, and the campaign diverges (caught by the Intonatissimo shot-noise campaign cells). Deterministic models are unchanged (w ≡ 1 reduces the closure to measurement_error). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…n strategy ctx
Task-importance weights (flattened per element, e.g. the σ_z×40 leakage
defense) become a chassis knob: composed into every whitened cost as
W = W_task·Σ^{-1/2}, restricted alongside the goal/model on a mid-campaign
dimension change, and forwarded to TopKRemeasure's re-measure whitening —
chassis, strategies, records, and selectors speak one unit. The strategy
ctx now also carries the ACTIVE measurement model and the chassis (w, σ2)
so strategies can whiten their Jacobians consistently.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…TuningProblem Model and experiment must share operator structure (frame); violation silently null-spaces the Jacobian and stalls the loop (the feat/lab_frame campaign lesson). Companion of the Intonatissimo QP-ILC loop docs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Review (adversarial pass against the approved spec/plan; statistics and behavior-preservation traces re-derived independently — they check out). Verdict: mergeable after fixes. Blocking
Recommended Also suggest bumping the version (the adapt!-before-step ordering change is behavioral, and downstream compat needs to distinguish this chassis from the released 0.2.0). |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
feat: noise-native measurement layer + chassis policy seams (QILC port, public substrate)
Implements the public half of the QILC stanford port per the approved spec:
noise_floor/debiased_cost/cost_std/diff_std(diagonal fast path) and
whiten(model, y_exp; W_task, var_floor)—GLS
W = W_task·Σ^{-1/2}from the (previously inert) measurement noisetypes, plug-in per iteration. Deviation: default
var_floor = 0.05(not the plan's 0.25 — the plan's own acceptance test requires the y=0.9
wigner element unfloored at defaults).
SimulatedExperiment(...; rng)drawsε ~ N(0, Σ(y)) per noisy element;
run_experiment(...; n_shots)value-copyoverride on both experiment types (TopKRemeasure contract).
measurement_functions/):displaced_parity(x, α; Nq, Nc)(kwarg-routed beside the cavity-only path),qubit_sigma_z, ρ triangle encode/decode,reconstruct_rho_from_parity(docstring: MLE reconstruction is diagnostics-only, never ILC feedback).
PulseTuningProblem:acceptance::AcceptancePolicy—LineSearchAcceptance(behavior-preservingextraction of the Armijo + γ-schedule path, pinned by hard-coded pre-seam
traces) and
OneShotAcceptance(β-damped apply, σ_Δ-awarereject-and-revert, shrink-only trust scaling, stall anneal).
selector::IterateSelector—FinalIterate,NoiseCorrectedBestJ(argmin debiased J̃),
TopKRemeasure(k, reps_factor),PolyakAverage(subsumes the deprecated
polyak_avgkwarg).y_goalkwarg (resolved once; the chained-loop-driftinvariant) and
W_task(task importance composed into every whitened cost).IterationRecordextended (J̃ + Ĵ, accepted, F_model via the newlast_f_modelstrategy hook, θ measurement-time snapshot, timings) +solve!(...; logger)seam.adapt!(device_model, …)now runs BEFORE the strategy step (recal mustprecede Jacobian assembly).
W_task restriction + acceptance reset + warning.
armijo_line_searchgains acostclosure soprobes compare in the same (whitened) units as
J_ref— a raw trial costagainst a whitened reference silently accepts every step once shot noise is
declared (caught by the Intonatissimo campaign cells).
Suite: 270/270. Every extraction is pinned by a behavior-preservation
regression recorded on the pre-seam chassis.
Verification: suite 270/270 at
58b9ecd. Behavior-preserving extractionsare pinned by hard-coded traces recorded on the pre-seam chassis (reject
cascade, partial-α accept, line_search=false, Polyak). Downstream, the full
Intonatissimo suite (which consumes every seam here) runs 427 pass / 0 fail /
2 expected B-spline skips, and the end-to-end acceptance gate through the new
stack reached F_truth 0.99718 with ≥ 0.99 sustained over the final 20 of 30
iterations under χ×1.15 + K_c×2.2 + 1000-shot noise + 1 %/trial drift.
Stack: this is the base of the QILC-port stack — Intonatissimo
feat/qp-ilc-strategy(harmoniqs/Intonatissimo.jl#44) and stanford-bosonicsport/intonatissimo-chassis(harmoniqs/stanford-bosonics#6) build on theseseams. Merge order: this PR first.
Spec:
armonissima/specs/spec-20260701-161246-qilc-stanford-port-noise-native.md·Plan:
armonissima/plans/plan-20260701-235146-qilc-stanford-port-noise-native.md🤖 Generated with Claude Code