Skip to content

Commit 7c5bc55

Browse files
Ronald Tseronaldtse
authored andcommitted
feat(export): --dump-positions on the margins entrypoint
Feeds TODO.training-work/05: the shipped-vs-head32 flip bootstrap needs per-pair dumps for both artifacts of each family. Writes {mid}-positions-{precision}.jsonl beside the margins JSON.
1 parent cb8902d commit 7c5bc55

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/gpu/modal_export.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def stage(event: str) -> None:
347347
timeout=5 * 3600,
348348
volumes={**CHECKPOINT_VOLUMES, **DATASET_VOLUMES, "/outputs": MODELS_VOLUME},
349349
)
350-
def margin_model(model_id: str, precisions: list[str], limit: int = 0) -> dict[str, str]:
350+
def margin_model(model_id: str, precisions: list[str], limit: int = 0, dump_positions: bool = False) -> dict[str, str]:
351351
"""Margin analysis alone over already-exported zips — read-only for the
352352
zips (diagnostic JSON only); validates published artifacts without
353353
touching their metadata."""
@@ -376,7 +376,8 @@ def margin_model(model_id: str, precisions: list[str], limit: int = 0) -> dict[s
376376
if not zip_path.exists():
377377
reports[precision] = "zip not exported (skipped)"
378378
continue
379-
report = run_margin_analysis(model, zip_path, pairs, max_len=128)
379+
dump = out_dir / f"{mid}-positions-{precision}.jsonl" if dump_positions else None
380+
report = run_margin_analysis(model, zip_path, pairs, max_len=128, dump_positions=dump)
380381
write_margin_report(report, out_dir / f"{mid}-margins-{precision}.json")
381382
reports[precision] = (
382383
f"samples={report.samples} tokens={report.tokens} "
@@ -404,8 +405,8 @@ def parity(model: str, precisions: str = "fp32,fp16,int8", limit: int = 0) -> No
404405

405406

406407
@app.local_entrypoint()
407-
def margins(model: str, precisions: str = "fp32,fp16,int8", limit: int = 0) -> None:
408-
reports = margin_model.remote(model, precisions.split(","), limit)
408+
def margins(model: str, precisions: str = "fp32,fp16,int8", limit: int = 0, dump_positions: bool = False) -> None:
409+
reports = margin_model.remote(model, precisions.split(","), limit, dump_positions)
409410
for precision, status in reports.items():
410411
print(f"{model} [{precision}] {status}")
411412

0 commit comments

Comments
 (0)