mirror of
https://github.com/Druthulu/BFM-decomp
synced 2026-09-26 13:33:34 -04:00
perf(phase-23): cap api_draft max_tokens 4096->512 (no-stop ramble) + capture saturation/throughput findings
- the model rambled to 4096 tokens on no-stop-token drafts (~80-130s each); a ≤15-ins fn's C is ~100-300 toks, so 512 truncates the ramblers (gate-rejected anyway) - CURRENT_PHASE: ≤15 band NOT saturated (~4,597 unique / 4,087 untried, SC03=12,497); drafting ~15-18s/func serial is the throughput wall; architecture = phase-separate + parallel-gate + vLLM batched serving (the real GPU lever); fresh bank-rate still TBD
This commit is contained in:
@@ -73,5 +73,5 @@ The **whole-binary byte-gate** (`gate_stage`/`harvest_verify`, G3/P9) is the sol
|
||||
- 2026-06-30: **T7 DEBUGGED + FIXED.** 3 Explore scouts (tooling / run-evidence / corpus) + a direct code read (R14 — which resolved a flat contradiction between two scouts) found **two independent bugs** in `lora_grind`'s gate path: **(A)** `good_sha()` passed `"<sha> <name>"` vs harvest_verify's bare `sha1()` → 0 banks for ALL binaries incl. 077 (so 077's "0/12" was a bug artifact); **(B)** `src/asm/out` defaulted to ov_SC01_077 → non-077 drafts dropped at the 077 stub-filter, silently. Fixed `gate_stage.run_gate` (binary-agnostic resolution + bare-hash normalize + a loud negative-control guard) + `lora_grind.good_sha`; byte-neutral (check-all 136/136). ov_SC01_000 spot-run **banked 7/15 (47%) byte-identical** (@commit:0322) → reach-2 `func_8017CE24` propagated ×2. **ROI:** 6/7 reach-1 → broad rotation is high bank-rate / low fleet-% ROI; the fleet lever is **reach≥2 targeting** + corpus-v3. Backlog now correctly classified (4× close=1 = grinder fuel). NEXT: **T8 corpus-v3** (struct types) + **T9 reach≥2 selection** + concurrent grinder.
|
||||
- 2026-06-30 (cont.): **T9 reach≥2 targeting built + measured.** Added `lora_grind --min-reach N` (lazy sig-based reach oracle == `dedup_propagate`, validated 0-mismatch/60 + the func_8017CE24=2 ground truth; `--min-reach 2` ranks high-reach-first, naturally restricts to overlays). Bounded reach≥2 mass-run: ov_SC01_000's 15 reach≥2 (shared) stubs banked **0/15** (vs the reach-1 spot-run's 7/15) — the model is **weakest on shared code** (corpus skipped the `DEFINE_func` bodies + it's the regalloc/schedule tail). But **5/15 are close≤3 reach-134 near-misses** (3× close=1 = func_8012E27C/BF4C/AD64) → high-value permuter fuel (×134 each). **FINDING: reach≥2 model-only ≠ a fleet lever; the lever is reach≥2-draft → grinder-close (×134)**, which needs `grinder.py`'s per-binary fix (same class as T7) + a backlog `binary` field. (A foreground mass-run hit the 10-min Bash cap mid-2nd-batch; tree recovered clean via `git checkout`, check-all 136/136.) Details: `docs/gen2-mips-matching-model.md` "T9 RESULT". NEXT: the grinder per-binary fix (realize the reach-134 ×134 fuel), then corpus-v3.
|
||||
- 2026-06-30 (cont.): **Grinder per-binary fix (5-layer) — built + validated; reach≥2 fuel re-characterized.** The grinder/backlog were ov_SC01_077-hardcoded **5 layers deep** — fixed all: `gate_stage` records `binary`, `backlog.FIELDS` keeps it, `backlog.load_best`/`_open_stubs` fleet-aware (stuck-local fns surface via their overlay record), `p16_permute.setup` takes asm-subdir, `grinder` per-binary resolution + grouped gating + None-`nins` allow. Validated: the 3 fresh reach-134 close=1 ov_SC01_000 fns now surface + resolve + gate per-000. **FINDINGS (byte-evidenced):** (a) the reach≥2 close=1 fuel is **MODEL semantic-misses** (7B drafts empty `void f(void){}` for trivial `return 1`/setters), NOT permuter fuel — a corrected draft banks them (**+3 byte-identical** via the fixed gate, @commit:0326); (b) ×reach is **propagation-capped** (inline-matched in `ov_SC01_077_a.c` → dedup "nothing to propagate" → banked ×1). So the reach-134 ×134 payoff routes through **corpus-v3** (leaf variety) + the **dedup-collapse**, NOT the permuter. check-all 136/136 throughout. Details: `docs/gen2-mips-matching-model.md` (grinder fix). NEXT: corpus-v3 + dedup-collapse.
|
||||
- 2026-07-01 (**A: reach≥2 measurement + the macro-extern-injection lever — fleet 63.82%→64.16%, $0 LLM**): served v3 (`serve_local.py`, ~15s). **(1) Measured v3 on reach≥2** (`lora_grind --min-reach 2`, bounded): banked **6/15 in ov_SC01_005** (+1 in 006) — **v3 banks the reach≥2 band**, vs v2-pre-fix's 0/15 (T9). But the banks are mostly low-reach (the 005≡006 pair = ×2) and re-bank inline per overlay → the fleet-% needs the COLLAPSE. **(2) Scoped the dedup-collapse:** the broad-overlay inline banks are mostly already-propagated (8-hr sweeps) or reach-1; the real ×134 fuel is **29 reach-134 fns matched INLINE in ov_SC01_077 but `dedup_propagate`-skipped as "not self-contained"** (the §19/20 propagation cap; the Phase-20 backlog list). Diagnosed (R14): they fail `compiles_standalone` on **file-scope callee/data externs** (clean lever) or **local types** (fiddly). **(3) Built `tools/inject_capped_externs.py`** (the Phase-20-backlog "macro-extern-injection", never built): source each capped fn's externs from 077's OWN file-scope decls, inject block-scope → self-contained → liftable ×134. Byte-neutral (077 stays `d19c9580…`), fail-safe (only rewrites if then `compiles_standalone`). **Freed 8 (main .c) + 3 (`_a.c`) = 11 reach-134 fns**, propagated ×134, **9 new shared groups (1678→1687)**, fleet **63.82%→64.16%** (+0.34%, +1204 byte-identical), check-all **136/136**, dedup-check 0 failed, **$0 LLM**. cookbook **§28d** + SETUP inventory (R16/R21/R30). **(4) Type-walled subset (14 reach-134 fns) DEFERRED:** the §28b type-lift (`build_engine_types --strip`) is **collision-blocked** (`typedef vec differs between header and source`) — the inline-invented types (MATRIX/Buf/Vec3/Loc/vec/…) need manual name-collision reconciliation; low-ROI/fiddly, byte-gate+collision-guard correctly refused. The 14: `0x8014964C 0x8014A048 0x8014C8C8 0x801678F0 0x8016A8FC 0x801749C8 0x80177EA4` (main) + `0x8012A418 0x8012A464 0x8012C658 0x8012E778 0x8012EA90 0x80134310 0x801395D4` (_a). Blast radius of a lift = overlays ONLY (engine_types.h does NOT reach main/resident). **(5) Launched a bounded broad v3 harvest** (12 batches, propagate-every-4) for $0 corpus growth + incremental banks — running at write time. **NEXT:** verify+commit the harvest; then the strategic fork — (a) v3.1 flywheel retrain on the grown corpus (compounding, ~2h GPU), (b) the type-collision reconciliation (~+0.5%, fiddly), or (c) accept the automated ceiling and head to PhaseEnd. The injection lever now CLOSES the v3-reach≥2→×134 loop for future 077 banks (idempotent re-run).
|
||||
- 2026-07-01 (**A: reach≥2 measurement + the macro-extern-injection lever — fleet 63.82%→64.16%, $0 LLM**): served v3 (`serve_local.py`, ~15s). **(1) Measured v3 on reach≥2** (`lora_grind --min-reach 2`, bounded): banked **6/15 in ov_SC01_005** (+1 in 006) — **v3 banks the reach≥2 band**, vs v2-pre-fix's 0/15 (T9). But the banks are mostly low-reach (the 005≡006 pair = ×2) and re-bank inline per overlay → the fleet-% needs the COLLAPSE. **(2) Scoped the dedup-collapse:** the broad-overlay inline banks are mostly already-propagated (8-hr sweeps) or reach-1; the real ×134 fuel is **29 reach-134 fns matched INLINE in ov_SC01_077 but `dedup_propagate`-skipped as "not self-contained"** (the §19/20 propagation cap; the Phase-20 backlog list). Diagnosed (R14): they fail `compiles_standalone` on **file-scope callee/data externs** (clean lever) or **local types** (fiddly). **(3) Built `tools/inject_capped_externs.py`** (the Phase-20-backlog "macro-extern-injection", never built): source each capped fn's externs from 077's OWN file-scope decls, inject block-scope → self-contained → liftable ×134. Byte-neutral (077 stays `d19c9580…`), fail-safe (only rewrites if then `compiles_standalone`). **Freed 8 (main .c) + 3 (`_a.c`) = 11 reach-134 fns**, propagated ×134, **9 new shared groups (1678→1687)**, fleet **63.82%→64.16%** (+0.34%, +1204 byte-identical), check-all **136/136**, dedup-check 0 failed, **$0 LLM**. cookbook **§28d** + SETUP inventory (R16/R21/R30). **(4) Type-walled subset (14 reach-134 fns) DEFERRED:** the §28b type-lift (`build_engine_types --strip`) is **collision-blocked** (`typedef vec differs between header and source`) — the inline-invented types (MATRIX/Buf/Vec3/Loc/vec/…) need manual name-collision reconciliation; low-ROI/fiddly, byte-gate+collision-guard correctly refused. The 14: `0x8014964C 0x8014A048 0x8014C8C8 0x801678F0 0x8016A8FC 0x801749C8 0x80177EA4` (main) + `0x8012A418 0x8012A464 0x8012C658 0x8012E778 0x8012EA90 0x80134310 0x801395D4` (_a). Blast radius of a lift = overlays ONLY (engine_types.h does NOT reach main/resident). **(5) Launched a bounded broad v3 harvest** (12 batches, propagate-every-4) for $0 corpus growth + incremental banks — running at write time. **NEXT:** verify+commit the harvest; then the strategic fork — (a) v3.1 flywheel retrain on the grown corpus (compounding, ~2h GPU), (b) the type-collision reconciliation (~+0.5%, fiddly), or (c) accept the automated ceiling and head to PhaseEnd. The injection lever now CLOSES the v3-reach≥2→×134 loop for future 077 banks (idempotent re-run). **(6) Saturation-campaign scoping (Drew's "10,000 small funcs" directive — exhaust ≤15 fleet-wide before bigger):** measured the real fuel — **~32,636 open ≤15-ins stub-instances / ~4,597 unique-by-name / 4,087 untried** (NOT saturated — my "saturated" claim from the SC01-only sample was an over-extrapolation Drew caught, R14; SC03 alone has 12,497). Sample shows ~all untried ≤15 are reach-1 (location-unique, ×1) — the shared band was matched/propagated in earlier phases. **THROUGHPUT WALL (the real blocker):** drafting is ~15–18s/func SERIAL (the real draft = full .s input + recovery pipeline), so exhausting ~4k unique funcs is ~a day and the full per-overlay set is multi-day; and the whole-overlay byte-gate (~1s warm) is fast but a big-overlay gate hung 11+ min once. **Fixes applied:** `lora_grind` runs `progress.py --fleet` only on propagate sweeps (was every batch = ~14s overhead dominating small batches); `--min-nins` (target a fresh band w/o re-grinding small failures); `api_draft` max_tokens 4096→512 (the model rambled to 4096 = ~80–130s on no-stop-token drafts). **ARCHITECTURE CONCLUSION (Drew's phase-separation idea = right):** the interleaved draft(GPU)→gate(CPU) per-batch design idles the GPU during every gate (the "low GPU usage" Drew saw). The path: **phase-separate** (bulk-draft GPU → bulk-gate parallel-across-cores CPU → dedupe once) + **pipeline** (draft N+1 while gating N) + **batched inference via vLLM** (the real GPU-saturation lever — Unsloth serve does ~18s/func serial; vLLM continuous-batching is 5–20×). This is a substantial focused build (the proper `bulk_harvest` + a vLLM serving swap) — deferred to a fresh focused effort (R30: capture findings now, the build is continuable). v3 bank-rate on the fresh location code = STILL UNMEASURED (the SC03 measurement hung on the slow gate); measure it first thing (it decides ~8k vs ~2k yield → whether the multi-day campaign is worth it).
|
||||
- 2026-06-30 (**8-hour autonomous run, Drew away**): prompt-fix + local serving + corpus-v3 + v3 + big batch. **LM Studio ejected** → built **`tools/serve_local.py`** (Unsloth GPU serving as an OpenAI endpoint; the prebuilt llama-cpp-python CUDA wheel SIGILLs on this no-AVX-512 CPU, so the Unsloth/torch path is the reliable one). **PROMPT FIX** (`api_draft.LEAN_SYS` + `format_finetune.SYS`, synced): "translate EVERY instruction, never an empty body" — the v2 empty-leaf overfit, small-leaf band **0/3→2/3**, banked 3 on a fresh ov_SC01_001 batch. **CORPUS-V3**: `export_pairs` now mines the **1623 engine_core.h `DEFINE_func` macros** (the shared setters/return-const the model was blind to — 96.6% of v2 was overlay-unique) + `format_finetune` inlines `engine_types.h` structs → corpus **1312→2891**, trainable **2534+291** (2.5× v2). **v3 trained** (Qwen2.5-Coder-7B QLoRA, loss 1.275→0.085, ~2h), held-out gate-true eval **MATCH 23/40 (57.5%)** (generalizing; v2's mixed-set rate was lower). Grinder concurrent during training = 0 banks (permuter tail exhausted, Phase-22 reality). **Big batch** (v3, broad rotation, 25 binaries, propagate-every-3, **$0 LLM**): banked **~352 fns inline + 45 new shared groups** (1633→1678) → fleet **63.67% → 63.82%** (+502 byte-identical), **136/136 byte-clean**, 25 auto-commits. v3 repeatedly banked the **empty-leaf/setter class v2 couldn't** (func_8012E27C=return 1, 8012AD64/BF4C=setters). **Pipeline validated end-to-end:** a free local fine-tuned model harvests the small/setter bulk at $0, gated identically (G3/P9). Details: `docs/gen2-mips-matching-model.md` ("Corpus-v3 ... 8-hour autonomous run"). **NEXT (fresh session):** (1) **shared/reach≥2 targeting** (`lora_grind --min-reach 2` with v3 — so the setter banks propagate ×134 instead of re-banking inline per binary — the fleet-% lever); (2) **dedup-collapse** the per-binary inline setters; (3) **corpus-v4** = struct-giant types; raise `--max-nins` as the band lifts. Serve: `tools/serve_local.py --adapter models/bfm-match-7b-v3` (R21 / SETUP §Tooling inventory).
|
||||
|
||||
+3
-1
@@ -152,7 +152,9 @@ def build_user_lean(t, asm_text, ghidra_text):
|
||||
+ asm + "\n\nWrite the byte-matching C function.")
|
||||
|
||||
|
||||
def call_api(messages, max_tokens=4096, temperature=TEMP, timeout=600):
|
||||
def call_api(messages, max_tokens=512, temperature=TEMP, timeout=600): # 512 caps the no-stop-token ramble
|
||||
# (a small-fn draft is ~100-300 toks;
|
||||
# giants pass an explicit larger cap)
|
||||
body = json.dumps({'model': MODEL, 'messages': messages,
|
||||
'max_tokens': max_tokens, 'temperature': temperature}).encode()
|
||||
req = urllib.request.Request(API_BASE + '/chat/completions', data=body,
|
||||
|
||||
Reference in New Issue
Block a user