fix: render unestablished effective context
Browse files- src/shiftedx_bench/model_card.py +8 -2
- tests/test_model_card.py +33 -0
src/shiftedx_bench/model_card.py
CHANGED
|
@@ -141,8 +141,14 @@ def render_benchmark_block(
|
|
| 141 |
f"{100 * float(card['accuracy']):.1f}% | {_format_float(card['mean_wall_s'])} s | "
|
| 142 |
f"{_format_float(card['mean_decode_tokens_per_second'])} tok/s | "
|
| 143 |
f"{_format_memory(card['max_active_memory_bytes'])} |"
|
| 144 |
-
|
| 145 |
lengths = ", ".join(f"{int(value):,}" for value in sorted(map(int, context["accuracy_by_length"])))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
total_wall = sum(float(row.get("telemetry", {}).get("wall_s") or 0) for row in rows)
|
| 147 |
lines.extend(
|
| 148 |
[
|
|
@@ -150,7 +156,7 @@ def render_benchmark_block(
|
|
| 150 |
f"- Tested model revision: [`{model_revision}`](https://huggingface.co/{model_repo}/tree/{model_revision})",
|
| 151 |
f"- Benchmark: [Shiftedx Bench v{benchmark_version}](https://huggingface.co/datasets/Shiftedx/shiftedx-bench/tree/{benchmark_revision})",
|
| 152 |
f"- Context lengths represented: {lengths} prompt tokens; effective tested context: "
|
| 153 |
-
f"{
|
| 154 |
f"- Runtime contract: {runtime}; KV cache `{kv_cache}`; MTP depth `{mtp_depth}`",
|
| 155 |
f"- Host: {host}",
|
| 156 |
f"- Total measured request wall time: {total_wall:.2f} seconds",
|
|
|
|
| 141 |
f"{100 * float(card['accuracy']):.1f}% | {_format_float(card['mean_wall_s'])} s | "
|
| 142 |
f"{_format_float(card['mean_decode_tokens_per_second'])} tok/s | "
|
| 143 |
f"{_format_memory(card['max_active_memory_bytes'])} |"
|
| 144 |
+
)
|
| 145 |
lengths = ", ".join(f"{int(value):,}" for value in sorted(map(int, context["accuracy_by_length"])))
|
| 146 |
+
effective_context = context.get("effective_context_length")
|
| 147 |
+
effective_context_text = (
|
| 148 |
+
f"{int(effective_context):,} tokens"
|
| 149 |
+
if effective_context is not None
|
| 150 |
+
else "not established at the benchmark's 90% threshold"
|
| 151 |
+
)
|
| 152 |
total_wall = sum(float(row.get("telemetry", {}).get("wall_s") or 0) for row in rows)
|
| 153 |
lines.extend(
|
| 154 |
[
|
|
|
|
| 156 |
f"- Tested model revision: [`{model_revision}`](https://huggingface.co/{model_repo}/tree/{model_revision})",
|
| 157 |
f"- Benchmark: [Shiftedx Bench v{benchmark_version}](https://huggingface.co/datasets/Shiftedx/shiftedx-bench/tree/{benchmark_revision})",
|
| 158 |
f"- Context lengths represented: {lengths} prompt tokens; effective tested context: "
|
| 159 |
+
f"{effective_context_text}",
|
| 160 |
f"- Runtime contract: {runtime}; KV cache `{kv_cache}`; MTP depth `{mtp_depth}`",
|
| 161 |
f"- Host: {host}",
|
| 162 |
f"- Total measured request wall time: {total_wall:.2f} seconds",
|
tests/test_model_card.py
CHANGED
|
@@ -117,3 +117,36 @@ def test_model_card_export_rejects_incomplete_or_wrong_revision(tmp_path):
|
|
| 117 |
model_revision="c" * 40,
|
| 118 |
benchmark_revision=BENCHMARK_REVISION,
|
| 119 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
model_revision="c" * 40,
|
| 118 |
benchmark_revision=BENCHMARK_REVISION,
|
| 119 |
)
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def test_model_card_renders_null_effective_context_as_not_established(tmp_path):
|
| 123 |
+
_write_run(tmp_path)
|
| 124 |
+
context_path = tmp_path / "context.jsonl"
|
| 125 |
+
rows = [json.loads(line) for line in context_path.read_text().splitlines()]
|
| 126 |
+
for row in rows:
|
| 127 |
+
row["passed"] = False
|
| 128 |
+
context_path.write_text(
|
| 129 |
+
"".join(json.dumps(row) + "\n" for row in rows), encoding="utf-8"
|
| 130 |
+
)
|
| 131 |
+
validated, version = validate_post_publish_run(
|
| 132 |
+
tmp_path,
|
| 133 |
+
variant=VARIANT,
|
| 134 |
+
profile="vision",
|
| 135 |
+
model_repo=MODEL_REPO,
|
| 136 |
+
model_revision=MODEL_REVISION,
|
| 137 |
+
benchmark_revision=BENCHMARK_REVISION,
|
| 138 |
+
)
|
| 139 |
+
block = render_benchmark_block(
|
| 140 |
+
validated,
|
| 141 |
+
variant=VARIANT,
|
| 142 |
+
model_repo=MODEL_REPO,
|
| 143 |
+
model_revision=MODEL_REVISION,
|
| 144 |
+
benchmark_revision=BENCHMARK_REVISION,
|
| 145 |
+
benchmark_version=version,
|
| 146 |
+
host="Apple Silicon, 64 GiB",
|
| 147 |
+
runtime="MTPLX 2.7.1",
|
| 148 |
+
kv_cache="off",
|
| 149 |
+
mtp_depth="2",
|
| 150 |
+
max_window_status="not-run",
|
| 151 |
+
)
|
| 152 |
+
assert "effective tested context: not established at the benchmark's 90% threshold" in block
|