Image-Text-to-Text
Transformers
Safetensors
kimi_k31
text-generation
mixture-of-experts
expert-upcycling
scientific-ai
chip-design
space
physics
s-t-a-r
custom_code
8-bit precision
Instructions to use STAR-future/Trinity with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use STAR-future/Trinity with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="STAR-future/Trinity", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForSeq2SeqLM model = AutoModelForSeq2SeqLM.from_pretrained("STAR-future/Trinity", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use STAR-future/Trinity with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "STAR-future/Trinity" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "STAR-future/Trinity", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/STAR-future/Trinity
- SGLang
How to use STAR-future/Trinity with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "STAR-future/Trinity" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "STAR-future/Trinity", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "STAR-future/Trinity" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "STAR-future/Trinity", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use STAR-future/Trinity with Docker Model Runner:
docker model run hf.co/STAR-future/Trinity
Remove a local-only helper from the public repository
Browse files- tools/publish_littleboy.py +0 -101
tools/publish_littleboy.py
DELETED
|
@@ -1,101 +0,0 @@
|
|
| 1 |
-
"""Build LittleBoy (m = 256, merged active experts) shard by shard and upload it to a gated Hugging Face repository,
|
| 2 |
-
deleting each local output after upload, so a 2 TB checkpoint passes through ~60 GB of free disk. Resumable.
|
| 3 |
-
|
| 4 |
-
python tools/littleboy/publish_littleboy.py --repo STAR-future/Trinity --local <dir with some Kimi shards> --work <dir>
|
| 5 |
-
|
| 6 |
-
The token is read from andkey (STARHUGGIN entry) and never printed. Progress: <work>/progress.jsonl.
|
| 7 |
-
"""
|
| 8 |
-
import argparse
|
| 9 |
-
import json
|
| 10 |
-
import re
|
| 11 |
-
import shutil
|
| 12 |
-
import sys
|
| 13 |
-
import time
|
| 14 |
-
from pathlib import Path
|
| 15 |
-
|
| 16 |
-
HERE = Path(__file__).resolve().parent
|
| 17 |
-
sys.path.insert(0, str(HERE))
|
| 18 |
-
import expand_kimi as X # noqa: E402
|
| 19 |
-
import wsp_activate as W # noqa: E402
|
| 20 |
-
from huggingface_hub import HfApi, hf_hub_download # noqa: E402
|
| 21 |
-
|
| 22 |
-
BASE, REV, M = "moonshotai/Kimi-K3.1-Pro", "d9e99b0792a5e93b78ea9bea62a68167e36ddd9e", 256
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
def token() -> str:
|
| 26 |
-
import os
|
| 27 |
-
if os.environ.get("HF_TOKEN_FILE"): # a worker machine: a 600 file holding only the token
|
| 28 |
-
return Path(os.environ["HF_TOKEN_FILE"]).read_text(encoding="utf-8").strip()
|
| 29 |
-
lines = Path("C:/Users/Utente/Desktop/n/andkey").read_text(encoding="utf-8", errors="replace").splitlines()
|
| 30 |
-
i = next(k for k, line in enumerate(lines) if "STARHUGGIN" in line.upper())
|
| 31 |
-
return re.findall(r"hf_[A-Za-z0-9]{20,}", "\n".join(lines[i:i + 3]))[0]
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
def main(argv):
|
| 35 |
-
ap = argparse.ArgumentParser()
|
| 36 |
-
ap.add_argument("--repo", required=True)
|
| 37 |
-
ap.add_argument("--local", required=True)
|
| 38 |
-
ap.add_argument("--work", required=True)
|
| 39 |
-
ap.add_argument("--only", type=int, default=0, help="stop after this many shards (0 = all)")
|
| 40 |
-
ap.add_argument("--mod", type=int, default=1, help="run several workers: this one takes shard i when i %% mod == rem")
|
| 41 |
-
ap.add_argument("--rem", type=int, default=0)
|
| 42 |
-
ap.add_argument("--first", type=int, default=0, help="first shard index (0-based) this worker may take")
|
| 43 |
-
ap.add_argument("--last", type=int, default=10**6, help="one past the last shard index this worker may take")
|
| 44 |
-
ap.add_argument("--reverse", action="store_true", help="take shards from the highest index down")
|
| 45 |
-
a = ap.parse_args(argv)
|
| 46 |
-
api = HfApi(token=token())
|
| 47 |
-
api.create_repo(a.repo, repo_type="model", private=False, exist_ok=True)
|
| 48 |
-
api.update_repo_settings(a.repo, gated="manual")
|
| 49 |
-
work, local = Path(a.work), Path(a.local)
|
| 50 |
-
(work / "headers").mkdir(parents=True, exist_ok=True)
|
| 51 |
-
idx_path = hf_hub_download(BASE, "model.safetensors.index.json", revision=REV, local_dir=work / "base_meta")
|
| 52 |
-
wm = json.loads(Path(idx_path).read_text())["weight_map"]
|
| 53 |
-
layer_of = {}
|
| 54 |
-
for k, shard in wm.items():
|
| 55 |
-
if ".block_sparse_moe." in k:
|
| 56 |
-
layer_of.setdefault(shard, set()).add(int(k.split(".layers.")[1].split(".")[0]))
|
| 57 |
-
done = set(api.list_repo_files(a.repo))
|
| 58 |
-
n = 0
|
| 59 |
-
order = list(enumerate(sorted(set(wm.values()))))
|
| 60 |
-
for i, shard in (reversed(order) if a.reverse else order):
|
| 61 |
-
if shard in done or i % a.mod != a.rem or not a.first <= i < a.last:
|
| 62 |
-
continue
|
| 63 |
-
if api.file_exists(a.repo, shard): # another worker (PC, GCP, Colab) uploaded it meanwhile
|
| 64 |
-
continue
|
| 65 |
-
t0 = time.time()
|
| 66 |
-
src = local / shard
|
| 67 |
-
fetched = None
|
| 68 |
-
if not src.exists():
|
| 69 |
-
fetched = Path(hf_hub_download(BASE, shard, revision=REV, local_dir=work / f"in{a.rem}"))
|
| 70 |
-
src = fetched
|
| 71 |
-
if shard in layer_of:
|
| 72 |
-
if len(layer_of[shard]) != 1:
|
| 73 |
-
raise SystemExit(f"{shard}: layers {sorted(layer_of[shard])}")
|
| 74 |
-
L = next(iter(layer_of[shard]))
|
| 75 |
-
out = work / "out" / shard
|
| 76 |
-
out.parent.mkdir(exist_ok=True)
|
| 77 |
-
info = W.layer_stream(src, out, L, M)
|
| 78 |
-
else:
|
| 79 |
-
out, info = src, {"copied": True}
|
| 80 |
-
hdr, _, _ = X.read_header(out)
|
| 81 |
-
(work / "headers" / (shard + ".json")).write_text(json.dumps({k: v["shape"] for k, v in hdr.items()}))
|
| 82 |
-
api.upload_file(path_or_fileobj=str(out), path_in_repo=shard, repo_id=a.repo,
|
| 83 |
-
commit_message=f"LittleBoy shard {shard}")
|
| 84 |
-
size = out.stat().st_size
|
| 85 |
-
if out != src:
|
| 86 |
-
out.unlink()
|
| 87 |
-
if fetched:
|
| 88 |
-
fetched.unlink()
|
| 89 |
-
with open(work / "progress.jsonl", "a", encoding="utf-8") as fo:
|
| 90 |
-
fo.write(json.dumps({"shard": shard, "bytes": size, "seconds": round(time.time() - t0),
|
| 91 |
-
**{k: v for k, v in info.items() if k != "pairs"}}) + "\n")
|
| 92 |
-
print(shard, size, round(time.time() - t0), "s", flush=True)
|
| 93 |
-
n += 1
|
| 94 |
-
if a.only and n >= a.only:
|
| 95 |
-
break
|
| 96 |
-
return 0
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
if __name__ == "__main__":
|
| 100 |
-
shutil.disk_usage(".")
|
| 101 |
-
sys.exit(main(sys.argv[1:]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|