Run this model with HF Jobs
Run jeweled/inkling-2-next on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/jeweled/inkling-2-next. Ask me which dataset to train on, then push the fine-tuned model to a new private model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/jeweled/inkling-2-next on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/jeweled/inkling-2-next. Ask me which benchmark to run, then save the scores and the per-example results to a new private dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/jeweled/inkling-2-next. Push it to a new private model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use jeweled/inkling-2-next with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jeweled/inkling-2-next with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="jeweled/inkling-2-next")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("jeweled/inkling-2-next", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jeweled/inkling-2-next with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jeweled/inkling-2-next" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jeweled/inkling-2-next", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/jeweled/inkling-2-next
- SGLang
How to use jeweled/inkling-2-next 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 "jeweled/inkling-2-next" \ --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": "jeweled/inkling-2-next", "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 "jeweled/inkling-2-next" \ --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": "jeweled/inkling-2-next", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use jeweled/inkling-2-next with Docker Model Runner:
docker model run hf.co/jeweled/inkling-2-next
- Inkling 2 Next
- 1. Architectural Thesis
- 2. Deep Dive: Conditional N-Gram Architecture (
196.6BEngram + Hybrid N-Gram Speculation)- 2.1 Canonical Tokenizer Compression (
36.0%Vocabulary Collapse) - 2.2 Multi-Order Prime-Modulus N-Gram Hash Tables (
196.61BParameters) - 2.3 Why Inject at
L1andL13? Exploiting6-Layer Block Attention Residuals - 2.4 Zero-Init Context-Gated Injection & Tiered NVMe/RAM Architecture
- 2.5 Inference-Time N-Gram Synergy: Hybrid SAM + Static N-Gram + 5-Layer MTP
- 2.1 Canonical Tokenizer Compression (
- 3. MoE Compute Reallocation: Dynamic
top-pRouting & Mini Shared Expert - 4. Lossless
NVFP4-Safe Post-Training & Verifiable Multi-Turn RL - 5. Benchmarks (
Inkling 2 Nextvs.thinkingmachines/Inkling-2-Small) - License & Lineage
- 6. Marin Step 5,000 Partial Engram Checkpoint & NVMe Reconstruction
- 1. Architectural Thesis
Inkling 2 Next
Release Status β Partial Checkpoint Available (Marin Step 5,000 196.6B Engram Only; Backbone & LoRA Weights Pending Head-to-Head Benchmarking): This repository currently hosts the Marin Step 5,000 partial checkpoint of the 196.6B Conditional Engram ONLY (
16ENGDLT01sparse.delta.zstshards +8TP8 dense projection/gating shards + canonical BPE LUT, trained on163.80MMarin tokens atop the122.5M-token V18 seed =286.3Mcumulative tokens /1.92Brow updates). BaseInkling-2-Smallbackbone weights, Stage A.5 shared-expert/AttnRes weights, and Stage B0/B1 LoRA adapters are not included here yet pending head-to-head benchmark publication.
1. Architectural Thesis
thinkingmachines/Inkling-2-Small is a 594B-parameter (~17B active) hybrid local/global Mixture-of-Experts model (48 layers, 384 routed experts per layer in native NVFP4 for L0β39 and MXFP8 for L40β47, top-8 sigmoid routing, 6-layer Block Attention Residuals, and a 5-layer Multi-Token Prediction speculative drafter).
While sparse MoE scales parameter capacity efficiently, empirical layer-ablation scans on Inkling-2-Small exposed three structural bottlenecks:
- Static Lexical Reconstruction Inside Early MoE Layers: Early-to-mid MoE layers expend substantial routed-expert compute and memory bandwidth reconstructing static local N-gram collocations, multi-token code/ABI identifiers, LaTeX idioms, and named entities that do not require deep non-linear expert routing.
- Uniform
top-8Tail Noise & Missing Shared Expert: Under energy-conserving sigmoid routing (route_scale = 8.0), the 7th and 8th lowest-scoring experts on high-certainty tokens contribute marginal residual signal while paying fullNVFP4/MXFP8expert memory-read cost β yetInkling-2-Smallnatively setsn_shared_experts = 0, making naivetop-kpruning brittle without a dense fallback pathway. - Quantized Expert Fragility Under Post-Training: Directly updating
NVFP4/MXFP8routed experts during SFT or RL introduces 4-bit/8-bit dequantize-requantize drift and degrades speculative drafter acceptance.
Inkling 2 Next resolves all three bottlenecks through four co-designed architectural layers:
| Component | Base Inkling-2-Small |
Inkling 2 Next | Primary Architectural Role |
|---|---|---|---|
| Total Parameters | 594B |
790.6B (594B backbone + 196.6B Engram) |
$O(1)$ offloaded lexical & structural N-gram capacity |
| Conditional N-Gram Memory | None | 196.61B Engram at L1 & L13 (n = 2, 3, 4, 24 prime-hash heads/layer) |
Offloads static N-gram/entity recall from early MoE experts |
| Tokenizer N-Gram Addressing | Raw 201,024 BPE IDs |
Canonical LUT Compression (201,024 -> 128,650, -36.0%) |
Collapses casing, spacing, and Unicode surface variants onto shared N-gram slots |
| MoE Routing Policy | Static top-8 everywhere (100% active MoE) |
Dynamic top-p = 0.85 (k in [3, 6], mean k = 4.83) |
Cuts routed-expert memory reads by -39.6% by dropping low-weight tail experts |
| Shared Expert Pathway | n_shared_experts = 0 |
dim = 512 BF16 Mini Shared Expert (L0β47, Muon-trained) |
Always-on dense residual anchor stabilizing aggressive top-p expert shedding |
| Speculative Decoding | 5-layer MTP drafter | Hybrid Prefix-Seeded Suffix Automaton (SAM) + Static N-Gram + 5-Layer MTP | Zero-overhead N-gram continuation drafting with strict 0-ULP target verification |
| Domain RL Adaptation | Base policy | NVFP4-Safe BF16 Attention Adaptation (Dr.GRPO + ExPPO + Clip-Higher + TIS) |
Zero expert requantization; 0.0% runtime serving overhead after static BF16 merge |
2. Deep Dive: Conditional N-Gram Architecture (196.6B Engram + Hybrid N-Gram Speculation)
2.1 Canonical Tokenizer Compression (36.0% Vocabulary Collapse)
Addressing N-gram tables with raw BPE token IDs fragments statistical support across trivial surface variations (e.g., " Theorem", "theorem", "THEOREM", and Unicode compatibility forms all hash to unrelated rows).
Before computing any N-gram hash, Inkling 2 Next maps every token through a static lookup table:
- Collapses
Inkling-2-Small's201,024padded vocabulary (200,058active BPE + control tokens) down to128,650canonical equivalence classes (36.0%reduction) β nearly 2x higher canonical compression density than comparable byte-heavy tokenizers. - Special wire/control tokens (chat turn delimiters,
<think>reasoning spans, and structured tool-invocation tags) map to dedicated isolated sentinels so structural control boundaries never alias with natural-language N-grams.
2.2 Multi-Order Prime-Modulus N-Gram Hash Tables (196.61B Parameters)
At each Engram injection layer, Inkling 2 Next extracts causal suffix N-grams of orders $n \in {2, 3, 4}$ over the canonically compressed token stream:
- Multi-Head Prime Hashing: Each of the
3N-gram orders is hashed across8independent heads (3 x 8 = 24hash heads per layer,head_dim = 256, concatenatedengram_dim = 6,144). Each head $h \in {0, \dots, 23}$ indexes a table of distinct prime modulus $P_h \approx 16\text{M}$ rows (~384Mrows per layer), eliminating systematic modular collision patterns across orders and heads: $$(384,006,168 + 384,016,682) \times 256 = 196,613,849,600 \text{ parameters } (\mathbf{196.61\text{B}})$$ - Tail-Noise Filtering (
min_count = 3): Rare4-grams appearing fewer than3times in the training corpus are masked from table updates, preventing single-occurrence sequence memorization and hash-collision pollution while concentrating capacity on reusable mathematical, code, and domain N-grams.
2.3 Why Inject at L1 and L13? Exploiting 6-Layer Block Attention Residuals
A naive N-gram lookup design either attaches tables to every transformer layer (multiplying metadata and projection overhead by 48x) or injects only at the input embedding (where early residual updates overwrite lexical detail).
Inkling-2-Small organizes its 48 layers into eight 6-layer Block Attention Residual groups (n_layers_per_attn_res_block = 6), where layers attend directly over normalized block-level residual states via learned inter-block queries:
Input -> [L0 -> L1(Engram #1) -> L2..L5] ==> Block 0 Residual
|
+--> [L6..L11] ==> Block 1 Residual
|
+--> [L12 -> L13(Engram #2) -> L14..L17] ==> Block 2 Residual
|
+--> [L18..L47] (Global + Local Reasoning Layers)
L1(Early Lexical Offload): Placed immediately afterL0contextualizes raw token embeddings, supplying $O(1)$ surface/phrase N-grams right at the start of Block 0.L13(Mid-Depth Structural & Compositional N-Grams): Placed near the entry of Block 2, after two full local/global attention cycles (L5,L11), capturing higher-order syntactic, API, and symbolic patterns while remaining directly reachable by deeper layers (L18βL47) via Block Attention Residuals.- Empirical Verification (
engram_cushion_bpb): In single-layer expert-shedding sweeps acrossL0βL17(top-8 -> top-6 / top-4with vs. without Engram), 31 of 32 candidates acrossL0βL15exhibited positive Engram cushion β proving thatL1+L13N-gram memory directly absorbs the representational load lost when pruning early-to-mid MoE experts, before naturally tapering off atL16βL17where abstract reasoning dominates.
2.4 Zero-Init Context-Gated Injection & Tiered NVMe/RAM Architecture
Raw N-gram embeddings are static with respect to broader context (e.g., "bank" in finance vs. systems memory banking). Inkling 2 Next gates every retrieved $6,144$-d N-gram vector against the live hidden state $h_\ell \in \mathbb{R}^{4608}$:
- Project the concatenated
24-head N-gram vector via a TP-sharded linear mapwkvinto key $k_e$ and value $v_e$. - Modulate $v_e$ by normalized query-key agreement $\sigma(\text{RMSNorm}(h_\ell) \odot \text{RMSNorm}(k_e))$ and scale by a zero-initialized scalar residual gate ($\alpha_\ell = 0$ at Step 0).
- Because $\alpha_\ell = 0$ at initialization, attaching
196.6Bparameters introduces exact0.000$\Delta\text{bpb}$ perturbation at Step 0 and smoothly opens ($\alpha_1 \approx 0.36$, $\alpha_{13} \approx 0.65$) only where N-gram lookups genuinely reduce cross-entropy and self-teacher KL.
- Because $\alpha_\ell = 0$ at initialization, attaching
- Zero-Penalty Serving &
SparseRowAdagradTraining: Because N-gram indices depend only on input token IDs (known beforeL0executes!),L1andL13lookups are prefetched asynchronously from sharded NVMe backing stores through a power-of-2 direct-mapped Zipfian RAM/GPU hot cache (~80β90%hit rate in2β4 GiB/shard), hiding off-chip latency completely behindL0andL2βL12compute. During retrofit training,SparseRowAdagradmaintains a single FP32 scalar per row (0.38 GiB/shard) and updates only active rows touched in each micro-batch.
2.5 Inference-Time N-Gram Synergy: Hybrid SAM + Static N-Gram + 5-Layer MTP
In addition to representation-level Engram tables at L1/L13, Inkling 2 Next exploits N-gram structure during decoding by coupling Inkling-2-Small's neural 5-layer MTP drafter (32,768 frequency-ranked hot vocabulary shortlist) with an online Suffix Automaton (SAM) + static corpus N-gram table:
- Multi-Turn Prefix Seeding: In agentic code, proof, and security workflows, variable names, file paths, JSON tool schemas, and Lean/Solidity/C identifiers repeat heavily across turns. Seeding the Suffix Automaton from cached prompt prefixes allows $O(1)$ exact multi-token span proposals whenever high-confidence N-gram matches exist, seamlessly handing off to the 5-layer neural MTP drafter on novel reasoning steps.
- Multimodal &
0-ULPTarget Safety: Contiguous vision-pad token runs are collapsed to bounded sentinels so image inputs never pollute text N-gram transitions, and every drafted token β whether proposed by SAM, static N-grams, or neural MTP β is verified by the full target model with zero-ULP greedy invariance (and exact residual rejection recoverynorm(max(0, p - q))fortemperature > 0).
3. MoE Compute Reallocation: Dynamic top-p Routing & Mini Shared Expert
Once 196.6B Engram offloads static lexical memory from L0βL15, Inkling 2 Next reallocates active MoE compute onto a sharper Pareto frontier:
- Dynamic
top-p = 0.85Routing (k_min = 3, k_max = 6):- Replaces static
top-8expert selection across all48layers with cumulative router-probability thresholding: each token activates only as many top-ranked experts (between 3 and 6) as needed to cover85%of normalized routing probability mass. - Reduces mean active experts from
8.00 -> 4.83(60.38%active MoE,-39.62%routed expert reads) β concentrating bandwidth on high-leverage reasoning tokens (k -> 6) while fast-pathing predictable syntax/boilerplate tokens (k -> 3).
- Replaces static
- Muon-Trained
dim = 512BF16 Mini Shared Expert (L0βL47):- Attaches a compact always-on BF16 shared expert (
hidden = 4,608 -> d_shared = 512 -> 4,608) usingInkling-2-Small's exact interleaved softcapped SiTU activation (gate_cap = 4.0,up_cap = 25.0). - Jointly trained via 5-iteration quintic Newton-Schulz Muon orthogonalized updates alongside
48router scale calibrations,96Block Attention Residual queries, and8global-attention (L5, 11, 17, 23, 29, 35, 41, 47) BF16 adapters under forward Self-Teacher KL regularization so probability calibration and MTP speculative acceptance remain tightly anchored.
- Attaches a compact always-on BF16 shared expert (
4. Lossless NVFP4-Safe Post-Training & Verifiable Multi-Turn RL
To specialize Inkling 2 Next across Mathematics, Cybersecurity, and Applied Cryptography without degrading quantized expert precision or general capabilities:
- 100% Frozen Quantized Experts (
0Requantization Error): All384NVFP4(L0β39) andMXFP8(L40β47) routed experts remain bit-for-bit untouched. Trainable rank-16/32 adapters attach strictly to BF16 attention projections (wq_du,wk_dv,wv_dv,wo_udacrossL1β47) and fold losslessly into BF16 weights at load time prior to kernel prepacking (0.0%runtime serving latency penalty). - Stacked-Champion Reference Anchoring: Sequential RL iterations pre-merge the promoted prior champion into the frozen reference policy (
KL = 0at Step 0), preventing KL gravity from pulling newly acquired multi-turn skills back toward the pre-RL base policy. - Verifiable Execution Harnesses & RL Mechanics: Trained strictly against real executable verifiers β
clang/AddressSanitizer/MemorySanitizer/UndefinedBehaviorSanitizercrash reproduction & minimal patching, standaloneLean 4kernel proof checking (0sorry/axiomescapes), multi-fileFoundry(forge test) differential Solidity exploit & patch verification, finite-field R1CS / Fiat-Shamir / Merkle verifier soundness forging, and Olympiad mathematics β using:- Length-Unbiased
Dr.GRPOsequence loss normalization (preventing long16Ktrajectories from diluting gradient signal or rewarding brevity/stall hacks), ExPPOprompt-relative surprisal advantage shaping within equal-reward classes,- Asymmetric DAPO
Clip-Higher([0.20, 0.28]) to preserve exploration on low-prior reasoning tokens, - Truncated Importance Sampling (
TIS) against rollout behavior log-probabilities, and - Post-RL Weight-Space Trajectory Blending (
50/50Raw + Step-EMA) to combine peak late-stage long-context discovery with smooth early-stage calibration.
- Length-Unbiased
5. Benchmarks (Inkling 2 Next vs. thinkingmachines/Inkling-2-Small)
Coming next: Standardized, apples-to-apples evaluations comparing Inkling 2 Next directly against base thinkingmachines/Inkling-2-Small under identical prompts, tool harnesses, context caps, and 0-ULP decoding settings will be added to this section prior to weight upload.
License & Lineage
Derived from thinkingmachines/Inkling-2-Small under the Apache-2.0 License.
6. Marin Step 5,000 Partial Engram Checkpoint & NVMe Reconstruction
6.1 Checkpoint Summary
- Source Run:
gs://calibre-web-436521-engram-marin/tpu_marin_run1/(v5p-16Cloud TPU,TP = 8,full_196bpreset) - Training Progress (
resume_state.json): Step5,000(batches_consumed = 10,000,163,800,000Marin tokens trained atop the122.5M-token V18 seed =286.3Mcumulative tokens,1,924,683,120sparse row updates) - Layer 1 Total Active Rows (
count >= 3):222,398,807/384,244,442(57.880%),1.res_gate = 0.709562(fromengram_dense_tpu_r0.pt) - Layer 13 Total Active Rows (
count >= 3):223,011,847/387,123,992(57.607%),13.res_gate = -1.355688(fromengram_dense_tpu_r0.pt) - Combined Active Rows (
L1 + L13,count >= 3):445,410,654/771,368,434(57.743%) - Scope (
29files total): Hosts the 196.6B Conditional Engram partial checkpoint ONLY. BaseInkling-2-Smallbackbone weights, Stage A.5shared_expert_a5/attn_res_queries, Stage B0/B1 LoRA adapters, and Adagrad/Adam optimizer states (sparse_accum_*,dense_opt_state_*) are not included here yet pending head-to-head benchmark publication.
6.2 Per-Rank Active Row Breakdown (count >= 3)
| TP8 Rank | L1 Total Rows | L1 Active (>=3) |
L13 Total Rows | L13 Active (>=3) |
|---|---|---|---|---|
r0 |
48,030,413 |
27,813,893 (57.909%) |
48,390,341 |
27,868,377 (57.591%) |
r1 |
48,030,449 |
27,811,180 (57.903%) |
48,390,387 |
27,866,988 (57.588%) |
r2 |
48,030,471 |
27,787,420 (57.854%) |
48,390,439 |
27,891,902 (57.639%) |
r3 |
48,030,549 |
27,811,777 (57.904%) |
48,390,469 |
27,892,803 (57.641%) |
r4 |
48,030,585 |
27,784,418 (57.847%) |
48,390,531 |
27,890,817 (57.637%) |
r5 |
48,030,613 |
27,812,026 (57.905%) |
48,390,583 |
27,865,923 (57.585%) |
r6 |
48,030,665 |
27,786,480 (57.852%) |
48,390,613 |
27,865,936 (57.585%) |
r7 |
48,030,697 |
27,791,613 (57.862%) |
48,390,629 |
27,869,101 (57.592%) |
| Total | 384,244,442 |
222,398,807 (57.880%) |
387,123,992 |
223,011,847 (57.607%) |
6.3 Repository File List (29 Files)
.gitattributesβ Git LFS tracking rules (*.delta.zst,*.zst,*.pt,*.npy, etc.)README.mdβ Architectural thesis & Marin Step5,000partial Engram checkpoint documentationresume_state.jsonβ Exact TPU training step metadata (steps_done = 5000,batches_consumed = 10000,total_tokens_trained = 163800000,total_row_updates = 1924683120)inkling2_canonical_lut.npyβ Canonical BPE token lookup table (201,024 -> 128,650,INKLING_ENGRAM_LUT)engram_dense_tpu_r{0..7}.pt(8files) β TP8-sharded PyTorch state dicts ({1,13}.{wkv, k_weight, q_weight, res_gate}) compatible withvllm_v18/engram_v18_runtime.py(INKLING_ENGRAM_DENSE_PREFIX)engram_L1_r{0..7}.delta.zst(8files) β zstd-compressedENGDLT01sparse delta shards for Layer 1 (active BF16 rows + fulluint16counts + embedded SHA-256 digests forindices,weights, andcounts)engram_L13_r{0..7}.delta.zst(8files) β zstd-compressedENGDLT01sparse delta shards for Layer 13SHA256SUMSβ Exact SHA-256 manifest of all checkpoint files
6.4 Reconstructing NVMe Serving Shards (engram_sparse_delta.py apply-nvme)
tpu_engram_train.py zero-initializes the full 196.6B sparse Engram table in host RAM, so inactive (count < 3) rows are exact 0.0 BF16 (0x0000). On each TP8 serving node r (0..7), create sparse zero-initialized .bf16.bin files via truncate on ext4 and apply the .delta.zst shards:
RANK=0 # set 0..7 on each TP8 node
SSD_DIR="/home/jeweled/ernie55-engram/ssd_inkling2_v18_purified_196b"
mkdir -p "$SSD_DIR"
# 1. Inspect local_rows from ENGDLT01 header and pre-create sparse zero-init .bf16.bin files
for LID in 1 13; do
LOCAL_ROWS=$(python3 src/engram_sparse_delta.py inspect \
--delta "engram_L${LID}_r${RANK}.delta.zst" | python3 -c "import sys,json; print(json.load(sys.stdin)['local_rows'])")
rm -f "$SSD_DIR/engram_L${LID}_r${RANK}.bf16.bin"
truncate -s "$((LOCAL_ROWS * 256 * 2))" "$SSD_DIR/engram_L${LID}_r${RANK}.bf16.bin"
# 2. Apply sparse delta (verifies ENGDLT01 magic + indices/weights/counts SHA-256s)
python3 src/engram_sparse_delta.py apply-nvme \
--delta "engram_L${LID}_r${RANK}.delta.zst" \
--ssd-dir "$SSD_DIR"
done
Then copy engram_dense_tpu_r${RANK}.pt to your INKLING_ENGRAM_DENSE_PREFIX (<prefix>_r${RANK}.pt) and point INKLING_ENGRAM_DIR="$SSD_DIR" and INKLING_ENGRAM_LUT=/path/to/inkling2_canonical_lut.npy when launching vllm_v18.
Model tree for jeweled/inkling-2-next
Base model
thinkingmachines/Inkling-2-Small