84 lines
2.9 KiB
Python
84 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
"""CI-only fixture for the standalone Linux CLI; no model assets are retained."""
|
|
|
|
import hashlib
|
|
import json
|
|
import pathlib
|
|
import struct
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
|
|
|
|
def fixture() -> bytes:
|
|
header = bytearray(b"GGUF" + struct.pack("<IQQ", 3, 2, 1))
|
|
|
|
def string(value: str) -> None:
|
|
encoded = value.encode()
|
|
header.extend(struct.pack("<Q", len(encoded)))
|
|
header.extend(encoded)
|
|
|
|
string("general.architecture")
|
|
header.extend(struct.pack("<I", 8))
|
|
string("qwen35")
|
|
for name, kind, offset, elements in (
|
|
("dense", 0, 128, 32),
|
|
("expert", 21, 0, 256),
|
|
):
|
|
string(name)
|
|
header.extend(struct.pack("<IQIQ", 1, elements, kind, offset))
|
|
header.extend(bytes((-len(header)) % 32))
|
|
payload = bytearray(256)
|
|
payload[:2] = struct.pack("<H", 0x3C00)
|
|
for index in range(64):
|
|
payload[index + 2] = index * 3 % 256
|
|
payload[74] = 0x55
|
|
for index in range(32):
|
|
payload[128 + 4 * index : 132 + 4 * index] = struct.pack(
|
|
"<f", (-1.0, -0.25, 0.25, 1.0)[index % 4]
|
|
)
|
|
return bytes(header + payload)
|
|
|
|
|
|
def main() -> None:
|
|
binary = pathlib.Path(sys.argv[1]).resolve()
|
|
with tempfile.TemporaryDirectory(prefix="strata-static-smoke-") as temporary:
|
|
root = pathlib.Path(temporary)
|
|
source = root / "mixed.gguf"
|
|
archive = root / "mixed.kar"
|
|
source.write_bytes(fixture())
|
|
derive = subprocess.run(
|
|
[binary, "model", "derive-mixed-identity", source],
|
|
capture_output=True,
|
|
text=True,
|
|
check=True,
|
|
)
|
|
identity = json.loads(derive.stdout)
|
|
expected_source = "c407838a4718093d8f2699209c7cac8b998a47b937e5afe59e4c5a0af09033a7"
|
|
assert identity["derived_f32_sha256"] == expected_source
|
|
prepare = subprocess.run(
|
|
[binary, "model", "prepare-mixed-preview", source, "--output", archive, "--levels", "2"],
|
|
capture_output=True,
|
|
text=True,
|
|
check=True,
|
|
)
|
|
assert "not eligible for serving" in prepare.stdout
|
|
expected_archive = "4053e787d46b2cf2bca3d67e38d06e1ee96a157e80e3155c8dbdbf36835df88c"
|
|
assert hashlib.sha256(archive.read_bytes()).hexdigest() == expected_archive
|
|
provenance = json.loads((root / "mixed.kar.provenance.json").read_text())
|
|
assert provenance["original_gguf_sha256"] == hashlib.sha256(source.read_bytes()).hexdigest()
|
|
assert provenance["derived_f32_sha256"] == expected_source
|
|
assert provenance["archive_sha256"] == expected_archive
|
|
verify = subprocess.run(
|
|
[binary, "model", "verify-mixed-preview", archive, "--source", source],
|
|
capture_output=True,
|
|
text=True,
|
|
check=True,
|
|
)
|
|
assert "payload CRCs match" in verify.stdout
|
|
print("static CLI mixed GGUF/KAR smoke passed")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|