crit-eval 0.7.3__tar.gz → 0.8.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {crit_eval-0.7.3 → crit_eval-0.8.2}/PKG-INFO +7 -5
- {crit_eval-0.7.3 → crit_eval-0.8.2}/README.md +4 -3
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/__init__.py +8 -1
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/cli.py +6 -5
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/limits/ceiling.py +18 -7
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/limits/context.py +28 -13
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/limits/headroom.py +74 -18
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/limits/schemes.py +19 -1
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/protocol.json +26 -15
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/quality/attention.py +28 -6
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/quality/fixed.py +2 -2
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/quality/packages.py +2 -2
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/quality/prepare.py +38 -5
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/quality/reference.py +188 -25
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/reports/compare.py +3 -1
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/reports/metrics.py +12 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/reports/status.py +117 -34
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/chat.py +53 -15
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/concurrency.py +69 -15
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/estimate.py +3 -1
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/journal.py +18 -2
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/long_context.py +82 -17
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/precheck.py +30 -7
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/quality_checks.py +66 -14
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/runner.py +43 -16
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/speed.py +157 -117
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/timing.py +11 -7
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/long.json +5 -5
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval.egg-info/PKG-INFO +7 -5
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval.egg-info/SOURCES.txt +5 -1
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval.egg-info/requires.txt +2 -1
- {crit_eval-0.7.3 → crit_eval-0.8.2}/pyproject.toml +8 -5
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval.py +259 -19
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_concurrency.py +15 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_estimate.py +2 -1
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_followup.py +20 -2
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_gguf_gemma4.py +353 -353
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_precheck_lower.py +13 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_quality_modes.py +43 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_server.py +36 -9
- crit_eval-0.8.2/tests/test_prepare_paired.py +33 -0
- crit_eval-0.8.2/tests/test_reference_called.py +30 -0
- crit_eval-0.8.2/tests/test_retrieval_thinking.py +33 -0
- crit_eval-0.8.2/tests/test_unmeasurable.py +36 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/LICENSE +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/__main__.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/architectures/__init__.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/architectures/gguf_config.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/architectures/gguf_deepseek4.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/architectures/gguf_gemma4.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/architectures/gguf_layout.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/architectures/gguf_qwen4exp.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/architectures/indexers.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/architectures/templates/deepseek-v4.jinja +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/examples/mock_adapter.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/limits/__init__.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/limits/batched.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/limits/devices.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/limits/kernels.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/limits/probe.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/limits/tensors.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/limits/tiers.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/probe/device_probe.cu +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/probe/device_probe_hip.cpp +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/probe/kernel_trace.cpp +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/probe/kernel_trace_rocm.cpp +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/probe/logprob_compare.cu +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/probe/logprob_compare.h +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/quality/__init__.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/quality/checkpoints.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/quality/logprob.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/quality/prompt_state.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/reports/__init__.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/__init__.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/ab.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/adapters.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/deadline.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/energy.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/forks.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/history.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/host.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/hostload.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/jitter.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/outcomes.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/pin.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/stages.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/tool_calls.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/run/tracks.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/agent/README.md.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/agent/cli.py.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/agent/headroom.py.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/agent/metrics.py.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/agent/prepare.py.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/agent/reference.py.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/agent/report.py.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/agent/runner.py.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/agent/tools.json +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/followup.json +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/heldout.json +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/long_document.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/quality.json +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/suite/speed.json +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/workbench/__init__.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval/workbench/harness.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval.egg-info/dependency_links.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval.egg-info/entry_points.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/crit_eval.egg-info/top_level.txt +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/setup.cfg +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_chat_template.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_deadline.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_deepseek4_template.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_devices.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_distributions.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_energy.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_exl3.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_forks.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_formats.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_gguf.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_gguf_deepseek4.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_gguf_qwen4exp.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_indexers.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_jitter.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_journal.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_kernels.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_packages.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_settings.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_stages.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_tensors.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_tiers.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_tracks.py +0 -0
- {crit_eval-0.7.3 → crit_eval-0.8.2}/tests/test_eval_workbench.py +0 -0
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crit-eval
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.2
|
|
4
4
|
Summary: crit-eval: one speed, quality and exactness suite that every inference engine runs the same way
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Repository, https://github.com/crit-labs/crit-eval
|
|
7
7
|
Requires-Python: >=3.11
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
|
-
Requires-Dist: crit-core>=0.
|
|
10
|
+
Requires-Dist: crit-core>=0.24.0
|
|
11
|
+
Requires-Dist: crit-models>=0.24.0
|
|
11
12
|
Provides-Extra: reference
|
|
12
13
|
Requires-Dist: torch; extra == "reference"
|
|
13
14
|
Requires-Dist: transformers>=5.20; extra == "reference"
|
|
@@ -55,7 +56,8 @@ Dynamic: license-file
|
|
|
55
56
|
## Quick start
|
|
56
57
|
|
|
57
58
|
```sh
|
|
58
|
-
python -m pip install "crit-core @ git+https://github.com/crit-labs/crit#subdirectory=core/python"
|
|
59
|
+
python -m pip install "crit-core @ git+https://github.com/crit-labs/crit#subdirectory=inference/core/python"
|
|
60
|
+
python -m pip install "crit-models @ git+https://github.com/crit-labs/crit#subdirectory=models/core/python"
|
|
59
61
|
python -m pip install "crit-eval[reference] @ git+https://github.com/crit-labs/crit-eval"
|
|
60
62
|
```
|
|
61
63
|
|
|
@@ -103,8 +105,8 @@ with `--package DIR`, through Core's own adapter; another engine without a serve
|
|
|
103
105
|
|
|
104
106
|
| KPI or record | In the result | What it records |
|
|
105
107
|
| --- | --- | --- |
|
|
106
|
-
| **
|
|
107
|
-
|
|
|
108
|
+
| **decode_sampled** | `status.kpis.decode_sampled` | Decode tokens per second at the model's own sampling, the decode speed, and tokens per round for speculative engines; one seed per case (`--adaptive-sampled` repeats a case at further seeds, up to 9, until its standard error is within 3%), and each case's error is reported when it has more than one. Without a sampled suite (an engine that cannot sample, a run that skipped it) it is null and decode is unmeasured |
|
|
109
|
+
| decode_greedy | `status.kpis.decode_greedy` | Greedy decode over the same six workloads (chat, code, math, tool calls, a long document, a 14K-token agent session), the text exactness and the repeat checks compare; labelled `comparison_only`: a greedy decode is never a speed and sets no goal |
|
|
108
110
|
| **prefill** | `status.kpis.prefill` | Prompt tokens per second on the two long prompts |
|
|
109
111
|
| **ttft** | `status.kpis.ttft` | Milliseconds to the first token over every workload |
|
|
110
112
|
| **long-context decode and ttft** | `status.kpis.context` | The same scores along a curve of prompts up to the required context (200,000 tokens by default; the required context itself on a certified run) |
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
## Quick start
|
|
39
39
|
|
|
40
40
|
```sh
|
|
41
|
-
python -m pip install "crit-core @ git+https://github.com/crit-labs/crit#subdirectory=core/python"
|
|
41
|
+
python -m pip install "crit-core @ git+https://github.com/crit-labs/crit#subdirectory=inference/core/python"
|
|
42
|
+
python -m pip install "crit-models @ git+https://github.com/crit-labs/crit#subdirectory=models/core/python"
|
|
42
43
|
python -m pip install "crit-eval[reference] @ git+https://github.com/crit-labs/crit-eval"
|
|
43
44
|
```
|
|
44
45
|
|
|
@@ -86,8 +87,8 @@ with `--package DIR`, through Core's own adapter; another engine without a serve
|
|
|
86
87
|
|
|
87
88
|
| KPI or record | In the result | What it records |
|
|
88
89
|
| --- | --- | --- |
|
|
89
|
-
| **
|
|
90
|
-
|
|
|
90
|
+
| **decode_sampled** | `status.kpis.decode_sampled` | Decode tokens per second at the model's own sampling, the decode speed, and tokens per round for speculative engines; one seed per case (`--adaptive-sampled` repeats a case at further seeds, up to 9, until its standard error is within 3%), and each case's error is reported when it has more than one. Without a sampled suite (an engine that cannot sample, a run that skipped it) it is null and decode is unmeasured |
|
|
91
|
+
| decode_greedy | `status.kpis.decode_greedy` | Greedy decode over the same six workloads (chat, code, math, tool calls, a long document, a 14K-token agent session), the text exactness and the repeat checks compare; labelled `comparison_only`: a greedy decode is never a speed and sets no goal |
|
|
91
92
|
| **prefill** | `status.kpis.prefill` | Prompt tokens per second on the two long prompts |
|
|
92
93
|
| **ttft** | `status.kpis.ttft` | Milliseconds to the first token over every workload |
|
|
93
94
|
| **long-context decode and ttft** | `status.kpis.context` | The same scores along a curve of prompts up to the required context (200,000 tokens by default; the required context itself on a certified run) |
|
|
@@ -18,7 +18,7 @@ if _registry is not None:
|
|
|
18
18
|
# The package holds its suite, protocol, probes and examples; a checkout of crit-eval is its parent.
|
|
19
19
|
EVAL_DIR = Path(__file__).resolve().parent
|
|
20
20
|
SUITE_DIR = EVAL_DIR / "suite"
|
|
21
|
-
__version__ = "0.
|
|
21
|
+
__version__ = "0.8.2"
|
|
22
22
|
CONTRACT = "eval-v1"
|
|
23
23
|
PROTOCOL_ID = re.compile(r"crit-eval-v(\d+)\.(\d+)\.(\d+)")
|
|
24
24
|
# The ids before crit-eval had its own repository (crit-eval-v4, crit-eval-v4.1, ... crit-eval-v8): major and minor.
|
|
@@ -37,6 +37,13 @@ def protocol_version(identifier):
|
|
|
37
37
|
raise ValueError(f"not a crit-eval protocol id: {identifier}")
|
|
38
38
|
|
|
39
39
|
|
|
40
|
+
def prefill_cases(protocol, unmeasurable=None):
|
|
41
|
+
"""The protocol's prefill cases a run scores prefill over: its speed.prefill_cases but those the prepared data
|
|
42
|
+
records as not measurable for the model (unmeasurable: {case id: why}, prepare's speed_unmeasurable)."""
|
|
43
|
+
skip = unmeasurable or {}
|
|
44
|
+
return [case for case in protocol["speed"].get("prefill_cases", []) if case not in skip]
|
|
45
|
+
|
|
46
|
+
|
|
40
47
|
def protocol_series(identifier):
|
|
41
48
|
"""What two protocols share when their scores compare and data prepared under one runs under the other: the minor
|
|
42
49
|
version before 1.0 (crit-eval-v0.1.x), the major from 1.0 on; an earlier id's major (docs/README.md)."""
|
|
@@ -248,10 +248,11 @@ def main(argv=None):
|
|
|
248
248
|
"transformers, GPU; stop any engine first)")
|
|
249
249
|
reference.add_argument("--model", required=True, help="The checkpoint the data was prepared from")
|
|
250
250
|
reference.add_argument("--data", required=True, help="Prepared suite directory")
|
|
251
|
-
reference.add_argument("--allowance", action=
|
|
252
|
-
help="
|
|
253
|
-
"store how far that lands from the scores (allowance.json):
|
|
254
|
-
"costs,
|
|
251
|
+
reference.add_argument("--allowance", action=argparse.BooleanOptionalAction, default=True,
|
|
252
|
+
help="When the checkpoint declares quantized activations, also score the texts with them "
|
|
253
|
+
"quantized as declared and store how far that lands from the scores (allowance.json): "
|
|
254
|
+
"what the format itself costs, which speed mode's limits are raised to twice of; a "
|
|
255
|
+
"second scoring pass, on by default (--no-allowance skips it)")
|
|
255
256
|
|
|
256
257
|
fetch = subs.add_parser("fetch", help="Fetch the checkpoint's reference package (prepared data and reference "
|
|
257
258
|
"scores) into the data, so a run needs only the engine")
|
|
@@ -405,7 +406,7 @@ def _command(args):
|
|
|
405
406
|
+ (f"; the reference's own spread {how['spread']}" if how.get("spread") else "")
|
|
406
407
|
+ {"none": "; the checkpoint declares no quantized activations: no allowance to measure",
|
|
407
408
|
"unsupported": "; the allowance not measured (see above)"}.get(
|
|
408
|
-
how.get("allowance"), f"; the allowance (what the declared activation format costs,
|
|
409
|
+
how.get("allowance"), f"; the allowance (what the declared activation format costs, judged by in speed) "
|
|
409
410
|
f"{how['allowance']}" if how.get("allowance") else ""))
|
|
410
411
|
return 0
|
|
411
412
|
if args.command == "fetch":
|
|
@@ -18,7 +18,8 @@ the same rate), its MXFP4 and NVFP4 at the nvfp4 rate and its F32/F16/BF16 at bf
|
|
|
18
18
|
(gathered), vision towers, norms, convolutions and the output head (one row of logits per
|
|
19
19
|
prompt) are left out. Engines may compute in other formats; the floor uses the stored ones, and
|
|
20
20
|
prefill_floor_ms prices the quantized matrices with other prompt activations on request (ACTIVATIONS:
|
|
21
|
-
BF16, FP16 accumulation, FP8),
|
|
21
|
+
BF16, FP16 accumulation, FP8), and the 16-bit ones re-encoded to FP8 (W8A8 at the FP8 rate, REENCODED), as
|
|
22
|
+
crit_eval.limits.headroom.activation_ceilings reports them.
|
|
22
23
|
|
|
23
24
|
Time to first token cannot beat either floor: the prompt's arithmetic, or reading the weights
|
|
24
25
|
once (language-model tensors and the output head, not embeddings, vision or draft layers)
|
|
@@ -28,6 +29,7 @@ import math
|
|
|
28
29
|
import os
|
|
29
30
|
|
|
30
31
|
from crit_core.model import open_model, parse_model_config
|
|
32
|
+
from crit_models.config import architecture
|
|
31
33
|
from crit_core.model.gguf import TYPE_BY_NAME, TensorInfo as GgufTensor
|
|
32
34
|
|
|
33
35
|
from .schemes import PRIMARY, quantization_of, refuse_unread, stored
|
|
@@ -41,11 +43,12 @@ def _source(model):
|
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
def model_config(model):
|
|
44
|
-
"""The model's config.json read with Core's rules (crit_core.model.ModelSource.config
|
|
45
|
-
|
|
46
|
-
(
|
|
46
|
+
"""The model's config.json read with Core's rules (crit_core.model.ModelSource.config: the folder's own, or the
|
|
47
|
+
one a GGUF's metadata derives; an empty config when the model has none) and its mechanisms with crit Models'
|
|
48
|
+
(crit_models.config.architecture: layer kinds, experts, latent attention, recurrent state, the KV a token adds).
|
|
49
|
+
Rules read the text section (`text_config` over the root)."""
|
|
47
50
|
source = _source(model)
|
|
48
|
-
return source.config() if source else parse_model_config({})
|
|
51
|
+
return architecture(source.config() if source else parse_model_config({}))
|
|
49
52
|
|
|
50
53
|
|
|
51
54
|
def weight_files(model, drafts=False):
|
|
@@ -206,12 +209,15 @@ def best_rates(device):
|
|
|
206
209
|
# The activation formats a quantized matrix's prompt GEMM can take, and the rates (crit_eval.limits.probe keys) each runs at
|
|
207
210
|
# for each stored weight format, the best available one counting: BF16 activations on BF16 tensor cores with FP32
|
|
208
211
|
# accumulation, FP16 activations accumulating in FP16, FP8 activations (FP4 weights times FP8 through kind::f8f6f4, or
|
|
209
|
-
# widened to FP8), and the stored format itself (W8A8, W4A4). Weights stored in BF16 stay at the BF16 rate
|
|
212
|
+
# widened to FP8), and the stored format itself (W8A8, W4A4). Weights stored in BF16 stay at the BF16 rate unless
|
|
213
|
+
# re-encoded: their matrices (DENSE) take FP8 only as REENCODED, weights and activations in E4M3 (W8A8).
|
|
210
214
|
ACTIVATIONS = {"bf16": {"fp8": ("bf16",), "nvfp4": ("bf16",)},
|
|
211
215
|
"fp16_acc": {"fp8": ("fp16_acc",), "nvfp4": ("fp16_acc",)},
|
|
212
|
-
"fp8": {"fp8": ("fp8",), "nvfp4": ("fp4_fp8", "fp8")},
|
|
216
|
+
"fp8": {"fp8": ("fp8",), "nvfp4": ("fp4_fp8", "fp8"), "bf16": ("fp8",)},
|
|
213
217
|
"stored": {"fp8": ("fp8",), "nvfp4": ("nvfp4",)}}
|
|
214
218
|
QUANTIZED = ("fp8", "nvfp4")
|
|
219
|
+
DENSE = "bf16" # the matmul_flops_per_token key of the matrices stored in 16 bits
|
|
220
|
+
REENCODED = {DENSE: {"fp8": 1.0}} # those matrices re-encoded to FP8 rows (W8A8), as activation shares
|
|
215
221
|
|
|
216
222
|
|
|
217
223
|
def quantized_formats(ceiling):
|
|
@@ -219,6 +225,11 @@ def quantized_formats(ceiling):
|
|
|
219
225
|
return [f for f in QUANTIZED if ((ceiling or {}).get("matmul_flops_per_token") or {}).get(f)]
|
|
220
226
|
|
|
221
227
|
|
|
228
|
+
def has_dense(ceiling):
|
|
229
|
+
"""Whether the model's prompt GEMMs multiply matrices stored in 16 bits (DENSE), which REENCODED prices in FP8."""
|
|
230
|
+
return bool(((ceiling or {}).get("matmul_flops_per_token") or {}).get(DENSE))
|
|
231
|
+
|
|
232
|
+
|
|
222
233
|
def activation_shares(activations, formats):
|
|
223
234
|
"""{stored format: {activation: share}} from an engine's prompt_activations: one activation for every quantized
|
|
224
235
|
format ("fp16_acc"), one per format ({"nvfp4": "fp16_acc", "fp8": "fp8"}) or shares of a format's FLOPs
|
|
@@ -33,6 +33,7 @@ from .tensors import tensor_role
|
|
|
33
33
|
|
|
34
34
|
GIB = 1 << 30
|
|
35
35
|
DRAFT_HEAD = re.compile(r"(^|\.)head\.weight$") # a draft layer's own output head (shared_head.head)
|
|
36
|
+
SIXTEEN = ("BF16", "F16") # the stored dtypes of 16-bit matrices (safetensors and GGUF names alike)
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
def _kv_fit(free_bytes, kv_bytes_per_token, *, headroom, reserve, held, granularity):
|
|
@@ -60,42 +61,56 @@ def weight_split(model, config):
|
|
|
60
61
|
if not shards:
|
|
61
62
|
return None
|
|
62
63
|
split = {"resident": 0, "experts": 0, "draft": 0, "embedding": 0, "vision": 0}
|
|
64
|
+
# The same groups' matrices stored in 16 bits (SIXTEEN, two dimensions or more: no norms or biases).
|
|
65
|
+
sixteen = {"resident": 0, "experts": 0, "draft": 0, "embedding": 0}
|
|
63
66
|
tied = bool(config.tie_word_embeddings)
|
|
64
67
|
heads = 0
|
|
65
68
|
for shard in shards:
|
|
66
69
|
for tensor in shard.tensors:
|
|
67
70
|
role, size = tensor_role(tensor.name, shard.path.name, drafts), tensor.nbytes
|
|
71
|
+
wide = tensor.dtype in SIXTEEN and len(tensor.shape) >= 2
|
|
68
72
|
if role.kind == "other_modality":
|
|
69
73
|
split["vision"] += size
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
split["resident"] += size
|
|
74
|
+
continue
|
|
75
|
+
group = "embedding" if role.kind == "embedding" else "experts" if role.kind == "expert" else "resident"
|
|
76
|
+
split[group] += size
|
|
77
|
+
sixteen[group] += size if wide else 0
|
|
78
|
+
if group == "resident":
|
|
76
79
|
heads += role.kind == "head"
|
|
77
80
|
if role.draft:
|
|
78
81
|
split["draft"] += size
|
|
82
|
+
sixteen["draft"] += size if wide else 0
|
|
79
83
|
if tied and not heads:
|
|
80
84
|
# The output head is the embedding table: every pass reads all of it.
|
|
81
85
|
split["resident"] += split["embedding"]
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
sixteen["resident"] += sixteen["embedding"]
|
|
87
|
+
split["embedding"] = sixteen["embedding"] = 0
|
|
88
|
+
return {**split, "sixteen": sixteen}
|
|
84
89
|
|
|
85
90
|
|
|
86
|
-
def pass_bytes(model, kv_bytes_per_element):
|
|
91
|
+
def pass_bytes(model, kv_bytes_per_element, sixteen_bits=16):
|
|
87
92
|
"""What one decode pass of one token reads from the stored model, for an engine that reports no bytes_per_pass:
|
|
88
93
|
the weights read on every pass but draft layers, the routed experts' share (experts_per_token of the experts,
|
|
89
94
|
taken as equally sized) and the fixed state (linear-attention and Mamba recurrence, sliding-window KV at
|
|
90
|
-
kv_bytes_per_element).
|
|
95
|
+
kv_bytes_per_element). sixteen_bits: the bits a weight of the matrices stored in 16 bits is read at (8: quality
|
|
96
|
+
mode speed's starting arithmetic, every such matrix in FP8: speed_pass_bytes). None without weight headers."""
|
|
91
97
|
config = model_config(model)
|
|
92
98
|
split = weight_split(model, config)
|
|
93
99
|
if split is None:
|
|
94
100
|
return None
|
|
95
101
|
moe = config.moe
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
share = (min(1.0, moe.experts_per_token / moe.experts) if split["experts"] and moe and moe.experts
|
|
103
|
+
and moe.experts_per_token else 0)
|
|
104
|
+
saved = (1 - sixteen_bits / 16) * (split["sixteen"]["resident"] - split["sixteen"]["draft"]
|
|
105
|
+
+ split["sixteen"]["experts"] * share)
|
|
106
|
+
return int(split["resident"] - split["draft"] + split["experts"] * share - saved
|
|
107
|
+
+ config.fixed_state_bytes(kv_bytes_per_element))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def speed_pass_bytes(model, kv_bytes_per_element):
|
|
111
|
+
"""pass_bytes with every matrix stored in 16 bits read in 8 bits: what a pass reads in quality mode speed's
|
|
112
|
+
starting arithmetic (protocol headroom.speed_weights). None without weight headers."""
|
|
113
|
+
return pass_bytes(model, kv_bytes_per_element, sixteen_bits=8)
|
|
99
114
|
|
|
100
115
|
|
|
101
116
|
def draft_step_bytes(model):
|
|
@@ -355,11 +355,15 @@ def activation_ceilings(result, rates, sources, prefill_cases, evidence=()):
|
|
|
355
355
|
fastest shown to pass. evidence: earlier results of the same model (a baseline) whose quality judged their own
|
|
356
356
|
declared activations, beside this result's; only those judged in this result's quality mode count, since a pass
|
|
357
357
|
under the speed mode's budget shows nothing for preserve's and a failure under preserve's nothing for the speed
|
|
358
|
-
mode's.
|
|
358
|
+
mode's. Where the model stores matrices in 16 bits, each ceiling once more with those re-encoded to FP8 (W8A8:
|
|
359
|
+
ceiling.REENCODED), named ACTIVATION+w8 (REENCODED_SUFFIX; only stored+w8 for a model with no quantized matrices),
|
|
360
|
+
which the speed mode admits (MODE_ACTIVATIONS) and no quality evidence judges. None when the model stores neither
|
|
361
|
+
quantized nor 16-bit matrices."""
|
|
359
362
|
ceiling = tiered_ceiling(result)
|
|
360
363
|
formats = model_ceiling.quantized_formats(ceiling)
|
|
364
|
+
dense = model_ceiling.has_dense(ceiling)
|
|
361
365
|
speed, info = result.get("speed") or {}, result.get("engine") or {}
|
|
362
|
-
if not formats or not rates:
|
|
366
|
+
if not (formats or dense) or not rates:
|
|
363
367
|
return None
|
|
364
368
|
measured = {cid: c for cid, c in speed.get("cases", {}).items() if c.get("status") == "measured" and c.get("ttft_ms")}
|
|
365
369
|
|
|
@@ -380,19 +384,23 @@ def activation_ceilings(result, rates, sources, prefill_cases, evidence=()):
|
|
|
380
384
|
"cases": {cid: {"floor_ms": ms} for cid, ms in floors.items()}}
|
|
381
385
|
return row, lacking
|
|
382
386
|
modes, missing = {}, []
|
|
383
|
-
for
|
|
384
|
-
|
|
387
|
+
names = [a for a in model_ceiling.ACTIVATIONS if formats]
|
|
388
|
+
names += [a + REENCODED_SUFFIX for a in (model_ceiling.ACTIVATIONS if formats else ("stored",)) if dense]
|
|
389
|
+
for name in names:
|
|
390
|
+
shares = row_shares(name, formats)
|
|
385
391
|
row, lacking = priced(shares)
|
|
386
392
|
row["rates"] = {}
|
|
387
|
-
for f in
|
|
393
|
+
for f, mix in shares.items():
|
|
394
|
+
activation = next(iter(mix))
|
|
388
395
|
rate, key = model_ceiling.matmul_rate(rates, f, activation)
|
|
389
396
|
row["rates"][f] = {"tflops": rate, "rate": key if rate else None, "source": sources.get(key) if rate else None}
|
|
390
397
|
if lacking:
|
|
391
398
|
row["missing"] = lacking
|
|
392
|
-
modes[
|
|
393
|
-
judged = [prompt_evidence(result, formats)] + [prompt_evidence(other, formats) for other in evidence
|
|
394
|
-
|
|
395
|
-
|
|
399
|
+
modes[name] = {**row, "state": None, "evidence": []}
|
|
400
|
+
judged = ([prompt_evidence(result, formats)] + [prompt_evidence(other, formats) for other in evidence
|
|
401
|
+
if other.get("model_sha256") == result.get("model_sha256")
|
|
402
|
+
and quality_mode(other) == quality_mode(result)]
|
|
403
|
+
if formats else [(None, None, None)])
|
|
396
404
|
declared, state, detail = judged[0]
|
|
397
405
|
own = None
|
|
398
406
|
if declared is not None:
|
|
@@ -413,10 +421,31 @@ def activation_ceilings(result, rates, sources, prefill_cases, evidence=()):
|
|
|
413
421
|
row = own if name == "declared" else modes[name]
|
|
414
422
|
reachable = {"name": name, "label": own["label"] if name == "declared" else name, "ceiling_score": score,
|
|
415
423
|
"ttft_floor_ms": row["ttft_floor_ms"], "cases": row["cases"]}
|
|
416
|
-
if declared is None:
|
|
424
|
+
if declared is None and formats:
|
|
417
425
|
missing.append("prompt_activations from the adapter (the activation format of each quantized matrix group's "
|
|
418
426
|
"prompt GEMMs; with the quality gate it names the reachable prefill ceiling)")
|
|
419
|
-
return {"formats": formats, "modes": modes, "declared": own, "reachable": reachable,
|
|
427
|
+
return {"formats": formats, "dense": dense, "modes": modes, "declared": own, "reachable": reachable,
|
|
428
|
+
"missing": missing}
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
# A ceiling's name with the model's 16-bit matrices re-encoded to FP8 (W8A8) beside the quantized ones' activation.
|
|
432
|
+
REENCODED_SUFFIX = "+w8"
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
def row_shares(name, formats):
|
|
436
|
+
"""The activation shares a ceiling of activation_ceilings prices: every quantized format at the named activation,
|
|
437
|
+
and with REENCODED_SUFFIX the 16-bit matrices in FP8 too (ceiling.REENCODED)."""
|
|
438
|
+
activation = name[:-len(REENCODED_SUFFIX)] if name.endswith(REENCODED_SUFFIX) else name
|
|
439
|
+
shares = {f: {activation: 1.0} for f in formats}
|
|
440
|
+
return {**shares, **model_ceiling.REENCODED} if name.endswith(REENCODED_SUFFIX) else shares
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
def ceiling_label(name):
|
|
444
|
+
"""A ceiling's name as the reports write it: an activation, or with REENCODED_SUFFIX that activation and the
|
|
445
|
+
16-bit matrices in FP8 (W8A8)."""
|
|
446
|
+
if not name.endswith(REENCODED_SUFFIX):
|
|
447
|
+
return name
|
|
448
|
+
return f"{name[:-len(REENCODED_SUFFIX)]} (16-bit matrices in FP8, W8A8)"
|
|
420
449
|
|
|
421
450
|
|
|
422
451
|
# A quality-preserving engine keeps its prompt activations in 16 bits (quality mode preserve): the fastest of these
|
|
@@ -424,8 +453,11 @@ def activation_ceilings(result, rates, sources, prefill_cases, evidence=()):
|
|
|
424
453
|
PRESERVE_ACTIVATIONS = ("bf16", "fp16_acc")
|
|
425
454
|
# The prompt activations of the quantized matrices each quality mode admits without quality evidence (the formats
|
|
426
455
|
# activation_ceilings prices): preserve's 16-bit ones; the speed mode admits every one, the stored format's own,
|
|
427
|
-
# FP8 and 16-bit, whatever format the checkpoint stores, so its limits never fall below preserve's
|
|
428
|
-
|
|
456
|
+
# FP8 and 16-bit, whatever format the checkpoint stores, so its limits never fall below preserve's, and each with the
|
|
457
|
+
# matrices stored in 16 bits re-encoded to FP8 (+w8): its starting arithmetic holds every target matrix in 8 bits.
|
|
458
|
+
MODE_ACTIVATIONS = {"preserve": PRESERVE_ACTIVATIONS,
|
|
459
|
+
"speed": tuple(a + suffix for suffix in ("", REENCODED_SUFFIX)
|
|
460
|
+
for a in ("bf16", "fp16_acc", "fp8", "stored"))}
|
|
429
461
|
|
|
430
462
|
|
|
431
463
|
def quality_mode(result):
|
|
@@ -442,19 +474,21 @@ def mode_limits(result):
|
|
|
442
474
|
keeps the activations in 16 bits; the speed mode admits the stored
|
|
443
475
|
format's too, so its limits are the stored format's (None) wherever that is the fastest priced (a device with the
|
|
444
476
|
format's tensor cores), and a faster one's elsewhere (FP8 for 4-bit matrices on a device without 4-bit ones).
|
|
445
|
-
|
|
477
|
+
The speed mode's limits hold the matrices stored in 16 bits in FP8 too (the +w8 ceilings) wherever the model has
|
|
478
|
+
such matrices and the device multiplies FP8 faster than BF16. None too while the ceilings by activation are not
|
|
479
|
+
priced (a checkpoint with neither 16-bit nor FP8 or NVFP4 matrices)."""
|
|
446
480
|
mode = quality_mode(result)
|
|
447
481
|
admitted = MODE_ACTIVATIONS[mode]
|
|
448
482
|
room = result.get("headroom") or {}
|
|
449
483
|
found = room.get("activations") or {}
|
|
450
484
|
formats = found.get("formats") or ()
|
|
451
485
|
modes = found.get("modes") or {}
|
|
452
|
-
options = [(row["ceiling_score"], name,
|
|
486
|
+
options = [(row["ceiling_score"], ceiling_label(name), row_shares(name, formats), row.get("ttft_floor_ms"))
|
|
453
487
|
for name, row in modes.items() if name in admitted and row.get("ceiling_score")]
|
|
454
488
|
reach = found.get("reachable")
|
|
455
489
|
if reach and reach.get("ceiling_score"):
|
|
456
490
|
shares = ((found.get("declared") or {}).get("activations") if reach["name"] == "declared"
|
|
457
|
-
else
|
|
491
|
+
else row_shares(reach["name"], formats))
|
|
458
492
|
options.append((reach["ceiling_score"], reach["label"], shares, reach.get("ttft_floor_ms")))
|
|
459
493
|
if not options:
|
|
460
494
|
return None
|
|
@@ -833,7 +867,7 @@ def measured_hit_rate(result):
|
|
|
833
867
|
|
|
834
868
|
def summarize(info, speed, step_ms, bandwidth_gbs, thresholds, ceiling=None, tflops=None, steps=None,
|
|
835
869
|
prefill_cases=(), context=None, context_settings=None, decode_speed=None, decode_name="greedy",
|
|
836
|
-
host_rates=None, model_pass=None, tiers=None, telemetry=None):
|
|
870
|
+
host_rates=None, model_pass=None, tiers=None, telemetry=None, speed_pass=None):
|
|
837
871
|
"""info: adapter info(); speed: run_speed() result; step_ms: median ordinary one-token step
|
|
838
872
|
in ms (None when unmeasured); bandwidth_gbs: achievable device bandwidth in GB/s; ceiling:
|
|
839
873
|
the prepared model arithmetic (ceiling.model_ceiling); tflops: GEMM rates by format; steps:
|
|
@@ -845,7 +879,9 @@ def summarize(info, speed, step_ms, bandwidth_gbs, thresholds, ceiling=None, tfl
|
|
|
845
879
|
model's memory tiers on the device (crit_eval.limits.tiers.derive), which price an engine that declares no host
|
|
846
880
|
bytes, each case at its own expert cache hit rate, and the prompts' floors (protocol headroom.tiers); telemetry: the
|
|
847
881
|
engine's own expert cache counters over each speed suite (result telemetry), the hit rate where its requests report
|
|
848
|
-
none. Without either the expert misses are unmeasured: no rate is assumed.
|
|
882
|
+
none. Without either the expert misses are unmeasured: no rate is assumed. speed_pass: in quality mode speed, the
|
|
883
|
+
bytes a pass reads with every 16-bit matrix in 8 bits (context.speed_pass_bytes), its starting arithmetic: a pass
|
|
884
|
+
that reads more is a decode gap (speed_weights_gap)."""
|
|
849
885
|
decode_speed = decode_speed or speed
|
|
850
886
|
width = info.get("draft_width")
|
|
851
887
|
probed_gbs = bandwidth_gbs # the fixed denominator takes the probe's, never an engine's
|
|
@@ -1001,6 +1037,7 @@ def summarize(info, speed, step_ms, bandwidth_gbs, thresholds, ceiling=None, tfl
|
|
|
1001
1037
|
missing.append("verify_ms and draft_ms from generate() (separates the draft steps from the verify pass)")
|
|
1002
1038
|
|
|
1003
1039
|
gaps = decode_gaps(cases, score, width, draft_floor, projection)
|
|
1040
|
+
gaps += speed_weights_gap(cases, score, info.get("bytes_per_pass"), speed_pass)
|
|
1004
1041
|
gaps += acceptance_gaps(cases, score, width, bound_width, step_ms, draft_ms)
|
|
1005
1042
|
if decode_speed is not speed:
|
|
1006
1043
|
gaps += sampling_gaps(decode_speed, speed, score)
|
|
@@ -1033,6 +1070,7 @@ def summarize(info, speed, step_ms, bandwidth_gbs, thresholds, ceiling=None, tfl
|
|
|
1033
1070
|
"end_to_end": end_to_end, "noise": _noises(speed, decode_speed, prefill_cases), "context": long_context,
|
|
1034
1071
|
# Decode over one token per pass at the model files' bytes, whatever the engine reports (reported, not judged).
|
|
1035
1072
|
"fixed_decode": fixed_decode(decode_speed, model_pass, probed_gbs, decode_name),
|
|
1073
|
+
**({"speed_pass_bytes": speed_pass} if speed_pass else {}),
|
|
1036
1074
|
"missing": missing, "warnings": warnings,
|
|
1037
1075
|
}
|
|
1038
1076
|
|
|
@@ -1117,6 +1155,24 @@ def context_summary(info, context, ceiling, tflops, bandwidth_gbs, draft_floor,
|
|
|
1117
1155
|
"missing": missing, "gaps": gaps}
|
|
1118
1156
|
|
|
1119
1157
|
|
|
1158
|
+
def speed_weights_gap(cases, score, bytes_per_pass, speed_pass):
|
|
1159
|
+
"""protocol headroom.speed_weights: in quality mode speed, the decode gain if each round's model pass read what a
|
|
1160
|
+
pass reads with every 16-bit matrix in 8 bits (speed_pass), its time scaled by the bytes, all else as measured;
|
|
1161
|
+
[] where the pass already reads no more than that (within 1%), or without the pass's bytes or its step."""
|
|
1162
|
+
timed = {cid: row for cid, row in cases.items() if row.get("round_ms") and row.get("decode_tps")
|
|
1163
|
+
and row.get("step_ms")}
|
|
1164
|
+
if not score or not timed or not bytes_per_pass or not speed_pass or bytes_per_pass <= speed_pass * 1.01:
|
|
1165
|
+
return []
|
|
1166
|
+
ratio = speed_pass / bytes_per_pass
|
|
1167
|
+
gain, factors = _projected_gain(timed, score, lambda cid, row: row["round_ms"] - row["step_ms"] * (1 - ratio))
|
|
1168
|
+
if not gain or gain <= 0:
|
|
1169
|
+
return []
|
|
1170
|
+
return [{"kpi": "decode", "name": "16-bit weights read in 8 bits (quality mode speed's starting arithmetic)",
|
|
1171
|
+
"projected_gain": gain, "case_speedup": factors,
|
|
1172
|
+
"detail": f"a pass reads {bytes_per_pass / 1e9:.2f} GB, {speed_pass / 1e9:.2f} GB with every matrix "
|
|
1173
|
+
"stored in 16 bits held in FP8"}]
|
|
1174
|
+
|
|
1175
|
+
|
|
1120
1176
|
def decode_gaps(cases, score, width, draft_floor, projection):
|
|
1121
1177
|
"""Decode-score gains if one term were at its floor, with everything else as measured."""
|
|
1122
1178
|
gaps = []
|
|
@@ -44,7 +44,8 @@ in DECODERS.
|
|
|
44
44
|
activations(checkpoint, base) says how the checkpoint's own inference quantizes the activations a quantized matrix
|
|
45
45
|
multiplies (its declared input activations: compressed-tensors input_activations with base.input_global_scale or
|
|
46
46
|
base.input_scale, ModelOpt base.input_scale), and quantize_activations applies it in FP32 in the reference's
|
|
47
|
-
allowance pass (crit_eval.quality.reference
|
|
47
|
+
allowance pass (crit_eval.quality.reference; both quality modes judge against exact activations, and speed's
|
|
48
|
+
limits are raised to twice what that pass costs).
|
|
48
49
|
"""
|
|
49
50
|
import json
|
|
50
51
|
import math
|
|
@@ -97,6 +98,23 @@ def activations(checkpoint, base):
|
|
|
97
98
|
return None
|
|
98
99
|
|
|
99
100
|
|
|
101
|
+
def declares_activations(model):
|
|
102
|
+
"""Whether checkpoint folder `model` declares quantized input activations for a matrix, from its config and
|
|
103
|
+
tensor headers alone (no torch): a compressed-tensors config group with input_activations, else (ModelOpt and
|
|
104
|
+
others) a stored base.input_scale or base.input_global_scale. What a speed run asks of a checkpoint whose data
|
|
105
|
+
holds no allowance (protocol quality.allowance); False where the model cannot be read."""
|
|
106
|
+
try:
|
|
107
|
+
from crit_core.model import inspect_model, open_model
|
|
108
|
+
quantization = quantization_of(open_model(model).config())
|
|
109
|
+
if _method(quantization) == "compressed-tensors":
|
|
110
|
+
return any(isinstance(group, dict) and group.get("weights") and group.get("input_activations")
|
|
111
|
+
for group in (quantization.get("config_groups") or {}).values())
|
|
112
|
+
return any(tensor.name.endswith((".input_scale", ".input_global_scale"))
|
|
113
|
+
for shard in inspect_model(model, header_only=True).shards for tensor in shard.tensors)
|
|
114
|
+
except Exception: # a model it cannot read: the run says nothing of an allowance
|
|
115
|
+
return False
|
|
116
|
+
|
|
117
|
+
|
|
100
118
|
def _round_e2m1(magnitude):
|
|
101
119
|
"""Magnitudes (at most 6) to the nearest E2M1 value, ties to the even code, as the hardware conversion rounds."""
|
|
102
120
|
import torch
|