Datasets:
Rebuild: smoke-all + layer filter fix
Browse files- kit_manifest.json +5 -4
- scripts/build_kit.py +1 -0
- scripts/make_smoke_specs.py +88 -0
- scripts/rht_int4_convert.py +18 -2
- scripts/run_lane.py +2 -0
kit_manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
-
"built_from_commit": "
|
| 3 |
"files": {
|
| 4 |
-
"scripts/rht_int4_convert.py": "
|
| 5 |
"scripts/rewrite_lalamo_hybrid_spec.py": "154564c88391f81b5c24f64125d99abc15d81bd082a8264e36d43a00d4c47a04",
|
| 6 |
"scripts/normalize_lalamo_config.py": "248a5a07d0829c9e383eeba1a5204e88abdc065f78737d1191d376a1f37476c4",
|
| 7 |
"scripts/make_lalamo_eval_copy.py": "5563e8542ef51e57cc6ed5cff48fcc81d58fb6487d75350df8273cfad948a500",
|
|
@@ -11,8 +11,9 @@
|
|
| 11 |
"scripts/eval_quantized.py": "703904d36ff9f096aa2d7cfbad420318908834b34c2890d10e85aa05fb4fdd28",
|
| 12 |
"scripts/qad_finetune.py": "26830bf55203a6a2e7fd79451c400949a1f6cdd1fc8d4011b62ff59d39c6e486",
|
| 13 |
"scripts/compute_bpc.py": "2b55fd1df406d54b40daeeca2ecaf2efb35981655f5bf5e0cc10c057ce796256",
|
| 14 |
-
"scripts/run_lane.py": "
|
| 15 |
"scripts/make_sweep_spec.py": "dc31ec026c89e7db316a185575a4423bca988c2ac6cf08ef6df8f955328cda69",
|
|
|
|
| 16 |
"scripts/combine_lane_manifests.py": "164ba691d60b3e2987b805426c606d135dcf3cf0c855b38cf7f5d6d57628a481",
|
| 17 |
"scripts/make_qad_dataset.py": "c8ca660ffe781e066fdf3c9bfce2fdf2af40bef13160519fdc6f1410f740a72d",
|
| 18 |
"scripts/ag_fetch.py": "2d13b52f5f41a84c61d196a0eaaf35f2d03b39e45b4379d80adb7e84c451ef7f",
|
|
@@ -27,7 +28,7 @@
|
|
| 27 |
"scripts/check_docs.py": "e867ccced2e240fadd9a467dcca018e0d668c5e92ddccaeb4f9f936252f7883d",
|
| 28 |
"scripts/tiny_sharding_probe.py": "29eb58f2689242b919616f6aab6ff753e0de031b16371137975b4d645e836fae",
|
| 29 |
"scripts/audit_public_corpus.py": "84f1ec805a74004e71f63a70a8ed19967cb3fad9966f254798e655ab95e53ab0",
|
| 30 |
-
"scripts/build_kit.py": "
|
| 31 |
"scripts/bootstrap_kaggle.py": "1633e3edbb80976c337444e3e4544e2b5210b2d8d1821e3a2717c1099c00843e",
|
| 32 |
"data/calibration_en_wikitext2_dedup.txt": "18a79f4f938cc25747a90a12b120c7131e7f4ac55b58dfc691795ea61d4b5e9a",
|
| 33 |
"data/calibration_ja_wikipedia_dedup.txt": "b45e3f3f00f2137be280a75c1fa9c9883a7e69d289257c4388fc701f33fee0d1",
|
|
|
|
| 1 |
{
|
| 2 |
+
"built_from_commit": "73d54d05a6711a90648643369a7f365b101c0d91",
|
| 3 |
"files": {
|
| 4 |
+
"scripts/rht_int4_convert.py": "add2a584ad9e0d586bfaa16230b19491c580f9e7a11a7aac5fdfb4972e1eca9d",
|
| 5 |
"scripts/rewrite_lalamo_hybrid_spec.py": "154564c88391f81b5c24f64125d99abc15d81bd082a8264e36d43a00d4c47a04",
|
| 6 |
"scripts/normalize_lalamo_config.py": "248a5a07d0829c9e383eeba1a5204e88abdc065f78737d1191d376a1f37476c4",
|
| 7 |
"scripts/make_lalamo_eval_copy.py": "5563e8542ef51e57cc6ed5cff48fcc81d58fb6487d75350df8273cfad948a500",
|
|
|
|
| 11 |
"scripts/eval_quantized.py": "703904d36ff9f096aa2d7cfbad420318908834b34c2890d10e85aa05fb4fdd28",
|
| 12 |
"scripts/qad_finetune.py": "26830bf55203a6a2e7fd79451c400949a1f6cdd1fc8d4011b62ff59d39c6e486",
|
| 13 |
"scripts/compute_bpc.py": "2b55fd1df406d54b40daeeca2ecaf2efb35981655f5bf5e0cc10c057ce796256",
|
| 14 |
+
"scripts/run_lane.py": "e3b3bfebbf8955a0bdf7447c564d9b3ecc388d5afb2777096e091578d3ca3513",
|
| 15 |
"scripts/make_sweep_spec.py": "dc31ec026c89e7db316a185575a4423bca988c2ac6cf08ef6df8f955328cda69",
|
| 16 |
+
"scripts/make_smoke_specs.py": "824400dc0d85c9ebd360b10ed4f7056938a1915efd5da6f1a5ac3fb33eb7e998",
|
| 17 |
"scripts/combine_lane_manifests.py": "164ba691d60b3e2987b805426c606d135dcf3cf0c855b38cf7f5d6d57628a481",
|
| 18 |
"scripts/make_qad_dataset.py": "c8ca660ffe781e066fdf3c9bfce2fdf2af40bef13160519fdc6f1410f740a72d",
|
| 19 |
"scripts/ag_fetch.py": "2d13b52f5f41a84c61d196a0eaaf35f2d03b39e45b4379d80adb7e84c451ef7f",
|
|
|
|
| 28 |
"scripts/check_docs.py": "e867ccced2e240fadd9a467dcca018e0d668c5e92ddccaeb4f9f936252f7883d",
|
| 29 |
"scripts/tiny_sharding_probe.py": "29eb58f2689242b919616f6aab6ff753e0de031b16371137975b4d645e836fae",
|
| 30 |
"scripts/audit_public_corpus.py": "84f1ec805a74004e71f63a70a8ed19967cb3fad9966f254798e655ab95e53ab0",
|
| 31 |
+
"scripts/build_kit.py": "eaa35d13bbd3f7525e9d52302d1acd2257a9a5e8cc2dd552da33dc8ed45c19e9",
|
| 32 |
"scripts/bootstrap_kaggle.py": "1633e3edbb80976c337444e3e4544e2b5210b2d8d1821e3a2717c1099c00843e",
|
| 33 |
"data/calibration_en_wikitext2_dedup.txt": "18a79f4f938cc25747a90a12b120c7131e7f4ac55b58dfc691795ea61d4b5e9a",
|
| 34 |
"data/calibration_ja_wikipedia_dedup.txt": "b45e3f3f00f2137be280a75c1fa9c9883a7e69d289257c4388fc701f33fee0d1",
|
scripts/build_kit.py
CHANGED
|
@@ -44,6 +44,7 @@ KIT_SCRIPTS = [
|
|
| 44 |
"compute_bpc.py",
|
| 45 |
"run_lane.py",
|
| 46 |
"make_sweep_spec.py",
|
|
|
|
| 47 |
"combine_lane_manifests.py",
|
| 48 |
"make_qad_dataset.py",
|
| 49 |
"ag_fetch.py",
|
|
|
|
| 44 |
"compute_bpc.py",
|
| 45 |
"run_lane.py",
|
| 46 |
"make_sweep_spec.py",
|
| 47 |
+
"make_smoke_specs.py",
|
| 48 |
"combine_lane_manifests.py",
|
| 49 |
"make_qad_dataset.py",
|
| 50 |
"ag_fetch.py",
|
scripts/make_smoke_specs.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Derive tiny smoke specs from the real lane specs.
|
| 3 |
+
|
| 4 |
+
A full lane takes hours; a broken flag, missing file, or merge mismatch shows up
|
| 5 |
+
in the first minutes. This shrinks every lane (samples 1, 32 tokens, 2 eval
|
| 6 |
+
chunks) so one CPU session can prove that all of them run end to end.
|
| 7 |
+
|
| 8 |
+
python scripts/make_smoke_specs.py --out-dir lanes
|
| 9 |
+
|
| 10 |
+
The generated files are named ``smoke-<lane>.json``. ``balanced-h`` keeps its
|
| 11 |
+
merge but only at ratio 0.5; robustness shards keep only the first two
|
| 12 |
+
conditions.
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
from __future__ import annotations
|
| 16 |
+
|
| 17 |
+
import argparse
|
| 18 |
+
import copy
|
| 19 |
+
import glob
|
| 20 |
+
import json
|
| 21 |
+
from pathlib import Path
|
| 22 |
+
|
| 23 |
+
DEFAULT_SKIP = {"smoke-08b"}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def shrink(spec: dict, robustness_limit: int) -> dict:
|
| 27 |
+
spec = copy.deepcopy(spec)
|
| 28 |
+
spec["lane"] = f"smoke-{spec['lane']}"
|
| 29 |
+
spec.setdefault("paths", {})["jax_platform"] = "cpu"
|
| 30 |
+
spec.setdefault("eval", {})["max_sequences"] = 2
|
| 31 |
+
spec["eval"]["max_tokens"] = 32
|
| 32 |
+
spec["eval"]["min_tokens"] = 4
|
| 33 |
+
spec["eval"]["dtype"] = "float32"
|
| 34 |
+
spec.setdefault("convert", {})["parallel"] = "replicated"
|
| 35 |
+
# quantize only layer 0 so a smoke conversion takes seconds, not ten minutes
|
| 36 |
+
spec["convert"]["layer_filter"] = "/[0]/"
|
| 37 |
+
|
| 38 |
+
is_robustness = "robustness" in spec["lane"]
|
| 39 |
+
conditions = spec.get("conditions", [])
|
| 40 |
+
if is_robustness:
|
| 41 |
+
conditions = conditions[:robustness_limit]
|
| 42 |
+
|
| 43 |
+
for condition in conditions:
|
| 44 |
+
condition["samples"] = 1
|
| 45 |
+
condition["max_tokens"] = 32
|
| 46 |
+
condition.setdefault("calib_dtype", "float32")
|
| 47 |
+
spec["conditions"] = conditions
|
| 48 |
+
|
| 49 |
+
merge = spec.get("merge")
|
| 50 |
+
if merge:
|
| 51 |
+
merge["ratios"] = [0.5]
|
| 52 |
+
return spec
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def main() -> None:
|
| 56 |
+
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 57 |
+
parser.add_argument("--lanes-dir", type=Path, default=Path("lanes"))
|
| 58 |
+
parser.add_argument("--out-dir", type=Path, default=Path("lanes"))
|
| 59 |
+
parser.add_argument("--robustness-limit", type=int, default=2)
|
| 60 |
+
parser.add_argument("--include", nargs="*", default=None)
|
| 61 |
+
parser.add_argument("--dry-run", action="store_true")
|
| 62 |
+
args = parser.parse_args()
|
| 63 |
+
|
| 64 |
+
written = []
|
| 65 |
+
for path in sorted(args.lanes_dir.glob("*.json")):
|
| 66 |
+
if path.name.startswith("smoke-") or path.stem in DEFAULT_SKIP:
|
| 67 |
+
continue
|
| 68 |
+
if args.include and path.stem not in args.include:
|
| 69 |
+
continue
|
| 70 |
+
if path.name == "bits-down-out-6.json":
|
| 71 |
+
continue
|
| 72 |
+
try:
|
| 73 |
+
spec = json.loads(path.read_text(encoding="utf-8"))
|
| 74 |
+
except json.JSONDecodeError:
|
| 75 |
+
continue
|
| 76 |
+
if "conditions" not in spec:
|
| 77 |
+
continue
|
| 78 |
+
smoke = shrink(spec, args.robustness_limit)
|
| 79 |
+
out = args.out_dir / f"{smoke['lane']}.json"
|
| 80 |
+
print(f"{path.name} -> {out.name} ({len(smoke['conditions'])} conditions)")
|
| 81 |
+
if not args.dry_run:
|
| 82 |
+
out.write_text(json.dumps(smoke, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
| 83 |
+
written.append(out.name)
|
| 84 |
+
print(f"{len(written)} smoke specs")
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
if __name__ == "__main__":
|
| 88 |
+
main()
|
scripts/rht_int4_convert.py
CHANGED
|
@@ -135,6 +135,13 @@ def find_spec(qwen_models, name: str):
|
|
| 135 |
raise ValueError(f"model spec {name!r} not found")
|
| 136 |
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
def resolve_bits(path: str, rules: list[dict], default: int) -> int:
|
| 139 |
"""First rule whose ``match`` substring appears in the layer path wins."""
|
| 140 |
for rule in rules:
|
|
@@ -292,7 +299,10 @@ def main() -> None:
|
|
| 292 |
hybrid_spec = build_hybrid_spec(args.bits)
|
| 293 |
layer_bits_used: dict[str, int] = {}
|
| 294 |
quantize_key = jax.random.key(0)
|
| 295 |
-
counts = {"quantized": 0, "skipped": 0, "yaqa": 0}
|
|
|
|
|
|
|
|
|
|
| 296 |
|
| 297 |
calibration = None
|
| 298 |
if args.preconditioners:
|
|
@@ -317,6 +327,9 @@ def main() -> None:
|
|
| 317 |
def quantize_linear(path, linear: Linear) -> Linear:
|
| 318 |
started = time.time()
|
| 319 |
key = "/".join(path)
|
|
|
|
|
|
|
|
|
|
| 320 |
shape = tuple(int(x) for x in linear.weights.shape)
|
| 321 |
if len(shape) != 2 or any(dimension % required_divisor for dimension in shape):
|
| 322 |
counts["skipped"] += 1
|
|
@@ -381,7 +394,10 @@ def main() -> None:
|
|
| 381 |
f"(symmetric=False)"
|
| 382 |
)
|
| 383 |
quantized_model = map_nodes_of_type_with_path(Linear, quantize_linear, model)
|
| 384 |
-
print(
|
|
|
|
|
|
|
|
|
|
| 385 |
if layer_bits_used:
|
| 386 |
distribution = {}
|
| 387 |
for bits in layer_bits_used.values():
|
|
|
|
| 135 |
raise ValueError(f"model spec {name!r} not found")
|
| 136 |
|
| 137 |
|
| 138 |
+
def should_quantize(path: str, filters: list[str]) -> bool:
|
| 139 |
+
"""Empty filters means everything; otherwise any substring match."""
|
| 140 |
+
if not filters:
|
| 141 |
+
return True
|
| 142 |
+
return any(item in path for item in filters)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
def resolve_bits(path: str, rules: list[dict], default: int) -> int:
|
| 146 |
"""First rule whose ``match`` substring appears in the layer path wins."""
|
| 147 |
for rule in rules:
|
|
|
|
| 299 |
hybrid_spec = build_hybrid_spec(args.bits)
|
| 300 |
layer_bits_used: dict[str, int] = {}
|
| 301 |
quantize_key = jax.random.key(0)
|
| 302 |
+
counts = {"quantized": 0, "skipped": 0, "yaqa": 0, "filtered": 0}
|
| 303 |
+
layer_filters = [item for item in (args.layer_filter or "").split(",") if item]
|
| 304 |
+
if layer_filters:
|
| 305 |
+
print(f"layer filter: {layer_filters} (other layers stay full precision)")
|
| 306 |
|
| 307 |
calibration = None
|
| 308 |
if args.preconditioners:
|
|
|
|
| 327 |
def quantize_linear(path, linear: Linear) -> Linear:
|
| 328 |
started = time.time()
|
| 329 |
key = "/".join(path)
|
| 330 |
+
if not should_quantize(key, layer_filters):
|
| 331 |
+
counts["filtered"] += 1
|
| 332 |
+
return linear
|
| 333 |
shape = tuple(int(x) for x in linear.weights.shape)
|
| 334 |
if len(shape) != 2 or any(dimension % required_divisor for dimension in shape):
|
| 335 |
counts["skipped"] += 1
|
|
|
|
| 394 |
f"(symmetric=False)"
|
| 395 |
)
|
| 396 |
quantized_model = map_nodes_of_type_with_path(Linear, quantize_linear, model)
|
| 397 |
+
print(
|
| 398 |
+
f"quantized: {counts['quantized']}, skipped: {counts['skipped']}, "
|
| 399 |
+
f"yaqa: {counts['yaqa']}, filtered: {counts['filtered']}"
|
| 400 |
+
)
|
| 401 |
if layer_bits_used:
|
| 402 |
distribution = {}
|
| 403 |
for bits in layer_bits_used.values():
|
scripts/run_lane.py
CHANGED
|
@@ -441,6 +441,8 @@ class Runner:
|
|
| 441 |
for key in ("bits", "group_size", "block_size", "parallel"):
|
| 442 |
if key in convert_settings:
|
| 443 |
convert_command += [f"--{key.replace('_', '-')}", str(convert_settings[key])]
|
|
|
|
|
|
|
| 444 |
if condition.get("layer_bits_json"):
|
| 445 |
bits_path = self.resolve(condition["layer_bits_json"])
|
| 446 |
assert bits_path is not None
|
|
|
|
| 441 |
for key in ("bits", "group_size", "block_size", "parallel"):
|
| 442 |
if key in convert_settings:
|
| 443 |
convert_command += [f"--{key.replace('_', '-')}", str(convert_settings[key])]
|
| 444 |
+
if convert_settings.get("layer_filter"):
|
| 445 |
+
convert_command += ["--layer-filter", str(convert_settings["layer_filter"])]
|
| 446 |
if condition.get("layer_bits_json"):
|
| 447 |
bits_path = self.resolve(condition["layer_bits_json"])
|
| 448 |
assert bits_path is not None
|