Skip to content

Commit 2e0df5a

Browse files
justinchubyCopilot
andcommitted
Format GGUF support audit tooling
Apply the repository formatters to the generated support documentation and runtime-evidence tests after transplanting the PR onto the squash-merged parent. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
1 parent dc36ddc commit 2e0df5a

5 files changed

Lines changed: 60 additions & 46 deletions

File tree

‎scripts/generate_gguf_support_docs.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from __future__ import annotations
77

88
import argparse
9-
from pathlib import Path
109
import sys
10+
from pathlib import Path
1111

1212
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
1313

‎src/mobius/integrations/gguf/_docs.py‎

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
__all__ = ["DOC_PATH", "check_document", "render_blocks", "update_document"]
99

10+
import re
1011
from collections import Counter
1112
from pathlib import Path
12-
import re
1313

1414
from mobius.integrations.gguf._arch_registry import iter_arch_specs
1515
from mobius.integrations.gguf._mmproj_registry import iter_projector_specs
@@ -61,9 +61,7 @@ def _summary() -> str:
6161
qtypes = iter_quant_specs()
6262
projectors = iter_projector_specs()
6363
tokenizers = tokenizer_pre_policies()
64-
stored = [
65-
spec for spec in qtypes if spec.readable and spec.role is StorageRole.QUANTIZED
66-
]
64+
stored = [spec for spec in qtypes if spec.readable and spec.role is StorageRole.QUANTIZED]
6765
routed = [
6866
spec
6967
for spec in stored
@@ -73,49 +71,59 @@ def _summary() -> str:
7371
]
7472
graph_counts = Counter(spec.graph.value for spec in architectures)
7573
runtime_counts = Counter(spec.runtime.value for spec in architectures)
76-
quantized_import_counts = Counter(
77-
spec.quantized_import.value for spec in architectures
78-
)
74+
quantized_import_counts = Counter(spec.quantized_import.value for spec in architectures)
7975
projector_counts = {
8076
"graph-importable": sum(spec.is_importable for spec in projectors),
8177
"runtime-supported": sum(spec.runtime is Support.SUPPORTED for spec in projectors),
8278
}
8379
return "\n".join(
8480
(
85-
f"**Pinned source:** `ggml-org/llama.cpp@{UPSTREAM_COMMIT}` "
86-
f"({UPSTREAM_DATE}).",
81+
f"**Pinned source:** `ggml-org/llama.cpp@{UPSTREAM_COMMIT}` ({UPSTREAM_DATE}).",
8782
"",
8883
"| Census | Total | Closure |",
8984
"|---|---:|---|",
90-
f"| Architectures | {len(architectures)} | "
91-
f"graph verdicts: {dict(sorted(graph_counts.items()))}; "
92-
f"importable: {sum(spec.is_importable for spec in architectures)}; "
93-
f"quantized import: {dict(sorted(quantized_import_counts.items()))}; "
94-
f"runtime: {dict(sorted(runtime_counts.items()))} |",
95-
f"| Active stored qtypes | {len(stored)} | {len(routed)} have an import route; "
96-
f"{len(stored) - len(routed)} are explicitly deferred with no route |",
97-
f"| Serialized projector strings | {len(projectors)} | "
98-
f"{dict(sorted(projector_counts.items()))} |",
99-
f"| Tokenizer pre identifiers | {len(tokenizers)} | "
100-
f"{len({policy.canonical for policy in tokenizers.values()})} semantic groups; "
101-
"all default to deferred and become exact-copy only with a validated embedded "
102-
"`tokenizer.huggingface.json` |",
85+
(
86+
f"| Architectures | {len(architectures)} | "
87+
f"graph verdicts: {dict(sorted(graph_counts.items()))}; "
88+
f"importable: {sum(spec.is_importable for spec in architectures)}; "
89+
f"quantized import: {dict(sorted(quantized_import_counts.items()))}; "
90+
f"runtime: {dict(sorted(runtime_counts.items()))} |"
91+
),
92+
(
93+
f"| Active stored qtypes | {len(stored)} | {len(routed)} have an import route; "
94+
f"{len(stored) - len(routed)} are explicitly deferred with no route |"
95+
),
96+
(
97+
f"| Serialized projector strings | {len(projectors)} | "
98+
f"{dict(sorted(projector_counts.items()))} |"
99+
),
100+
(
101+
f"| Tokenizer pre identifiers | {len(tokenizers)} | "
102+
f"{len({policy.canonical for policy in tokenizers.values()})} semantic groups; "
103+
"all default to deferred and become exact-copy only with a validated embedded "
104+
"`tokenizer.huggingface.json` |"
105+
),
103106
"",
104-
"`SUPPORTED` means the named capability is implemented and mechanically tested. "
105-
"`DEFERRED` means it is intentionally unavailable pending the stated work. "
106-
"`REJECTED` means the input or route is invalid by policy. Graph support proves "
107-
"construction/execution only; runtime support additionally requires a pinned real "
108-
"artifact, independent parity, and deterministic generation or stateful semantics. "
109-
"Tokenizer `copy` delegates algorithm semantics to an embedded, vocabulary-identical "
110-
"tokenizer JSON; it is not a reconstructed or independently proven tokenizer.",
107+
(
108+
"`SUPPORTED` means the named capability is implemented and mechanically tested. "
109+
"`DEFERRED` means it is intentionally unavailable pending the stated work. "
110+
"`REJECTED` means the input or route is invalid by policy. Graph support proves "
111+
"construction/execution only; runtime support additionally requires a pinned real "
112+
"artifact, independent parity, and deterministic generation or stateful semantics. "
113+
"Tokenizer `copy` delegates algorithm semantics to an embedded, "
114+
"vocabulary-identical tokenizer JSON; it is not a reconstructed or independently "
115+
"proven tokenizer."
116+
),
111117
)
112118
)
113119

