trnr release bundle (42 KB): embeds the quantizer, the GGUF converter, the fork patcher and the model card
Browse files- UPLOAD_1_trnr_ship.py +21 -5
UPLOAD_1_trnr_ship.py
CHANGED
|
@@ -19,6 +19,8 @@ MID = "allenai/OLMoE-1B-7B-0125-Instruct"
|
|
| 19 |
HF_TOKEN = "__HF_TOKEN__" # injected by the runner cell; a real token here makes
|
| 20 |
# HuggingFace REJECT the upload (its secret scanner).
|
| 21 |
REPO_NAME = "OLMoE-1B-7B-0125-Instruct-ternary-tq1_0"
|
|
|
|
|
|
|
| 22 |
B = lambda t: print("=" * 70 + "\n" + t + "\n" + "=" * 70, flush=True)
|
| 23 |
P = lambda s: print(" " + s, flush=True)
|
| 24 |
SH = lambda c: subprocess.run(c, shell=True).returncode
|
|
@@ -785,10 +787,21 @@ embeddings, the output head and the router stay F16.
|
|
| 785 |
3. Canonical GPTQ error feedback across blocks, with a per-expert Hessian for down_proj.
|
| 786 |
4. Bytes packed into TQ1_0's layout, verified byte-identical to llama.cpp's own encoder.
|
| 787 |
|
| 788 |
-
## Requirements
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 792 |
|
| 793 |
## Honest limitations
|
| 794 |
- __RATIO__x fp16 perplexity, and that is the price of ternary itself: the scalar three-level
|
|
@@ -815,6 +828,8 @@ MID = "allenai/OLMoE-1B-7B-0125-Instruct"
|
|
| 815 |
HF_TOKEN = "__HF_TOKEN__" # injected by the runner cell; a real token here makes
|
| 816 |
# HuggingFace REJECT the upload (its secret scanner).
|
| 817 |
REPO_NAME = "OLMoE-1B-7B-0125-Instruct-ternary-tq1_0"
|
|
|
|
|
|
|
| 818 |
B = lambda t: print("=" * 70 + "\n" + t + "\n" + "=" * 70, flush=True)
|
| 819 |
P = lambda s: print(" " + s, flush=True)
|
| 820 |
SH = lambda c: subprocess.run(c, shell=True).returncode
|
|
@@ -907,7 +922,8 @@ P("ppl %.4f ratio vs f16 %.4f = %.3fx" % (ppl, F16, ratio))
|
|
| 907 |
|
| 908 |
B("6/8 model card from the template + upload to HuggingFace")
|
| 909 |
card = (open(K + "/card.md").read().replace("__SIZE__", "%.3f" % (os.path.getsize(DST) / 1e9))
|
| 910 |
-
.replace("__PPL__", "%.4f" % ppl).replace("__RATIO__", "%.2f" % ratio).replace("
|
|
|
|
| 911 |
open(K + "/README.md", "w").write(card)
|
| 912 |
from huggingface_hub import whoami, create_repo, upload_file
|
| 913 |
me = whoami(token=HF_TOKEN)["name"]; REPO = "%s/%s" % (me, REPO_NAME)
|
|
|
|
| 19 |
HF_TOKEN = "__HF_TOKEN__" # injected by the runner cell; a real token here makes
|
| 20 |
# HuggingFace REJECT the upload (its secret scanner).
|
| 21 |
REPO_NAME = "OLMoE-1B-7B-0125-Instruct-ternary-tq1_0"
|
| 22 |
+
FORK_URL = "https://github.com/fourthyplayz/trnr.cpp" # PUBLISHED: real fork of
|
| 23 |
+
# ggml-org/llama.cpp, branch `trnr-rot`, one commit over PIN (written into the card)
|
| 24 |
B = lambda t: print("=" * 70 + "\n" + t + "\n" + "=" * 70, flush=True)
|
| 25 |
P = lambda s: print(" " + s, flush=True)
|
| 26 |
SH = lambda c: subprocess.run(c, shell=True).returncode
|
|
|
|
| 787 |
3. Canonical GPTQ error feedback across blocks, with a per-expert Hessian for down_proj.
|
| 788 |
4. Bytes packed into TQ1_0's layout, verified byte-identical to llama.cpp's own encoder.
|
| 789 |
|
| 790 |
+
## Requirements -- you MUST use the companion fork
|
| 791 |
+
The model stores a rotation tensor `trnr.rot` that upstream llama.cpp does not know about. The
|
| 792 |
+
companion fork **trnr.cpp** adds it: one commit over llama.cpp at __PIN8__, which is a
|
| 793 |
+
`trnr.rot` ggml tensor plus one graph line in `src/models/olmoe.cpp`. **On stock llama.cpp the
|
| 794 |
+
model loads and then produces garbage**, because the expert input never gets rotated.
|
| 795 |
+
|
| 796 |
+
- fork: __FORK_URL__ -- branch `trnr-rot`, so: `git clone -b trnr-rot __FORK_URL__`
|
| 797 |
+
- or apply `trnr_rot.patch` (4 KB, also in this repo) to a clean llama.cpp checkout:
|
| 798 |
+
`git clone https://github.com/ggml-org/llama.cpp && cd llama.cpp && git checkout __PIN8__ && git apply trnr_rot.patch`
|
| 799 |
+
- or use the prebuilt patched tree shipped as `trnr.cpp.tar.gz`
|
| 800 |
+
- build: `cmake -B build -DCMAKE_BUILD_TYPE=Release -DGGML_CUDA=OFF && cmake --build build -C Release -j --target llama-cli llama-perplexity`
|
| 801 |
+
|
| 802 |
+
Sanity check after building: this model must give ppl ~__RATIO_TXT__ on wikitext-2-raw at
|
| 803 |
+
8x512 tokens. If it gives thousands, the rotation tensor is not being read -- you are on stock
|
| 804 |
+
llama.cpp or the patch did not apply.
|
| 805 |
|
| 806 |
## Honest limitations
|
| 807 |
- __RATIO__x fp16 perplexity, and that is the price of ternary itself: the scalar three-level
|
|
|
|
| 828 |
HF_TOKEN = "__HF_TOKEN__" # injected by the runner cell; a real token here makes
|
| 829 |
# HuggingFace REJECT the upload (its secret scanner).
|
| 830 |
REPO_NAME = "OLMoE-1B-7B-0125-Instruct-ternary-tq1_0"
|
| 831 |
+
FORK_URL = "https://github.com/fourthyplayz/trnr.cpp" # PUBLISHED: real fork of
|
| 832 |
+
# ggml-org/llama.cpp, branch `trnr-rot`, one commit over PIN (written into the card)
|
| 833 |
B = lambda t: print("=" * 70 + "\n" + t + "\n" + "=" * 70, flush=True)
|
| 834 |
P = lambda s: print(" " + s, flush=True)
|
| 835 |
SH = lambda c: subprocess.run(c, shell=True).returncode
|
|
|
|
| 922 |
|
| 923 |
B("6/8 model card from the template + upload to HuggingFace")
|
| 924 |
card = (open(K + "/card.md").read().replace("__SIZE__", "%.3f" % (os.path.getsize(DST) / 1e9))
|
| 925 |
+
.replace("__PPL__", "%.4f" % ppl).replace("__RATIO__", "%.2f" % ratio).replace("__RATIO_TXT__", "%.2fx fp16 (%.2f)" % (ratio, ppl))
|
| 926 |
+
.replace("__PIN8__", PIN[:8]).replace("__FORK_URL__", FORK_URL or "(not published yet -- trnr_rot.patch below is the whole fork)"))
|
| 927 |
open(K + "/README.md", "w").write(card)
|
| 928 |
from huggingface_hub import whoami, create_repo, upload_file
|
| 929 |
me = whoami(token=HF_TOKEN)["name"]; REPO = "%s/%s" % (me, REPO_NAME)
|