Commit Graph

8 Commits

Author SHA1 Message Date
Drew T 1caff3dc4c feat(phase-23): api_draft MAXTOK env + OpenRouter cost capture (T10.7 reasoning-model support)
- MAXTOK env (default 512 = local v3 unchanged); reasoning models (GLM5.2) need a high cap or
  they spend the budget on reasoning tokens and return empty content
- accumulate usage.cost from the response -> per-run $ + $/fn readout (OpenRouter reports it)
2026-07-01 18:29:27 -06:00
Drew T 7dbdd1ce47 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
2026-06-30 15:52:04 -06:00
Drew T 066a2e5c8f feat(phase-23): local GPU serving + prompt-fix + corpus-v3 (macro+struct mining)
LM Studio was ejected, so serving is ours now: tools/serve_local.py serves base+LoRA via
Unsloth (.venv-train cu128) as an OpenAI endpoint — no llama.cpp build (this CPU has no
AVX-512, which SIGILLs the prebuilt llama-cpp-python CUDA wheels). api_draft/lora_grind hit
it unchanged.

PROMPT FIX (api_draft.LEAN_SYS + format_finetune.SYS, kept in sync): 'translate EVERY
instruction, never an empty body' — a prompt test took the small-leaf band 0/3 -> 2/3 MATCH
(the v2 corpus overfit an empty void f(void){} leaf pattern). Validated end-to-end: a fresh
ov_SC01_001 batch banked 3 via the local server + better prompt.

CORPUS-V3 (export_pairs + format_finetune):
- export_pairs now ALSO mines the 1623 DEFINE_func macro bodies in engine_core.h (the shared
  setters/return-const/dispatchers extract_defs never saw -> 96.6% of v2 was overlay-unique,
  the root of the empty-leaf overfit). Corpus 1312 inline -> 2891 (1312 inline + 1579 macros).
- format_finetune inlines engine_types.h structs in the compile-filter so struct-using bodies
  are KEPT not dropped: train 2534/2591 (97.8%) compile standalone (v2 was 1111 total).
2026-06-30 01:46:54 -06:00
Drew T b4c312a30c feat(phase-22): FIRST free-local-model banks — 4 open stubs matched by the v2 LoRA
The fine-tuned 7B (bfm-match-7b-v2) drafted real OPEN ov_SC01_077 stubs; whole-binary gate banked 4
(func_80160B34 func_8015CC74 func_8016084C func_801705C0). Sample: 9/22 match_one proxy -> 4/22
whole-binary banked (18%; the proxy->gate gap is the TU-plumbing wall). Model is format-robust (raw .s
== normalized). api_draft: NORMALIZE_ASM bridge (unused — model handles raw .s) + ghidra_c-empty fix.
2026-06-29 21:58:09 -06:00
Drew T 1c80b25ac6 feat(phase-22): LoRA specialist pilot tooling — format_finetune + train_lora + api_draft LEAN
format_finetune.py: corpus -> Qwen chat-template instruction JSONL (lean asm->C, 1174 train/133 test).
train_lora.py: Unsloth QLoRA recipe (Qwen2.5-Coder-7B 4-bit, fits 12GB; merges to GGUF for LM Studio).
api_draft.py LEAN=1: ~350-tok asm-only prompt matching the training shape (fine-tuned model needs no
inlined cookbook -> fast). Datasets gitignored. Eval: beat stock-local ~0 on the held-out frozen 20.
2026-06-29 16:35:06 -06:00
Drew T 4895843dda feat(phase-22): api_draft fair-harness — inline common.h + live cookbook + corpus examples
Gives the no-tool local model the context the agents read: common.h, live matching cookbook
(COOKBOOK_FULL toggle), 2 byte-matched corpus examples. Qwen3.6-35B-A3B result: harness fixes
compile-fails but model stays stuck at fixed near-misses; FULL cookbook worse+2.3x slower than
curated (dilution, gate-confirmed). Bottleneck is model refinement, not context.
2026-06-29 16:24:37 -06:00
Drew T ad535ad1ab feat(phase-22): gen2 matching-model design + export_pairs.py corpus miner
docs/gen2-mips-matching-model.md: the BFM/gcc-2.7.2 matching-specialist idea (LoRA on our own
gate-verified pairs — the corpus off-the-shelf RE LLMs lack). export_pairs.py mines 1307 banked
(asm<->C) pairs from build objects (asm/ is gitignored, so disasm the ROM-identical build, splat-like
format) + src defs -> datasets/match_pairs/{pairs,train,test}.jsonl (gitignored, 1174/133 split).
api_draft.py: TEMP env-tunable. .gitignore: datasets/ models/ weights.
2026-06-29 14:27:19 -06:00
Drew T 3549f756f7 feat(phase-22): api_draft.py — provider-agnostic draft worker (local/OpenRouter)
Script equivalent of one worker_wave drafter for any OpenAI-compatible endpoint (LM Studio /
llama.cpp / vLLM / OpenRouter). Inlines asm+ghidra_c+toolkit, calls /chat/completions, extracts C,
iterates against match_one (diff fed back, keep best). Output scores as a 'local'/'glm' arm via
ab_score.py. Env: API_BASE/API_KEY/MODEL. Logic self-tested; HTTP is standard OpenAI format.
2026-06-29 13:05:18 -06:00