Repository navigation
Inkling 2, phase 1: the file format and a reference forward pass, checked on the real model (#974) - #981
Draft
mrsirg97-rgb wants to merge 1 commit into
Draft
Inkling 2, phase 1: the file format and a reference forward pass, checked on the real model (#974)#981mrsirg97-rgb wants to merge 1 commit into
mrsirg97-rgb wants to merge 1 commit into
Conversation
…cked on the real model (mw00#974) tools/inkling2_gguf.py writes the checkpoint in the layout of llama.cpp's Inkling 2 conversion (ggml-org/llama.cpp#32187), what unsloth's GGUFs ship: the same 1,260 tensors and keys as their UD-IQ1_S, 653 F32 tensors bit-equal. ref/inkling2.py is the forward over any inkling2 GGUF in float64, each step recorded. Against transformers: a small random model within 6.4e-6, the real model (256 tokens, all 48 layers) within KL 1.4e-11, the same top-1 token at every position. ref/load.py reads NVFP4 and unsloth's IQ types. docs/INKLING2.md: the model, the format's conventions, what maps onto Maya.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #974. This is the groundwork for an Inkling-2-Small engine, done the way GLM's started (docs/GLM5-FLASH.md's phase
1: the format,
ref/glm.py, a tiny test model): it does not run Inkling in Maya yet - no kernels, no engine. Itpins down exactly what an engine has to compute and checks it against transformers, so the kernels can be written
against it a step at a time.
What's in it
tools/inkling2_gguf.py- the checkpoint as aninkling2GGUF in the layout of llama.cpp's Inkling 2conversion (model : add Inkling 2 (stacked on Inkling 1) ggml-org/llama.cpp#32187, draft), which is what unsloth/Inkling-2-Small-GGUF ships, so an engine
that reads it reads unsloth's files too. Written from that PR's conversion; its code is not copied or run here.
The experts keep their original bits (NVFP4 with a scale per expert; layers 40-47's MXFP8 as exact BF16).
Against unsloth's UD-IQ1_S:
--plan --against: the same 1,260 tensors, name for name and shape for shape; F32 in the same places; everyinkling2.*key the same value.scales, relative projections, residual queries, the router and its bias, the experts' scales): bit-equal to
unsloth's bytes.
ref/inkling2.py- the forward pass over anyinkling2GGUF in float64, inref/glm.py's conventions, witheach step a kernel produces recorded under a name (
--dump-dir). Its docstring is the forward written out.ref/load.py- reads NVFP4 and the IQ types unsloth's quants use (block sizes checked against gguf-py's).tests/inkling2_ref_test.py- a small random Inkling 2 built by transformers, written as the checkpoint(NVFP4 and MXFP8 experts, BF16 dense), converted, read back by the reference: over 300 tokens (past the window,
the relative extent and the log-scaling floor) max |dlogp| 6.4e-6, max KL 1.6e-12, top-1 100%. 4 s. Each of
these breaks fails it: the dynamic conv's taps in the wrong order, the sink dropped, the log scaling dropped, an
expert's scale dropped, the stream not restarted at a block boundary, the residual norm's eps, the window off by
one, the selection bias in the weights.
tests/inkling2_real_check.py- the real model (below).docs/INKLING2.md- the model, the format's conventions a kernel has to follow (the conv folds, the expertscales, the residual queries), what maps onto Maya's engines and what's new, memory.
On the real model
The real Inkling-2-Small converted (11 files, 484 GB, as unsloth's BF16), through the reference, against
transformers' own decoder layers over the original checkpoint (fp32 on one RTX 5090, every expert decoded from the
checkpoint's bits), 256 tokens, all 48 layers:
transformers' greedy answer on the same weights to "In two sentences: why does a short convolution before attention
help a language model?" (thinking effort
none, cut at 32 tokens):What it needs
transformers' main with
inkling2(from 109a7d19bf; no release has it yet - the tests skip without it) and gguf-pywith NVFP4 (llama.cpp's). No build change; nothing in
src/changes.Next
The kernels for what's new to Maya (the attention's relative bias, sinks and clips; the short convs; the attention
residuals; the expert scale with the softcapped SwiGLU), each checked against the reference's recorded steps, then
the engine. Happy to take those on, or to leave it here as a base if you'd rather build it yourself.