Record immutable benchmark revision in run manifests
Browse files- README.md +1 -0
- src/shiftedx_bench/cli.py +10 -0
- src/shiftedx_bench/model_card.py +7 -0
- tests/test_model_card.py +7 -0
README.md
CHANGED
|
@@ -91,6 +91,7 @@ Use the first-class quant gate for every candidate before spending hours on the
|
|
| 91 |
--model '<served-model-id>' \
|
| 92 |
--hf-repo '<owner/public-model-repo>' \
|
| 93 |
--hf-revision '<full-published-commit-sha>' \
|
|
|
|
| 94 |
--profile vision \
|
| 95 |
--label '<stable-candidate-label>' \
|
| 96 |
--output-dir 'results/<stable-candidate-label>'
|
|
|
|
| 91 |
--model '<served-model-id>' \
|
| 92 |
--hf-repo '<owner/public-model-repo>' \
|
| 93 |
--hf-revision '<full-published-commit-sha>' \
|
| 94 |
+
--benchmark-revision '<full-shiftedx-bench-commit-sha>' \
|
| 95 |
--profile vision \
|
| 96 |
--label '<stable-candidate-label>' \
|
| 97 |
--output-dir 'results/<stable-candidate-label>'
|
src/shiftedx_bench/cli.py
CHANGED
|
@@ -78,10 +78,17 @@ def _reasoning_request_overrides(args: argparse.Namespace) -> dict[str, Any]:
|
|
| 78 |
def _record_evaluated_artifact(manifest: dict[str, Any], args: argparse.Namespace) -> None:
|
| 79 |
repo_id = getattr(args, "hf_repo", None)
|
| 80 |
revision = getattr(args, "hf_revision", None)
|
|
|
|
| 81 |
if bool(repo_id) != bool(revision):
|
| 82 |
raise ValueError("--hf-repo and --hf-revision must be supplied together")
|
|
|
|
|
|
|
| 83 |
if repo_id:
|
| 84 |
manifest["evaluated_artifact"] = {"repo_id": repo_id, "revision": revision}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
|
| 87 |
def _validate_context_variant_profile(args: argparse.Namespace, variants: list[dict[str, Any]]) -> None:
|
|
@@ -229,6 +236,7 @@ def run_quant_gate(args: argparse.Namespace) -> None:
|
|
| 229 |
"model": args.model,
|
| 230 |
"hf_repo": args.hf_repo,
|
| 231 |
"hf_revision": args.hf_revision,
|
|
|
|
| 232 |
"api_key_env": args.api_key_env,
|
| 233 |
"timeout": args.timeout,
|
| 234 |
"variants": None,
|
|
@@ -280,6 +288,7 @@ def render_model_card(args: argparse.Namespace) -> None:
|
|
| 280 |
profile=args.profile,
|
| 281 |
model_repo=args.model_repo,
|
| 282 |
model_revision=args.model_revision,
|
|
|
|
| 283 |
)
|
| 284 |
block = render_benchmark_block(
|
| 285 |
rows,
|
|
@@ -398,6 +407,7 @@ def make_parser() -> argparse.ArgumentParser:
|
|
| 398 |
command.add_argument("--profile", choices=["vision", "text"], default="vision")
|
| 399 |
command.add_argument("--hf-repo", help="Published Hugging Face repo evaluated by this run")
|
| 400 |
command.add_argument("--hf-revision", help="Full immutable Hugging Face revision evaluated by this run")
|
|
|
|
| 401 |
command.set_defaults(func=run_quant_gate)
|
| 402 |
|
| 403 |
command = subparsers.add_parser("render-model-card")
|
|
|
|
| 78 |
def _record_evaluated_artifact(manifest: dict[str, Any], args: argparse.Namespace) -> None:
|
| 79 |
repo_id = getattr(args, "hf_repo", None)
|
| 80 |
revision = getattr(args, "hf_revision", None)
|
| 81 |
+
benchmark_revision = getattr(args, "benchmark_revision", None)
|
| 82 |
if bool(repo_id) != bool(revision):
|
| 83 |
raise ValueError("--hf-repo and --hf-revision must be supplied together")
|
| 84 |
+
if repo_id and not benchmark_revision:
|
| 85 |
+
raise ValueError("--benchmark-revision is required for a post-publication run")
|
| 86 |
if repo_id:
|
| 87 |
manifest["evaluated_artifact"] = {"repo_id": repo_id, "revision": revision}
|
| 88 |
+
manifest["benchmark_source"] = {
|
| 89 |
+
"repo_id": "Shiftedx/shiftedx-bench",
|
| 90 |
+
"revision": benchmark_revision,
|
| 91 |
+
}
|
| 92 |
|
| 93 |
|
| 94 |
def _validate_context_variant_profile(args: argparse.Namespace, variants: list[dict[str, Any]]) -> None:
|
|
|
|
| 236 |
"model": args.model,
|
| 237 |
"hf_repo": args.hf_repo,
|
| 238 |
"hf_revision": args.hf_revision,
|
| 239 |
+
"benchmark_revision": args.benchmark_revision,
|
| 240 |
"api_key_env": args.api_key_env,
|
| 241 |
"timeout": args.timeout,
|
| 242 |
"variants": None,
|
|
|
|
| 288 |
profile=args.profile,
|
| 289 |
model_repo=args.model_repo,
|
| 290 |
model_revision=args.model_revision,
|
| 291 |
+
benchmark_revision=args.benchmark_revision,
|
| 292 |
)
|
| 293 |
block = render_benchmark_block(
|
| 294 |
rows,
|
|
|
|
| 407 |
command.add_argument("--profile", choices=["vision", "text"], default="vision")
|
| 408 |
command.add_argument("--hf-repo", help="Published Hugging Face repo evaluated by this run")
|
| 409 |
command.add_argument("--hf-revision", help="Full immutable Hugging Face revision evaluated by this run")
|
| 410 |
+
command.add_argument("--benchmark-revision", help="Full immutable Shiftedx Bench revision used by this run")
|
| 411 |
command.set_defaults(func=run_quant_gate)
|
| 412 |
|
| 413 |
command = subparsers.add_parser("render-model-card")
|
src/shiftedx_bench/model_card.py
CHANGED
|
@@ -54,6 +54,7 @@ def validate_post_publish_run(
|
|
| 54 |
profile: str,
|
| 55 |
model_repo: str,
|
| 56 |
model_revision: str,
|
|
|
|
| 57 |
) -> tuple[list[dict[str, Any]], str]:
|
| 58 |
expected = EXPECTED_COUNTS[profile]
|
| 59 |
rows = [row for row in _load_rows(run_dir, expected) if str(row.get("variant")) == variant]
|
|
@@ -89,6 +90,12 @@ def validate_post_publish_run(
|
|
| 89 |
f"Post-publication provenance mismatch in {path.name}: "
|
| 90 |
f"expected {model_repo}@{model_revision}, found {artifact}"
|
| 91 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
if len(versions) != 1 or "None" in versions:
|
| 93 |
raise ValueError(f"Run manifests disagree on benchmark version: {sorted(versions)}")
|
| 94 |
return rows, versions.pop()
|
|
|
|
| 54 |
profile: str,
|
| 55 |
model_repo: str,
|
| 56 |
model_revision: str,
|
| 57 |
+
benchmark_revision: str,
|
| 58 |
) -> tuple[list[dict[str, Any]], str]:
|
| 59 |
expected = EXPECTED_COUNTS[profile]
|
| 60 |
rows = [row for row in _load_rows(run_dir, expected) if str(row.get("variant")) == variant]
|
|
|
|
| 90 |
f"Post-publication provenance mismatch in {path.name}: "
|
| 91 |
f"expected {model_repo}@{model_revision}, found {artifact}"
|
| 92 |
)
|
| 93 |
+
benchmark = manifest.get("benchmark_source") or {}
|
| 94 |
+
if benchmark.get("repo_id") != "Shiftedx/shiftedx-bench" or benchmark.get("revision") != benchmark_revision:
|
| 95 |
+
raise ValueError(
|
| 96 |
+
f"Benchmark provenance mismatch in {path.name}: expected "
|
| 97 |
+
f"Shiftedx/shiftedx-bench@{benchmark_revision}, found {benchmark}"
|
| 98 |
+
)
|
| 99 |
if len(versions) != 1 or "None" in versions:
|
| 100 |
raise ValueError(f"Run manifests disagree on benchmark version: {sorted(versions)}")
|
| 101 |
return rows, versions.pop()
|
tests/test_model_card.py
CHANGED
|
@@ -56,6 +56,10 @@ def _write_run(tmp_path, *, omit_lane=None):
|
|
| 56 |
"benchmark_version": "0.3.0",
|
| 57 |
"variants": [{"label": VARIANT, "request_overrides": {}}],
|
| 58 |
"evaluated_artifact": {"repo_id": MODEL_REPO, "revision": MODEL_REVISION},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
}
|
| 60 |
(tmp_path / f"{names[lane]}.manifest.json").write_text(json.dumps(manifest), encoding="utf-8")
|
| 61 |
|
|
@@ -68,6 +72,7 @@ def test_post_publish_model_card_block_is_complete_and_idempotent(tmp_path):
|
|
| 68 |
profile="vision",
|
| 69 |
model_repo=MODEL_REPO,
|
| 70 |
model_revision=MODEL_REVISION,
|
|
|
|
| 71 |
)
|
| 72 |
block = render_benchmark_block(
|
| 73 |
rows,
|
|
@@ -101,6 +106,7 @@ def test_model_card_export_rejects_incomplete_or_wrong_revision(tmp_path):
|
|
| 101 |
profile="vision",
|
| 102 |
model_repo=MODEL_REPO,
|
| 103 |
model_revision=MODEL_REVISION,
|
|
|
|
| 104 |
)
|
| 105 |
with pytest.raises(ValueError, match="provenance mismatch"):
|
| 106 |
validate_post_publish_run(
|
|
@@ -109,4 +115,5 @@ def test_model_card_export_rejects_incomplete_or_wrong_revision(tmp_path):
|
|
| 109 |
profile="text",
|
| 110 |
model_repo=MODEL_REPO,
|
| 111 |
model_revision="c" * 40,
|
|
|
|
| 112 |
)
|
|
|
|
| 56 |
"benchmark_version": "0.3.0",
|
| 57 |
"variants": [{"label": VARIANT, "request_overrides": {}}],
|
| 58 |
"evaluated_artifact": {"repo_id": MODEL_REPO, "revision": MODEL_REVISION},
|
| 59 |
+
"benchmark_source": {
|
| 60 |
+
"repo_id": "Shiftedx/shiftedx-bench",
|
| 61 |
+
"revision": BENCHMARK_REVISION,
|
| 62 |
+
},
|
| 63 |
}
|
| 64 |
(tmp_path / f"{names[lane]}.manifest.json").write_text(json.dumps(manifest), encoding="utf-8")
|
| 65 |
|
|
|
|
| 72 |
profile="vision",
|
| 73 |
model_repo=MODEL_REPO,
|
| 74 |
model_revision=MODEL_REVISION,
|
| 75 |
+
benchmark_revision=BENCHMARK_REVISION,
|
| 76 |
)
|
| 77 |
block = render_benchmark_block(
|
| 78 |
rows,
|
|
|
|
| 106 |
profile="vision",
|
| 107 |
model_repo=MODEL_REPO,
|
| 108 |
model_revision=MODEL_REVISION,
|
| 109 |
+
benchmark_revision=BENCHMARK_REVISION,
|
| 110 |
)
|
| 111 |
with pytest.raises(ValueError, match="provenance mismatch"):
|
| 112 |
validate_post_publish_run(
|
|
|
|
| 115 |
profile="text",
|
| 116 |
model_repo=MODEL_REPO,
|
| 117 |
model_revision="c" * 40,
|
| 118 |
+
benchmark_revision=BENCHMARK_REVISION,
|
| 119 |
)
|