# S06 candidate 1 -- S46's protocol on the fixed bridge at n=8: the headline with a confidence interval. ~$20 cap.
# n=5 cannot resolve a 7.9% effect at the A/A's s_y (MDE 8.23%); n=8 gives 5.58%.
# S46b -- S46 again, on a bridge that does not manufacture sharing. reps=1, ~$0.90 on an L40S.
#
# WHY S46 MUST BE RE-RUN
# ======================
# D1 (results/d1_engine_hit_rate.json, 2026-09-02) read vLLM's own counters on S46's exact
# configuration: 38.6% of prompt tokens served from the prefix cache -- ABOVE the modelled
# stream's theoretical maximum of 16.9%. The cause is the trace bridge: bench/trace_io's
# legacy block_text chose words by `seed % 33`, so the real slice's 13,712 distinct block ids
# became 33 distinct texts, and GPU-only LRU on that collapsed stream at S46's capacity is
# 0.41 -- which is what the engine measured. S46's 1.3048x (30.5% knee uplift) was measured on
# a 33-text stream. It is a true statement about that stream and no statement about Mooncake.
#
# WHAT THIS RUN IS
# ================
# S46's protocol, same trace, same capacity, same ladder, on the FIXED mapping (keyed hash,
# 13,712 ids -> 13,712 texts, gated by assert_distinct_blocks_have_distinct_text before any
# request is served), at reps=1, with the engine's counters read. Two pre-registered readings:
#
#   direction: apc_off/apc_on < 1.0 is still expected -- the trace carries 16.9% achievable
#              reuse and APC should capture some of it. A null here is a NULL, not a broken
#              bridge (the converse gate has excluded that), and it says Mooncake-shaped traffic
#              at this capacity does not reward prefix caching much.
#   hit rate:  the engine's rate should land near the oracle's 0.039 (16-token blocks may lift
#              it somewhat; the ceiling is 0.169). A rate above 0.169 means the bridge is still
#              wrong somewhere and the run is void.
#
# n=1: the knee ratio is a direction, not a headline. If the direction holds, S46 at n=5 on the
# fixed bridge (~$25) is the headline run and needs its own approval.

artifact: s46c_apc_fixed_bridge_n8
sprint: "46b"
claim: >-
  Whether vLLM's prefix caching still raises the sustainable-QPS knee on the real Mooncake
  slice once the trace bridge no longer collapses distinct blocks into identical text -- and
  what hit rate the engine reports on the real stream.

model: Qwen/Qwen2.5-1.5B-Instruct
provider: modal
reps: 8
seed: 20260906
cost_cap_usd: 20.0
telemetry_hz: 10
warmup: 8
request_timeout_s: 300
drain_timeout_s: 45
client_shards: 8

server_args:
  max_model_len: 16384
  max_num_seqs: 256
  gpu_memory_utilization: 0.85
  num_gpu_blocks_override: 4096

arms:
  - name: apc_off
    server_args: {enable_prefix_caching: false}
  - name: apc_on
    server_args: {enable_prefix_caching: true}

slo:
  name: nominal
  ttft_p95_ms: 2000.0
  tpot_p95_ms: 50.0
  ttft_p99_ms: 4000.0
  min_completion_rate: 0.99

trace:
  source: mooncake_timed_600
  max_requests: 600
  block_tokens: 64
  max_output_tokens: 256
  duration_s: 60.0
  calibrate_tokens: true

gpu: L40S

sweep:
  lo_qps: 6.0
  hi_qps: 14.0
  coarse_points: 5
  refinements: 3
  reference_offered_qps: 100.0

preregistered_threshold:
  ratio_orientation: apc_off/apc_on
  primary: "paired median knee ratio apc_off/apc_on < 1.0, significant at alpha=0.05, n=8 (MDE at s_y 0.047 is 5.58%: results/s47_aa_null_real_trace.json, bench/stats.mde)"
  paired_ratio_must_be_significant_at_05: true
  paired_cv_pct_max: 8.72
  engine_hit_rate_apc_on_must_be_at_most: 0.169
  engine_hit_rate_apc_off_must_be: 0.0
  quote_only_if_harness_bound_arm_knees: 0
  companion_aa: "results/s47b_aa_fixed_bridge_n8.json must be within [0.90, 1.10] and not significant, else nothing here is quoted"

does_not_prove:
  - "n=8, one model (Qwen2.5-1.5B-Instruct), one GPU class (L40S), one trace, one capacity (65,536 tokens)."
  - "block_tokens 64 against a declared 512 (S46's 8x downscale), kept so the comparison with S46, S46b and the oracle is like-for-like."
  - "Sized on S47's s_y 0.047 from the collapsed stream; the fixed bridge's s_y is what the next run must be sized on."
  - "A knee ratio, not GPU-hours; the robust block decides whether the ratio or the absolutes are the steadier quantity."
