Skip to content

HOLD (M5 A/B): W2-A field-local prompts - #25

Open
bnsd55 wants to merge 1 commit into
mainfrom
w2a-field-local
Open

bnsd55 wants to merge 1 commit into
mainfrom
w2a-field-local

Conversation

@bnsd55

@bnsd55 bnsd55 commented Sep 18, 2026

Copy link
Copy Markdown
Owner

W2-A: Field-Local Prompts (HOLD for M5 A/B)

What changed

  • render_field_prompt is now mandatory on compile_slot_plan / compile_labels_plan — no dual paths, no fallback
  • The global-schema prompt path ("Classify the following fields...") and lead_in_ids are fully deleted
  • The prefill is now the exact token-ID LCP of per-field chat prompts (system + nonce-delimited context + field block)
  • Each row carries its field's post-LCP prompt tail + candidate remainder
  • PROMPT_VERSION = "jevmlx-parallel-v8" (main=v6, PR W2-E step 3: multi count row + reconciliation (COUNT_MARGIN_MIN = 0.7 nats) #24=v7, this=v8)
  • make_field_prompt_renderer extracted as the shared factory (engine + lint + cli + plan_hash)
  • Plan cache key now includes a context hash (prompt_tail_ids are context-dependent)
  • PARITY_ATOL bumped to 5e-2 (W2-A longer rows increase Metal batch-shape drift to ~0.027 nats)
  • New telemetry: plan_compile_ms (time to compile the plan), alongside existing prefill_tokens and suffix_tokens_total

Per-context plan recompile (inherent to exact-LCP design)

The prefill is the token-ID LCP of per-field chat prompts, which depend on the context. The plan cache (keyed by tokenizer + mode + context_hash) ensures the same context reuses the plan (~0 ms); a new context must recompile (tokenize R field prompts, LCP, codebook search). plan_compile_ms telemetry quantifies this cost in the A/B.

Merge gate

This PR is marked HOLD — it merges only after the M5 A/B (EV2 + TypeSafe) passes: EV2 drift decreases, TypeSafe accuracy non-worse. If the A/B loses, we close the PR.

Test results

All 502 tests pass (487 fast + 15 slow), ruff clean.

@bnsd55 bnsd55 closed this Sep 18, 2026
@bnsd55 bnsd55 reopened this Sep 18, 2026
- render_field_prompt is mandatory on compile_slot_plan/compile_labels_plan
- Deleted the global-schema prompt path and lead_in_ids (no dual paths)
- PROMPT_VERSION v8 (main=v6, PR #24=v7, this=v8)
- make_field_prompt_renderer extracted as shared factory (engine/lint/cli/plan_hash)
- Plan cache key includes context hash (prompt_tail_ids are context-dependent)
- PARITY_ATOL bumped to 5e-2 (W2-A longer rows increase Metal drift to ~0.027 nats)
- All 489 tests pass (474 fast + 15 slow), ruff clean

Per-context plan recompile is inherent to the exact-LCP design: the prefill
is the token-ID LCP of per-field chat prompts, which depend on the context.
The plan cache (tokenizer+mode+context_hash) ensures the SAME context reuses
the plan; a new context must recompile (tokenize R field prompts, LCP,
codebook search). plan_compile_ms telemetry quantifies this cost.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant