Aleksander22's picture
Slayer1B-1.09-Instruct-26.11: weights, card, notes, training code, manifests and results (history squashed; training data not published)
6071ec5
Raw History Blame Contribute Delete
1.42 kB
"""Convert a released package (model.safetensors + config.json [+ tokenizer.json]) back into the native Slayer checkpoint
format that train.py / evals.py / model_io.load read: torch.save({"model": state_dict, "config": cfg, "step": ..., "sft": ...}).
The release drops head.weight because it is tied to tok.weight; it is restored here, so the result is bit-identical in
weights to the training checkpoint the package was made from.
python to_native.py <package dir> <out.pt> [--step 95000]
Then, e.g., continue training from the E3 pre-decay point:
torchrun --nproc_per_node 8 train.py --ckpt E3_predecay.pt --data data/s3 --out runs/e5 --lr 5e-5 ...
"""
import argparse
import json
from pathlib import Path
import torch
from safetensors.torch import load_file
def main():
ap = argparse.ArgumentParser()
ap.add_argument("pkg")
ap.add_argument("out")
ap.add_argument("--step", type=int, default=95000, help="pretraining step of the base (kept for provenance)")
a = ap.parse_args()
p = Path(a.pkg)
sd = load_file(str(p / "model.safetensors"))
if "head.weight" not in sd and "tok.weight" in sd:
sd["head.weight"] = sd["tok.weight"]
cfg = json.loads((p / "config.json").read_text())
torch.save({"model": sd, "config": cfg, "step": a.step, "sft": {"converted_from": str(p)}}, a.out)
print("wrote", a.out, len(sd), "tensors")
if __name__ == "__main__":
main()