Buckets:
| #!/usr/bin/env python3 | |
| """Parse tree-v2 run logs for placeholder leakage and related signals. | |
| This is intentionally dependency-free so agents can run it against downloaded | |
| HF bucket job logs without setting up the benchmark environment. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import re | |
| import sys | |
| from pathlib import Path | |
| from typing import Any | |
| STATS_RE = re.compile( | |
| r"\[tree-v2\] stats steps=(?P<steps>\d+) " | |
| r"tok/step=(?P<tok>[0-9.]+) salvages=(?P<salvages>\d+) " | |
| r"full=(?P<full>\d+) attn_py_calls/step=(?P<attn>[0-9.]+)" | |
| ) | |
| SCHED_RE = re.compile(r"scheduled_spec_decode_tokens=\{[^:]+: \[(?P<body>[^\]]*)\]\}") | |
| def _parse_int_list(body: str) -> list[int]: | |
| values: list[int] = [] | |
| for part in body.split(","): | |
| part = part.strip() | |
| if not part: | |
| continue | |
| values.append(int(part)) | |
| return values | |
| def analyze_log(path: Path) -> dict[str, Any]: | |
| stats: list[dict[str, Any]] = [] | |
| scheduler_dumps: list[dict[str, Any]] = [] | |
| signals = { | |
| "star_reject_prewarmed": False, | |
| "star_attention_cache_built": 0, | |
| "direct_reject_fallback": 0, | |
| "cuda_illegal_access": 0, | |
| "graph_capture_29": False, | |
| } | |
| with path.open("r", encoding="utf-8", errors="replace") as handle: | |
| for line_no, line in enumerate(handle, start=1): | |
| if "star rejection prewarmed" in line: | |
| signals["star_reject_prewarmed"] = True | |
| if "star attention layer-cache built" in line: | |
| signals["star_attention_cache_built"] += 1 | |
| if "[pupa-directreject] falling back" in line: | |
| signals["direct_reject_fallback"] += 1 | |
| if "illegal memory access" in line: | |
| signals["cuda_illegal_access"] += 1 | |
| if "Profiling CUDA graph memory" in line and "largest=29" in line: | |
| signals["graph_capture_29"] = True | |
| match = STATS_RE.search(line) | |
| if match: | |
| stats.append( | |
| { | |
| "line": line_no, | |
| "steps": int(match.group("steps")), | |
| "tok_per_step": float(match.group("tok")), | |
| "salvages": int(match.group("salvages")), | |
| "full_accepts": int(match.group("full")), | |
| "attn_py_calls_per_step": float(match.group("attn")), | |
| } | |
| ) | |
| match = SCHED_RE.search(line) | |
| if match: | |
| tokens = _parse_int_list(match.group("body")) | |
| negatives = sum(1 for token in tokens if token < 0) | |
| scheduler_dumps.append( | |
| { | |
| "line": line_no, | |
| "count": len(tokens), | |
| "negatives": negatives, | |
| "all_negative": bool(tokens) and negatives == len(tokens), | |
| "head": tokens[:8], | |
| } | |
| ) | |
| last_stats = stats[-1] if stats else None | |
| return { | |
| "log": str(path), | |
| "signals": signals, | |
| "last_tree_stats": last_stats, | |
| "num_tree_stats": len(stats), | |
| "scheduler_dumps": scheduler_dumps, | |
| "placeholder_leak_suspected": any( | |
| dump["all_negative"] and dump["count"] > 0 for dump in scheduler_dumps | |
| ), | |
| } | |
| def print_human(report: dict[str, Any]) -> None: | |
| print(f"log: {report['log']}") | |
| print(f"placeholder_leak_suspected: {report['placeholder_leak_suspected']}") | |
| signals = report["signals"] | |
| print("signals:") | |
| for key in sorted(signals): | |
| print(f" {key}: {signals[key]}") | |
| if report["last_tree_stats"]: | |
| stats = report["last_tree_stats"] | |
| print("last_tree_stats:") | |
| print( | |
| " steps={steps} tok/step={tok_per_step:.3f} " | |
| "salvages={salvages} full={full_accepts} " | |
| "attn_py_calls/step={attn_py_calls_per_step:.1f}".format(**stats) | |
| ) | |
| print(f"scheduler_dumps: {len(report['scheduler_dumps'])}") | |
| for dump in report["scheduler_dumps"]: | |
| print( | |
| " line={line} count={count} negatives={negatives} " | |
| "all_negative={all_negative} head={head}".format(**dump) | |
| ) | |
| def main(argv: list[str] | None = None) -> int: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("job_logs", type=Path) | |
| parser.add_argument("--json", action="store_true") | |
| args = parser.parse_args(argv) | |
| if not args.job_logs.exists(): | |
| print(f"missing log file: {args.job_logs}", file=sys.stderr) | |
| return 2 | |
| report = analyze_log(args.job_logs) | |
| if args.json: | |
| print(json.dumps(report, indent=2, sort_keys=True)) | |
| else: | |
| print_human(report) | |
| return 1 if report["placeholder_leak_suspected"] else 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |
Xet Storage Details
- Size:
- 4.91 kB
- Xet hash:
- a2df10d61ca3c0c75efb0788e792ca7d1d8211471ffd50981123df15bb2de688
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.