Buckets:
| #!/usr/bin/env python3 | |
| """Create JSON/CSV/Markdown comparison including cache and arithmetic mean PPL.""" | |
| from __future__ import annotations | |
| import csv | |
| import json | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| EVAL = ROOT / "ppl-evals" | |
| MODELS = { | |
| "gqa": ("GQA", 98_710_016, 6144, 0), | |
| "cla4_h64": ("CLA4-h64", 98_759_168, 3072, 0), | |
| "roll16": ("Rolling-r16 no-refresh", 98_710_016, 1920, 0), | |
| "roll32": ("Rolling-r32 no-refresh", 99_430_912, 3328, 0), | |
| "roll16_refresh4": ("Rolling-r16 refresh4", 99_103_232, 2688, 0), | |
| "sharedproj_roll16_local128": ("SharedProj-r16-local128 (invalid backward)", 100_872_704, 1920, 786432), | |
| "sharedproj_roll32_local128": ("SharedProj-r32-local128 (invalid backward)", 100_872_704, 3328, 786432), | |
| } | |
| BENCHMARKS = ("c4", "fineweb_edu", "wikipedia", "pg19") | |
| CONTEXTS = ("2k", "8k", "32k") | |
| LENGTHS = {"2k": 2048, "8k": 8192, "32k": 32768} | |
| def result_path(model, benchmark): | |
| folder = "results_pg19" if benchmark == "pg19" else "results_mlra_10m" | |
| return EVAL / folder / f"{model}_{benchmark}.json" | |
| rows = [] | |
| for model, (label, parameters, per_token, local_fixed) in MODELS.items(): | |
| loaded = {benchmark: json.loads(result_path(model, benchmark).read_text()) | |
| for benchmark in BENCHMARKS} | |
| for context in CONTEXTS: | |
| task_ppl = {benchmark: loaded[benchmark]["results"][context]["ppl"] | |
| for benchmark in BENCHMARKS} | |
| cache_bytes = (per_token * LENGTHS[context] + local_fixed) * 2 | |
| rows.append({ | |
| "model": model, "label": label, "context": context, | |
| "parameters": parameters, "cache_elements_per_token": per_token, | |
| "local_ring_elements_per_sequence": local_fixed, | |
| "cache_mib_per_sequence": cache_bytes / 2**20, | |
| **{f"{key}_ppl": value for key, value in task_ppl.items()}, | |
| "mean_ppl": sum(task_ppl.values()) / len(task_ppl), | |
| }) | |
| gqa_by_context = {row["context"]: row for row in rows if row["model"] == "gqa"} | |
| for row in rows: | |
| baseline = gqa_by_context[row["context"]] | |
| row["mean_ppl_delta_percent_vs_gqa"] = ( | |
| (row["mean_ppl"] / baseline["mean_ppl"]) - 1.0 | |
| ) * 100.0 | |
| row["cache_savings_percent_vs_gqa"] = ( | |
| 1.0 - row["cache_mib_per_sequence"] / baseline["cache_mib_per_sequence"] | |
| ) * 100.0 | |
| out = EVAL / "results_rolling_sharedproj_comparison" | |
| out.mkdir(exist_ok=True) | |
| (out / "summary.json").write_text(json.dumps(rows, indent=2) + "\n") | |
| with (out / "summary.csv").open("w", newline="") as handle: | |
| writer = csv.DictWriter(handle, fieldnames=list(rows[0])) | |
| writer.writeheader(); writer.writerows(rows) | |
| lines = [ | |
| "# Rolling/shared-projection four-task perplexity comparison", "", | |
| "All PPL values use each model's final 32K checkpoint and matched fixed-token prefixes. " | |
| "Mean is the unweighted arithmetic mean over C4, FineWeb-Edu, Wikipedia and PG-19. " | |
| "Cache is theoretical BF16 persistent inference cache for one sequence. ", | |
| "SharedProj rows are retained as historical failed-run results only: their training kernel had a now-identified missing cross-branch Q/K gradient and they are not a valid architecture comparison.", "", | |
| "| Model | Context | Params | Cache MiB | Cache saved vs GQA | C4 | FineWeb-Edu | Wikipedia | PG-19 | Mean | Mean PPL vs GQA |", | |
| "|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|", | |
| ] | |
| for row in rows: | |
| lines.append( | |
| f"| {row['label']} | {row['context']} | {row['parameters']:,} | " | |
| f"{row['cache_mib_per_sequence']:.2f} | {row['cache_savings_percent_vs_gqa']:+.2f}% | " | |
| f"{row['c4_ppl']:.5f} | " | |
| f"{row['fineweb_edu_ppl']:.5f} | {row['wikipedia_ppl']:.5f} | " | |
| f"{row['pg19_ppl']:.5f} | {row['mean_ppl']:.5f} | " | |
| f"{row['mean_ppl_delta_percent_vs_gqa']:+.3f}% |" | |
| ) | |
| (out / "summary.md").write_text("\n".join(lines) + "\n") | |
| print(out / "summary.md") | |
Xet Storage Details
- Size:
- 3.93 kB
- Xet hash:
- 5cd577cfe76a3239ed8911950698b3624b61bf354d7038170e7e72f2f4a12fbd
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.