File size: 3,484 Bytes
5463614 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | import argparse
import os
from pathlib import Path
import yaml
HERE = Path(__file__).resolve().parent
CONTROL_BASE = "Qwen/Qwen2.5-0.5B-Instruct"
REAL = [
("shortthink-sft", "sft", "Qwen/Qwen3-1.7B", "AmareshHebbar/ShortThink_Qwen3_1.7B_SFT"),
("shortthink-grpo", "grpo", "Qwen/Qwen3-1.7B", "AmareshHebbar/ShortThink_Qwen3_1.7B_GRPO"),
("toolsure-orpo", "orpo", "Qwen/Qwen2.5-1.5B-Instruct", "AmareshHebbar/ToolSure_Qwen2.5_1.5B_ORPO"),
("stretch32k-sft", "long context sft", "TinyLlama/TinyLlama_v1.1", "AmareshHebbar/Stretch32K_TinyLlama_1.1B_SFT"),
("instruct-qwen2.5-0.5b", "instruction tuning", "Qwen/Qwen2.5-0.5B", "Qwen/Qwen2.5-0.5B-Instruct"),
]
BITNARROW = [
("bitnarrow-qwen7b", "weight edit", "Qwen/Qwen2.5-7B-Instruct", "qwen7b_narrow"),
("bitnarrow-llama8b", "weight edit", "meta-llama/Llama-3.1-8B-Instruct", "llama8b_narrow"),
]
def controls() -> list[dict]:
out = []
for s in range(3):
out.append({"name": f"null-identity-s{s}", "kind": "null identity", "control": {"kind": "identity", "seed": s}, "seed": s})
for s in range(3):
out.append({
"name": f"null-micro-noise-s{s}",
"kind": "null micro noise",
"control": {"kind": "noise", "strength": 0.0001, "seed": s},
"expect": "no_change",
"seed": s,
})
planted = [
("noise-0.10", {"kind": "noise", "strength": 0.10}),
("noise-0.20", {"kind": "noise", "strength": 0.20}),
("noise-0.40", {"kind": "noise", "strength": 0.40}),
("prune-0.30", {"kind": "prune", "strength": 0.30}),
("zero-last-mlp", {"kind": "zero", "match": r"layers\.23\.mlp\.down_proj\.weight$"}),
("scale-mlp-0.5", {"kind": "scale", "strength": 0.5, "match": r"mlp\.down_proj\.weight$"}),
]
for name, c in planted:
out.append({"name": f"planted-{name}", "kind": "planted " + c["kind"], "control": c})
for e in out:
e["base"] = CONTROL_BASE
return out
def main() -> None:
ap = argparse.ArgumentParser()
ap.add_argument("--out", default=str(HERE / "spec.yaml"))
ap.add_argument("--exports", default=os.environ.get("BITNARROW_EXPORTS", ""))
ap.add_argument("--no-real", action="store_true")
ap.add_argument("--smoke", action="store_true")
ap.add_argument("--dtype", default=os.environ.get("MD_DTYPE", "bfloat16"))
args = ap.parse_args()
audits = controls()
if args.smoke:
audits = [a for a in audits if a["name"] in ("null-micro-noise-s0", "planted-noise-0.40")]
if not args.no_real and not args.smoke:
for name, kind, base, deriv in REAL:
audits.append({"name": f"real-{name}", "kind": kind, "base": base, "derivative": deriv, "expect": "change"})
if args.exports:
for name, kind, base, folder in BITNARROW:
path = Path(args.exports) / folder
if path.exists():
audits.append({"name": f"real-{name}", "kind": kind, "base": base, "derivative": str(path), "expect": "change"})
spec = {
"out": "bench/results/audits",
"defaults": {"suite": "lite", "dtype": args.dtype, "seed": 0, "limit": 8 if args.smoke else None},
"audits": audits,
}
if spec["defaults"]["limit"] is None:
del spec["defaults"]["limit"]
Path(args.out).write_text(yaml.safe_dump(spec, sort_keys=False), encoding="utf-8")
print(f"{args.out}: {len(audits)} audits")
if __name__ == "__main__":
main()
|