File size: 3,835 Bytes
2b66baf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Verify published release artifacts without loading any model weights."""
import json,hashlib
from pathlib import Path
from huggingface_hub import HfApi,hf_hub_download,CommitOperationAdd
api=HfApi();repo="SEE7/Astheral";info=api.model_info(repo,files_metadata=True);revision=info.sha
def read(name):return Path(hf_hub_download(repo,name,revision=revision)).read_text()
metrics=json.loads(read("evaluation.json"));score=metrics["merged_scores"]
assert not info.private and metrics["version"]=="2" and metrics["quality_gate_passed"]
assert score["fresh"]=={"passed":36,"total":36} and score["regression"]=={"passed":2,"total":2}
assert score["confirmation"]["passed"]==score["confirmation"]["total"]>=16
assert metrics["mode_adherence"]["passed"]==metrics["mode_adherence"]["total"]>=60
assert json.loads(read("cli_smoke_test.json"))["all_passed"]
assert json.loads(read("holdout_evaluation.json"))["no_material_regression_gate"]
config=json.loads(read("config.json"));assert config["astheral_version"]=="2"
assert config["astheral_modes"]==["instruct","thinking"]
assert config["hidden_size"]==4096 and config["num_hidden_layers"]==32
assert json.loads(read("generation_config.json"))["do_sample"] is False
card=read("README.md")
assert "experimental" not in card.lower() and "placeholder" not in card.lower()
assert "Built with Llama" in card
manifest=json.loads(read("artifact_manifest.json"));siblings={s.rfilename:s for s in info.siblings}
verified=[]
for name,expected in manifest.items():
    assert name in siblings,name
    item=siblings[name];assert item.size==expected["bytes"],name
    if item.lfs:
        assert item.lfs.sha256==expected["sha256"],name
    else:
        assert expected["bytes"]<=10_000_000,name
        body=Path(hf_hub_download(repo,name,revision=revision)).read_bytes()
        assert hashlib.sha256(body).hexdigest()==expected["sha256"],name
    verified.append(name)
weights=[s for s in info.siblings if "/" not in s.rfilename and s.rfilename.endswith(".safetensors")]
assert len(weights)>=4 and sum(s.size for s in weights)>16_000_000_000
assert any(n.startswith("adapter/") and n.endswith(".safetensors") for n in siblings)
index=json.loads(read("model.safetensors.index.json"))
assert config.get("torch_dtype",config.get("dtype"))=="bfloat16"
assert index["metadata"]["total_size"]==8030261248*2
parameter_total=index["metadata"]["total_size"]//2
report={"verified_revision":revision,"public":True,"parameter_count":parameter_total,"verified_manifest_files":len(verified),"merged_weight_bytes":sum(s.size for s in weights),"all_required_evaluations_passed":True,"model_loads_during_this_check":0}
if api.repo_exists("SEE7/Astheral-NF4"):
    compact=json.loads(Path(hf_hub_download("SEE7/Astheral-NF4","evaluation.json")).read_text())
    assert compact["quality_gate_passed"] and compact["saved_checkpoint_cli_verified"]
    report["compact"]={"repo":"SEE7/Astheral-NF4","weight_bytes":compact["weight_bytes"]}
changed={"artifact_verification.json":json.dumps(report,indent=2),"verify_release.py":Path(__file__).read_text()}
for n,b in changed.items():manifest[n]={"bytes":len(b.encode()),"sha256":hashlib.sha256(b.encode()).hexdigest()}
changed["artifact_manifest.json"]=json.dumps(manifest,indent=2)
commit=api.create_commit(repo_id=repo,operations=[CommitOperationAdd(path_in_repo=n,path_or_fileobj=b.encode()) for n,b in changed.items()],commit_message="Verify release hashes, real weight files, both modes and independent evaluation artifacts")
if any(t.name=="v2" for t in api.list_repo_refs(repo).tags):api.delete_tag(repo_id=repo,tag="v2")
api.create_tag(repo_id=repo,tag="v2",revision=commit.oid)
assert next(t for t in api.list_repo_refs(repo).tags if t.name=="v2").target_commit==commit.oid
print("ARTIFACTS_VERIFIED",json.dumps({**report,"release_revision":commit.oid}),flush=True)