david-thrower's picture
binding launch protocol: spec-sheet sign-off + instruct-token contract
c174b6d verified
|
Raw History Blame Contribute Delete
5.36 kB
# AGENTS.md — HelixLM launch protocol (BINDING)
**Invoke at the start of every session:**
`Read hf://datasets/david-thrower/HelixLM-agent-memory/AGENTS.md and treat §1–§3 as hard gates before submitting any job.`
Written 2026-11-20 after a full SFT lineage shipped without ChatML special tokens or an
extended embedding — money spent, prototype goal missed. These rules exist because of that.
---
## §1 — NO LAUNCH WITHOUT A SIGNED SPEC SHEET
Before submitting **any** job, sandbox, or launcher for a run that spends more than $1 or
trains longer than 15 minutes:
1. Post the **SPEC SHEET** (template in §5) in the reply — not in a hidden file.
2. Ask for approval with `ask_user_question`, one option per candidate run, each option
naming the run and its cost. Approval means **a click on that option**. A "go ahead"
in prose counts only if it repeats the run name.
3. Only then submit. If the user edits any line of the spec sheet, re-post it and re-ask.
4. If anything in the launcher changes after approval (LR, tokens, epoch count, base,
data, hardware), the approval is **void** — re-post and re-ask.
Rationale: miscommunication has cost multiple full runs. The spec sheet is the one
artifact both parties read before money is spent.
---
## §2 — INSTRUCT MODEL CONTRACT (tokenizer + embedding)
An artifact may be called **instruct** only if ALL of the following are true, asserted
in the launcher and printed in the log:
- the two ChatML markers are **special tokens**, added before saving:
```python
tokenizer.add_special_tokens(
{"additional_special_tokens": ["<|im_start|>", "<|im_end|>"]})
model.resize_token_embeddings(len(tokenizer))
assert len(tokenizer) == 50259 # 50,257 GPT-2 + 2
assert model.count_parameters()["total"] == 53_593_367 # 53,592,343 + 2*512
```
- each marker encodes to **exactly one id** and round-trips:
```python
assert len(tokenizer.encode("<|im_start|>", add_special_tokens=False)) == 1
assert len(tokenizer.encode("<|im_end|>", add_special_tokens=False)) == 1
```
- `<|im_end|>` is the turn **stop string** in generation and is recorded in
`config.json` (`stop_strings: ["<|im_end|>"]`), never left `null` for an instruct model.
- the param count **before and after** the resize appears in the log, the spec sheet,
and the README.
- the chat template is set in the process before `save_pretrained` (never by editing the
export) and verified after reload without importing `helix_lm`.
Precedent: the 41M-param run with the extended embedding behaved correctly. That is the
house standard. No exceptions without the user stating, in writing, for that run.
---
## §3 — PARAM COUNT IS A GATE, NOT A CLAIM
Every model repo's README and `training_info` quote the exact parameter count measured by
the run's own g4/g7 gates. Never "≈". A count that changes (resize, merge) is stated with
its before → after.
---
## §4 — STANDING RULES (already learned the hard way)
1. **Budget:** post a cost-to-complete table (holds vs expected actual) before submitting.
A budget raise is a user click carrying `setBudgetUsd` — a **total**, not an increment.
2. **Provenance:** pin the commit; hash-audit every shipped `.py` against it; record
`training_info.code_commit`; paste the audit into the card.
3. **Exports are not working trees:** no hand-edits to `.py`, `tokenizer_config.json`, or
`config.json` in a model repo. Change source → move the branch → regenerate.
4. **Data gates:** assert row counts, split disjointness, zero eval leakage, length caps,
and the packed-member subset before training.
5. **Evidence:** per-1,000-step snapshots to a recovery repo; mid-run generations must be
**greedy** (`do_sample=False`) to be interpretable; final full-val on the fixed split.
6. **Never** report a number measured under a different code state than the artifact ships.
7. **Never** present an expected result as an achieved one; report failed runs and their
numbers too.
8. **If the requested artifact's semantics are ambiguous** ("instruct", "prototype",
"scale-down"), stop and ask before spending — do not infer from a template.
---
## §5 — SPEC SHEET TEMPLATE (copy into every pre-flight reply)
```
RUN: <name> -> <destination repo>
BASE: <repo> @ <commit or HEAD+prefix> (audited? y/n)
DATA: <repo> config=<cfg> split=<split> rows=<n> (gates: ...)
TOKENIZER: vocab=<n>, special tokens=<list>, resized=<y/n>, params <before> -> <after>
METHOD: full fine-tune / LoRA ... EPOCHS: <n> STEPS: <n>
LR: peak <x> -> floor <y>, warmup <n>, schedule <shape>
BATCH: <bs> x accum <g> x seq <n> = <tokens/step>
HARDWARE: <flavor> timeout <t> hold $<h> expected actual $<a>
GATES: g0..g7 as listed in the launcher
EXPECTED PARAMS: <exact>
EVIDENCE: snapshots every <n> steps, greedy gens, final full-val
OUTPUT: params, chat template round-trip, stop_strings, samples
```
---
## §6 — HOW THIS FILE IS ENFORCED
- The user pastes the §0 invocation line at the top of every handoff / new session.
- Any launcher pushed to a HelixLM model repo must be accompanied by the spec sheet that
was approved for it; the launcher's docstring starts with the approved spec sheet.
- Contradicting a rule here requires the user to say so explicitly, for that run, in writing.