114120

115121
def _architectures() -> str:
116122
rows = [
117-
"| Canonical architecture | Aliases | Import route | Tensor exactness | "
118-
"Config/tensor/graph/runtime/quantized import | Restriction or evidence gap |",
123+
(
124+
"| Canonical architecture | Aliases | Import route | Tensor exactness | "
125+
"Config/tensor/graph/runtime/quantized import | Restriction or evidence gap |"
126+
),
119127
"|---|---|---|---|---|---|",
120128
]
121129
upstream = upstream_architectures()
@@ -155,8 +163,10 @@ def _qtypes() -> str:
155163

156164
def _projectors() -> str:
157165
rows = [
158-
"| Projector string | Modality | Paired text architecture | "
159-
"Metadata/tensor/graph/runtime | Exactness/evidence |",
166+
(
167+
"| Projector string | Modality | Paired text architecture | "
168+
"Metadata/tensor/graph/runtime | Exactness/evidence |"
169+
),
160170
"|---|---|---|---|---|",
161171
]
162172
for spec in sorted(iter_projector_specs(), key=lambda item: item.projector_type):
@@ -180,16 +190,19 @@ def _projectors() -> str:
180190

181191
def _tokenizers() -> str:
182192
rows = [
183-
"| Exact identifier | Canonical semantic group | Pinned pre-type | Default route | "
184-
"Exactness/restriction |",
193+
(
194+
"| Exact identifier | Canonical semantic group | Pinned pre-type | Default route | "
195+
"Exactness/restriction |"
196+
),
185197
"|---|---|---|---|---|",
186198
]
187199
for identifier, policy in sorted(tokenizer_pre_policies().items()):
188-
rows.append(
200+
row = (
189201
f"| `{identifier}` | `{policy.canonical}` | `{policy.pre_type}` | "
190202
f"`{policy.default_route}` | Exact-copy only after embedded tokenizer JSON and "
191203
"ordered vocabulary validation; otherwise runtime packaging is deferred. |"
192204
)
205+
rows.append(row)
193206
return "\n".join(rows)
194207

195208

@@ -206,7 +219,9 @@ def render_blocks() -> dict[str, str]:
206219

207220
def _replace(text: str, begin: str, end: str, body: str) -> str:
208221
if text.count(begin) != 1 or text.count(end) != 1:
209-
raise ValueError(f"Expected exactly one generated block delimited by {begin!r}/{end!r}")
222+
raise ValueError(
223+
f"Expected exactly one generated block delimited by {begin!r}/{end!r}"
224+
)
210225
before, remainder = text.split(begin, 1)
211226
_, after = remainder.split(end, 1)
212227
return f"{before}{begin}\n\n{body}\n\n{end}{after}"

‎src/mobius/integrations/gguf/_docs_test.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_stale_at_style_pin_is_rejected(tmp_path: Path) -> None:
3232
+ "\nllama.cpp@1111111111111111111111111111111111111111\n",
3333
encoding="utf-8",
3434
)
35-
with pytest.raises(ValueError, match="Stale llama.cpp pins"):
35+
with pytest.raises(ValueError, match=r"Stale llama\.cpp pins"):
3636
update_document(document)
3737

3838

‎src/mobius/integrations/gguf/_runtime_evidence.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ def __post_init__(self) -> None:
126126
"GGUF runtime evidence requires immutable 40-hex revisions and LFS SHA-256"
127127
)
128128
if self.parity_kind not in {"full-logit", "component"}:
129-
raise ValueError("GGUF runtime evidence parity_kind must be full-logit or component")
129+
raise ValueError(
130+
"GGUF runtime evidence parity_kind must be full-logit or component"
131+
)
130132
if (
131133
not self.graph_files
132134
or tuple(sorted(self.graph_files)) != self.graph_files
@@ -286,6 +288,7 @@ def _hash_regular_file(path: Path) -> tuple[os.stat_result, str]:
286288
while chunk := os.read(descriptor, 1024 * 1024):
287289
digest.update(chunk)
288290
after = os.fstat(descriptor)
291+
289292
def identity(value: os.stat_result) -> tuple[int, int, int, int]:
290293
return (value.st_dev, value.st_ino, value.st_size, value.st_mtime_ns)
291294

‎src/mobius/integrations/gguf/_runtime_evidence_test.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ def test_matching_evidence_binds_arch_runtime_source_qtypes_and_route(
8080
runtime="onnx-genai",
8181
source_path=source,
8282
gguf_model=_model(),
83-
built_identity=gguf_artifact_identity(
84-
source, _model(), architecture="llama"
85-
),
83+
built_identity=gguf_artifact_identity(source, _model(), architecture="llama"),
8684
import_route=record.import_route,
8785
runtime_version="1.0.0",
8886
)
@@ -96,9 +94,7 @@ def test_matching_evidence_binds_arch_runtime_source_qtypes_and_route(
9694
runtime="ort-genai",
9795
source_path=source,
9896
gguf_model=_model(),
99-
built_identity=gguf_artifact_identity(
100-
source, _model(), architecture="llama"
101-
),
97+
built_identity=gguf_artifact_identity(source, _model(), architecture="llama"),
10298
import_route=record.import_route,
10399
runtime_version="1.0.0",
104100
)

0 commit comments

Comments
 (0)