File size: 2,291 Bytes
086a142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""Assemble a reproducible, attributed model bundle before validation/upload."""

import argparse
import json
import shutil
from pathlib import Path

p = argparse.ArgumentParser()
p.add_argument("name")
p.add_argument("--bundle")
a = p.parse_args()
source = Path("upstream") / a.name
bundle = Path(a.bundle) if a.bundle else Path("bundles") / (a.name + "-CoreAI")
manifest = json.loads((bundle / "manifest.json").read_text())
record = next(
    x
    for x in json.loads(Path("sources.json").read_text())
    if x["id"] == "vllm-sr/" + a.name
)
manifest.update(
    source=record["id"],
    revision=record["revision"],
    format="Apple Core AI .aimodel",
    attention_mode="noncausal_full_attention",
    function="main",
)
(bundle / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n")
for name in [
    "LICENSE",
    "NOTICE",
    "config.json",
    "decision_config.json",
    "tokenizer.json",
    "tokenizer_config.json",
    "vocab.json",
    "merges.txt",
    "chat_template.jinja",
    "preprocessor_config.json",
    "video_preprocessor_config.json",
    "MODEL_MANIFEST.json",
]:
    if (source / name).exists():
        shutil.copy2(
            source / name,
            bundle / name
            if name != "MODEL_MANIFEST.json"
            else "UPSTREAM_MANIFEST.json",
        )
for name in [
    "convert.py",
    "coreai_d3.py",
    "validate_mm.py",
    "validation_cases.py",
    "package.py",
    "sources.json",
    "smoke_runtime.py",
    "finalize_bundle.py",
]:
    shutil.copy2(name, bundle / name)
shutil.copy2(source / "d3_format.py", bundle / "d3_format.py")
shutil.copy2(source / "d3_runtime.py", bundle / "d3_runtime.py")
shutil.copy2(source / "NOTICE", bundle / "UPSTREAM_NOTICE")
(bundle / "requirements.txt").write_text(
    "coreai-core==1.0.0b3\ncoreai-torch==0.4.3\ntorch==2.14.0\ntorchvision==0.29.1\ntransformers==5.17.0\nnumpy==2.4.6\nPillow==12.3.0\nopencv-python-headless==5.0.0.93\nhuggingface-hub==1.33.0\naccelerate==1.15.0\nsafetensors==0.8.0\n"
)
(bundle / "NOTICE").write_text(
    (source / "NOTICE").read_text()
    + "\nCore AI conversion and host adapter by Max Farrell, 2026.\nConverted from "
    + record["id"]
    + " at "
    + record["revision"]
    + ".\nUpstream prompt formatting retained in d3_format.py.\n"
)