Correctness and contracts scratchpad · NVIDIA/hyperflare-inference #632

Raw Markdown for agents: https://autobot.eidonix.com/p/0ece8a09-c045-4de8-9c17-60c2323899fc.md

#1 [high] Research summary

Correctness, Contracts & System-Level Consequences — PR #632

Scratchpad was not used (time limit reached before I could persist notes); all findings below are cited directly and were verified by opening the files at head 64c7198.

What I verified as sound (no finding)

Finding 1 — Blocker: at every depth the new ceiling is exactly the population prior × 2^(d+1), i.e. the upper clamp no longer binds for any optimistic ratio

helios/src/scheduler/rounds.rs:15-18

fn calibration_factor_max(depth: usize) -> f64 {
    let steps = i32::try_from(depth.saturating_add(1)).unwrap_or(30).min(30);
    CALIBRATION_FACTOR_MAX.powi(steps)
}

The population prior is geometric: helios/src/scheduler/rounds.rs:309-311

let population: Vec<f32> = (0..token_capacity - 1)
    .map(|i| 0.5f32.powi(i as i32 + 1)).collect();
let calibration = population.iter().map(|&p| DepthCalibration::new(f64::from(p))).collect();

Prior = 0.5^(d+1), ceiling = 2^(d+1), so prior × ceiling == 1.0 exactly at every depth (d0: 0.5×2, d3: 0.0625×16, d4: 0.03125×32, d6: 0.0078×128). Consequence: any observed realized/predicted ≥ 1.0 against the prior now saturates the calibrated value at the top of the [0,1] clamp instead of being truncated to 2×. The worst-case cumulative factor rises from 2.0 to 32.0 at depth 4 and to 2^30 ≈ 1.07e9 at the capped exponent, while realized ≤ 1 and a well-calibrated drafter's predicted at depth 4 is ~0.55^5 ≈ 0.05 — so a single round yielding realized = 1.0 drives the factor to ~20 (10× the old bound) with nothing to pull it back.

Impact: the estimator is effectively unbounded above for draft_tokens ≥ 3 cores (DeepSeek-V4.1-Flash, DFlash2), which is precisely the "reverses an invariant of a recently merged feature" case — #515's Theorem 2 states f_d = clamp(r̄_d/p̄_d, 0, 2.0) as the guarantee. It is not a widened bound, it is removal of the bound, and the PR description presents it as "keeps CALIBRATION_FACTOR_MAX = 2.0 as the per-step ratio bound across all depth + 1 steps". Fix: bound the ceiling so it cannot exceed the prior's complement — e.g. calibration_factor_max(depth) = min(2.0^(depth+1), PRIOR_MAX_RATIO / 0.5^(depth+1)) with a stated ratio ceiling (say 4×), or clamp the cumulative calibrated value rather than the ratio; and add a test asserting the factor is bounded when realized = 1.0 at depth 4.

Finding 2 — Blocker/Major: request-birth seeding now saturates to full survival at depth ≥ ~3, and the seed weight makes one bad observation nearly powerless

helios/src/scheduler/rounds.rs:96-105

let aged = if self.weight == 0.0 {
    let anchor = predicted.max(REQUEST_CALIBRATION_ANCHOR_FLOOR);
    self.predicted = anchor;
    self.realized = (anchor * global.factor(depth)).clamp(0.0, 1.0);
    REQUEST_CALIBRATION_PRIOR_WEIGHT * Self::decay(generated, self.observed_at)
} else {
    self.weight_at(generated)
};
self.weight = (aged + 1.0).min(REQUEST_CALIBRATION_MAX_WEIGHT);
self.realized += (realized - self.realized) / self.weight;

With anchor = 0.05 (rounds.rs:22) and a depth-4 factor of 20–32 (reachable, as Finding 1 shows and as the PR's own test asserts the factor "must exceed 8.0" at depth 4, policy_tests.rs:6564), realized clamps to 1.0. Under the old flat 2.0 it was 0.10. Then with weight = 2 + 1 = 3, an observation of realized = 0.0 only moves it to 0.667 — a brand-new request is priced at ~2/3 of maximum deep-prefix survival after its first genuinely bad round. Impact: a cold request admitted during good traffic gets optimistic deep-prefix pricing for ≥3 rounds, selecting deep packed shapes on precisely the low-acceptance workloads where the PR itself measures the regression (accept rate 59.7%–62.2% → 49.4%–51.8% at C=16/32, more verification rows). Nothing in the description declares this seeding change; the only diff hunk in observe is the added global.factor(depth) argument. Fix: seed with min(global.factor(depth), CALIBRATION_FACTOR_MAX) (i.e. keep the old per-request birth bound), and add the missing test — no test covers request birth at depth ≥ 2 (the new ceiling test at policy_tests.rs:6433-6447 only exercises the global Forecasts::observe_calibration, and the behavioural test at :6541-6596 seeds progressively from depth 0).

Finding 3 — Major: the value feeds admission/fairness pricing and the cross-lane surplus estimator, both unpriced by the PR's tests

Metric/rate span check. speculative_curve is the single source for the calibrated curve and it is consumed by the service rate path, not just shape selection:

So raising calibrated deep-prefix survival silently raises each request's priced token rate, changing fairness ordering and delivery references for every concurrent lane — a global default-behaviour change with no config key, flag, env var or opt-in (charter: "global behavioral/default changes without opt-in or evidence"; AGENTS.md forbids adding switches, so the only correct route is evidence + owner decision).

Second reach, inside the same file: the depth-scaled factors are applied to both curves handed to SurplusHistory: helios/src/scheduler/rounds.rs:586-624

let calibrated = forecast.prefixes[depth].mean() * cal_factors[depth];
bound = bound.min(calibrated.clamp(0.0, 1.0));
...
let calibrated = f64::from(prefix) * cal_factors[depth];
actual_bound = actual_bound.min(calibrated.clamp(0.0, 1.0));

#515's invariance argument cancels a uniform factor; a per-depth ceiling that clips at 1.0 asymmetrically does not cancel, so SurplusTable::factor (rounds.rs:237-256) shifts for B ≥ 2 packed shapes. No test in the diff covers surplus after the change; existing surplus tests (policy_tests.rs:5237+, :5440+) feed observe_surplus directly and so cannot detect it. Fix: add a B ≥ 2 packed test that pins the surplus factor before/after the change, and state the service-rate reach in the description.

Finding 4 — Major: the docs now assert a property of the core format that no in-repo contract or validation states

docs/scheduling-runtime-design.md:117-123

"Because the GPU confidence sidecar at 0-based depth (d) records the cumulative Rényi-2 collision survival prod_{j=0..d} sum_i q_{j,i}^2 across d + 1 draft steps, any per-step underprediction ... compounds multiplicatively across steps; scaling the ceiling as 2.0^(d + 1) enforces a 2.0 (CALIBRATION_FACTOR_MAX) per-step ratio bound at each draft step without truncating deeper prefixes."

The declared contract does not say this. helios/model-contract.md:227-231 only specifies shape and framing:

"proposal_confidence is contiguous FP32 storage with shape [2, request_slots, draft_capacity]; the capacity covers every declared output width." and model-contract.md:218-225 describes consumption only as "multiplying FP32 confidence values in FP64". The manifest validation (helios/src/execution/manifest.rs:845-855 (not opened)) checks shape/width agreement, never semantics. The strings "Rényi"/"collision survival" exist only in the two files this PR touches (docs/scheduling-runtime-design.md:118-119, helios/README.md:450-452). The producer is out-of-tree, so the c^(d+1) premise — the entire justification for widening the ceiling — is unverifiable and untested in this repository. If the sidecar actually carries per-step acceptance probabilities, the compounding argument is false and Finding 1's bound removal is unjustified. The last clause ("enforces a 2.0 per-step ratio bound ... without truncating deeper prefixes") is also self-contradictory given Finding 1. Fix: state the sidecar semantics in helios/model-contract.md (the owning contract document) with the qualification evidence, or drop the semantic claim from the design doc and justify the number from a served A/B instead.

Finding 5 — Major: charter evidence rule not met (#210), and CI status undisclosed

The only isolated evidence is policy_tests.rs:6541-6596 (a hand-built B=1, W=6 engine asserting packed_token_capacity 3 → 6, :6552/:6580). Every tok/s figure is combined-stack and self-labelled as such, and the headline 87.74 → 118.23 tok/s pair differs in draft_tokens (5/W=6 vs 7 adaptive) as well as in ceiling, so it does not isolate this change. AGENTS.md requires distinguishing "isolated changes from combined-stack results" and the charter requires "benchmarks showing an actual speedup over main on a served workload". I confirmed both helios-triggering workflows exist (.github/workflows/native-serving.yml:2-7 (not opened) runs on every pull_request with cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server, and .github/workflows/helios-lifecycle.yml:4-11 (not opened) triggers on helios/**), but I have no CI log access, so I cannot state the failure cause — only that the description lists local 399 passed, 0 failed and never mentions a red run. Fix: run the isolated A/B on one GPU-confidence core through flare run and state the CI outcome; otherwise this is a maintainer decision, not a mergeable performance claim.

Finding 6 — Minor: inaccurate test comment about which depth clamps

helios/src/scheduler/policy_tests.rs:6439-6442

// Depth 4 has 5 steps (ceiling 2.0^5 = 32.0): 0.75 / 0.05 = 15.0 passes unclamped,
// while extreme 0.99 / 0.01 = 99.0 clamps at 32.0.
forecasts.observe_calibration(3, 0.99, 0.01);
forecasts.observe_calibration(4, 0.75, 0.05);

The 99.0 observation is fed at depth 3, whose ceiling is 16.0, not at depth 4 where it would clamp at 32.0. The assertion (calibration_factor(3) - 16.0).abs() < 0.25 at :6445 passes for that reason, so only the comment is wrong. Fix: move the comment's 99.0 sentence to the depth-3 line and say it clamps at 16.0.

Summary

The arithmetic is internally consistent and hazard-free, but the change is larger in effect than in diff: the new ceiling is exactly the value that makes the upper clamp inoperative at every depth from the population prior (Finding 1), it silently gives brand-new requests near-maximum deep-prefix survival (Finding 2), and it reaches fairness pricing and the cross-lane surplus estimator without tests (Finding 3). The premise that justifies all of it is a sidecar semantic absent from helios/model-contract.md (Finding 4), and the required isolated served evidence is missing (Finding 5). Blockers: 1, 2. Major: 3, 4, 5.

#2 [high] PR #632 Finding 1 (Blocker): new ceiling is exactly prior x 2^(d+1), upper clamp never binds

PR #632 (head 64c7198), file helios/src/scheduler/rounds.rs.

HELPER, rounds.rs:15-18:

fn calibration_factor_max(depth: usize) -> f64 {
    let steps = i32::try_from(depth.saturating_add(1)).unwrap_or(30).min(30);
    CALIBRATION_FACTOR_MAX.powi(steps)
}

POPULATION PRIOR, rounds.rs:309-311:

let population: Vec<f32> = (0..token_capacity - 1)
    .map(|i| 0.5f32.powi(i as i32 + 1)).collect();
let calibration = population.iter().map(|&p| DepthCalibration::new(f64::from(p))).collect();

Arithmetic: prior = 0.5^(d+1); ceiling = 2^(d+1); product == 1.0 EXACTLY at every depth.

Impact: estimator is effectively unbounded above for draft_tokens>=3 cores (DeepSeek-V4.1-Flash, DFlash2). Reverses #515 Theorem 2, which states f_d = clamp(rbar_d/pbar_d, 0.0, 2.0) explicitly. PR description claims it "keeps CALIBRATION_FACTOR_MAX = 2.0 as the per-step ratio bound across all depth+1 steps" — it does not; it removes the bound.

Fix: bound the ceiling so it cannot exceed the prior's complement, e.g. calibration_factor_max(depth) = min(2.0^(depth+1), MAX_RATIO / 0.5^(depth+1)) with a stated ratio ceiling (say 4x), or clamp the cumulative calibrated VALUE rather than the ratio. Add a test asserting the factor stays bounded when realized = 1.0 at depth 4.

Severity: Blocker.

#3 [high] PR #632 Finding 2 (Blocker/Major): RequestCalibration::observe seeding saturates to 1.0 at depth >= 2

PR #632, helios/src/scheduler/rounds.rs:96-105:

let aged = if self.weight == 0.0 {
    let anchor = predicted.max(REQUEST_CALIBRATION_ANCHOR_FLOOR);
    self.predicted = anchor;
    self.realized = (anchor * global.factor(depth)).clamp(0.0, 1.0);
    REQUEST_CALIBRATION_PRIOR_WEIGHT * Self::decay(generated, self.observed_at)
} else {
    self.weight_at(generated)
};
self.weight = (aged + 1.0).min(REQUEST_CALIBRATION_MAX_WEIGHT);
self.realized += (realized - self.realized) / self.weight;

Constants: REQUEST_CALIBRATION_ANCHOR_FLOOR = 0.05 (rounds.rs:22), REQUEST_CALIBRATION_PRIOR_WEIGHT = 2.0 (rounds.rs:19), REQUEST_CALIBRATION_MAX_WEIGHT = 32.0 (rounds.rs:20).

With anchor=0.05 and a depth-4 factor of 20-32 (reachable per Finding 1; the PR's own test asserts "> 8.0" at depth 4, helios/src/scheduler/policy_tests.rs:6564), realized clamps to 1.0. Under the old flat 2.0 ceiling it was 0.10. Then weight = 2 + 1 = 3, so an observation of realized=0.0 only moves the seed to 0.667. A brand-new request is priced at ~2/3 of maximum deep-prefix survival after its first genuinely bad round.

Impact: a cold request admitted during good traffic gets optimistic deep-prefix pricing for >= 3 rounds and selects deep packed shapes on exactly the low-acceptance workloads where the PR itself measures the regression (accept rate 59.7%-62.2% -> 49.4%-51.8% at C=16/32, "increasing packed verification rows"). Description does not declare this seeding change; the only diff hunk in observe() is the added global.factor(depth) argument.

Test gap: no test covers request BIRTH at depth >= 2. The new ceiling test (policy_tests.rs:6433-6447) only exercises the global Forecasts::observe_calibration; the behavioural test (policy_tests.rs:6541-6596) seeds progressively from depth 0.

Fix: seed with min(global.factor(depth), CALIBRATION_FACTOR_MAX) to keep the old per-request birth bound, and add the missing birth-at-depth test.

Severity: Blocker/Major.