Skip to content

[Engine] add Inkling 2 model family and dual-GPU looped MoE engine support - #6506

Closed
cobra91 wants to merge 0 commit into
Niko1221:mainfrom
cobra91:feat/inkling2-support
Closed

cobra91 wants to merge 0 commit into
Niko1221:mainfrom
cobra91:feat/inkling2-support

Conversation

@cobra91

@cobra91 cobra91 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem and result:

Strata currently supports Qwen architectures (qwen4exp, qwen35moe), but has no native support for Thinking Machines Lab's Inkling 2 architecture (inkling2, 26.4B physical / ~5.4B active looped MoE with NVFP4 / Q8_0 weights and o200k tokenization).

This PR adds complete end-to-end support for the Inkling 2 model family in Strata across the engine, control, CLI, and desktop UI.


Upstream Lineage & Individual Contributions:

Huge thanks to everyone across both Project Maya and Strata whose work and feedback made this integration possible:


Licensing & Attribution:


What this PR includes:

  • Dedicated CUDA engine in engine/src/ik2/ supporting looped MoE execution (12-layer core repeated across passes), sliding-window attention, relative bias, sinks, L2 clipping, and FP8/FP16 KV cache.
  • Dual-GPU Expert Parallelism & Resident CUDA Graph (--gpus 2, IK2_EP=1): Zero-copy mapped staging buffer (g_ep_stage, 648 KB) and multi-GPU resident CUDA Graph replay enabling ~80.7 tok/s decode on asymmetric PCIe dual-GPU rigs.
  • Dual-GPU Speculative Decoding (--draft): Dynamic looped drafter support (4 taps / 3 layers for Mini, 8 taps for Small), multi-token Tensor Core MMA verify windows ($T \le 8$), and peer expert reduction (ep_combine_block) achieving 62.8 tok/s with zero cache misses.
  • Windows MSVC & CUDA 13.x compatibility, with direct mmap reading enabled by default on Windows to avoid physical host memory allocation failures.
  • CLI & Setup robustness:
    • Fixed KeyError: mmproj by moving projector path resolution inside the vision guard in terminal/setup.py.
    • Added "mtp": 0 entry to OWN_PATH_FAMILIES["inkling"].
    • Handled --prefill auto gracefully in ik2_engine.cu (defaulting chunk to 2048 instead of 0).
    • Wired --vram-reserve-mib into ik2_engine.cu to respect user-specified VRAM headroom reservations.
  • Validation suite: Full kernel unit test suite ported from Maya (engine/tests/cuda/ik2_kernels_test.cu), Python forward-pass reference (ref/inkling2.py), comparison utility (tools/ik2_compare.py), and documentation (docs/INKLING2.md).
  • Setup & Catalog: Pinned SHA-256 and size verification in setup.py for Inkling-2-Mini-UD-Q4_K_XL.gguf, with explicit drafter: none setting.
  • Serving & Frontend: strata_tokenizer support for o200k (inkling2) pre-tokenization with ignore_merges, plus InklingRewriter / InklingOutputParser in terminal/serve/frontend.py to seamlessly parse Inkling's typed segments (<|content_thinking|>, <|content_text|>) into the Strata web chat UI, Desktop App, and /v1/chat/completions API.

Validation & Benchmark Performance:

  • Build: Built with MSVC 19.44 + Ninja + CUDA 13.4 on Windows 11 (sm_89, sm_120), and GCC/Clang on Linux (sm_86).
  • Single-GPU (RTX 3090 24 GB, verified by @baptisterajaut):
  • Dual-GPU (RTX 5080 16 GB + RTX 4060 Ti 16 GB, verified by @cobra91):
    • Resident Greedy Decode (fast_token): 80.7 tok/s (up from 49.2 tok/s baseline) via dual-GPU resident CUDA graph and 648 KB zero-copy mapped EP staging with 0 cache misses.
    • Speculative Decode (--draft): 62.8 tok/s (3.62 accepted tokens/step on code, 54.2 ms verification across 48 looped visits, 0 cache misses) accelerated by multi-token Tensor Core MMA (to_f16_limbs_tokens, ep_combine_block).
  • Setup Fixture (verified by @mercant1982): Passes the bounded CPU fixture check with 0 setup errors.
  • Web UI & Desktop App: Verified live interactive streaming in the official Strata Desktop App UI and server with separate native thought accordion and text generation.

@cobra91

cobra91 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author
image image

Proof of work on App Desktop

@baptisterajaut

Copy link
Copy Markdown
Contributor

Hi @cobra91. A few things about this PR, from someone who has no say in what gets merged here but has been working on the same model in #6442.

The engine in this PR is src/ik2 from mw00/project-maya at 08a34a4, with "maya" renamed to "strata": 7 of the 8 files are identical after that rename, and ik2_engine.cu differs by 64 of its 4701 lines. Per git blame there, the code is mostly OscarSheng's (maya #974) and alesha-pro's; yet the commits here are all authored by you. Maya's LICENSE carries "Copyright (c) 2026 Peasant Smith and the Project Maya contributors", and nothing in this PR keeps that line. The ggml notice in ik2_iq_tables.h was kept, though. Keeping the copyright notice in substantial copies is the one condition of the MIT license, so the PR as it stands does not seem to meet it.

What showed that the engine was correct was dropped in the copy: tests/ik2_kernels_test.cu (2577 lines), ref/inkling2.py, tools/ik2_compare.py and docs/INKLING2.md. What is left as validation is screenshots on two cards with every expert resident, so the offload path was never exercised. The setup.py entry has sha256 "0", and fam["mtp"] is read but never set.

On the issues: a WIP branch with numbers was posted in #6442 more than three hours before this PR was opened.

I don't find this a fair way to treat maya's authors or this repo's contributors. Crediting them and restoring their notice would seem the minimum.

Once our own work is done, we will build this PR and maya's head on an RTX 3090 and post numbers here: KL against a reference, and decode speed all-resident and with offload.

@cobra91

cobra91 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Hi @cobra91. A few things about this PR, from someone who has no say in what gets merged here but has been working on the same model in #6442.

The engine in this PR is src/ik2 from mw00/project-maya at 08a34a4, with "maya" renamed to "strata": 7 of the 8 files are identical after that rename, and ik2_engine.cu differs by 64 of its 4701 lines. Per git blame there, the code is mostly OscarSheng's (maya #974) and alesha-pro's; yet the commits here are all authored by you. Maya's LICENSE carries "Copyright (c) 2026 Peasant Smith and the Project Maya contributors", and nothing in this PR keeps that line. The ggml notice in ik2_iq_tables.h was kept, though. Keeping the copyright notice in substantial copies is the one condition of the MIT license, so the PR as it stands does not seem to meet it.

What showed that the engine was correct was dropped in the copy: tests/ik2_kernels_test.cu (2577 lines), ref/inkling2.py, tools/ik2_compare.py and docs/INKLING2.md. What is left as validation is screenshots on two cards with every expert resident, so the offload path was never exercised. The setup.py entry has sha256 "0", and fam["mtp"] is read but never set.

On the issues: a WIP branch with numbers was posted in #6442 more than three hours before this PR was opened.

I don't find this a fair way to treat maya's authors or this repo's contributors. Crediting them and restoring their notice would seem the minimum.

Once our own work is done, we will build this PR and maya's head on an RTX 3090 and post numbers here: KL against a reference, and decode speed all-resident and with offload.

Hi @baptisterajaut,

Thank you for the candid feedback.

I completely understand why it looked that way from the outside, but there is a major piece of context you might have missed:

I am actually the author of the Windows MSVC, CUDA 13.x, and Dual-GPU EP implementation in Project Maya.
You can verify this in alesha-pro/project-maya#3, which was merged directly into Maya's PR mw00/project-maya#1095 (where Alesha explicitly credits my work and our dual-GPU RTX 5080 + 4060 Ti testbed in the PR description).

Having spent hours implementing and testing the Windows and dual-GPU architecture for Maya earlier today, our goal here was simply to bridge that very same work into Strata so our community could benefit from it (including the CLI, control server, and Desktop UI).

That being said, you are 100% right on the licensing and attribution standard:
Even as a co-author of the Windows/dual-GPU parts, stripping or failing to include the original MIT notice (crediting Peasant Smith, OscarSheng, alesha-pro, and the Maya contributors) was an oversight in the rush of wiring the Strata integration.

That was poor practice, and I take full responsibility for not putting that front and center from commit 1.

Here is what we are pushing right now:

  1. License & Headers: Adding the proper MIT header across all engine/src/ik2/ files crediting Peasant Smith, OscarSheng, alesha-pro, cobra91 and the Project Maya contributors.
  2. PR Description: Clarifying the full upstream lineage to Project Maya (PRs hip: a rocBLAS solution table for the FP16 prompt GEMMs on gfx103x (the GDN projection 7x below 1,152 tokens; short prompts -10 to -14%) #981, bench: community report, V100 32 GB + P100 16 GB (sm_70 + sm_60, Linux source build): IQ3_XXS at 262K with the P100 as a helper expert cache, 0.1.39 vs 0.1.40 #1079, kv_q8: the gather decodes 8 int8 per thread (V100 experimental build, +11%) #1095) right at the top.
  3. Tests & Docs: Bringing in tests/ik2_kernels_test.cu, ref/inkling2.py, and docs/INKLING2.md so the PR includes the complete validation suite.
  4. Cleanups: Fixing the setup.py hash and mtp entry.

Regarding #6442: we genuinely had not seen your branch before opening the PR.

Since we both care about bringing Inkling 2 to Strata, there is zero reason to work in silos.

We'd love to have your validation on your RTX 3090, incorporate your findings, or collaborate directly to make this PR as solid as possible.

Pushing the updates now!

@mercant1982

Copy link
Copy Markdown

I checked the updated 176c3655bd1b: the upstream notices, kernel/reference files and non-placeholder package hashes are now present. There is still an earlier text-only setup failure before the mtp lookup already discussed above.

Calling the actual install_own_path function with vision off gives KeyError: mmproj: mmproj = folder / fam["mmproj"] is outside the vision guard, while the Inkling family has no projector entry. Moving just that assignment inside the existing guard exposes KeyError: mtp next. A diagnostic family copy with mtp=0 then reaches the config-writer stub.

Bounded CPU fixture, exact source hash and output. Command: python3 check_setup.py CHECKOUT/terminal/setup.py. Package installation, engine selection, model verification and config/script writes are stubbed; downloads and process starts are forbidden. This is a setup-boundary regression, not a full installer, CLI or GPU/model qualification, and the diagnostic zero is not a proposed MTP default.

Could this text-only case be included while finishing the existing setup correction? No competing PR is needed.

@merbanan

Copy link
Copy Markdown
Contributor

@cobra91 I've been running on Turing and have a set of patches here: https://github.com/baptisterajaut/Strata/pulls

Could you maybe pickup support for other quants in your PR?

@baptisterajaut

Copy link
Copy Markdown
Contributor

Numbers as promised, from one RTX 3090 24 GB. This PR at 176c365 and maya's #1095 head at 4d176d28099a, both on unsloth's Inkling-2-Mini-UD-Q4_K_XL.gguf (sha256 e62d463c…4de15: NVFP4 experts for layers 0-19, Q8_0 for the rest); ours is the feat/inkling2 branch on the official NVFP4 + MXFP8 safetensors. Same 257-token chat prompt, 512 greedy tokens, two runs each.

All resident, this PR decodes at 120-124 tok/s and maya's head at the same speed, with bit-identical logits. With maya's drafter it reaches 130-134 tok/s, but its output leaves plain greedy at token 46, and the two runs differ from each other. Ours does 87.5 tok/s, so maya's engine is about 1.4x faster on that path, and that gap is ours to close.

With the VRAM limited, each ik2 cache was sized so that peak VRAM matches ours (7.8 and 11.9 GiB). At 8 GB this PR does 22-24 tok/s, and maya's head 30 with IK2_DENSE=q8; ours does 63. At 12 GB: 45-47, 54, and 78.

On a 256-token text, the KL against an fp32 reference (which matches HF transformers at ~1e-12) is 9e-4 mean for this PR and maya, top-1 253/256. llama.cpp on the same GGUF gives 9.9e-4, so that is the quant, not the engine.

Broken in this PR: --prefill auto, which setup.py writes for own-path families, becomes chunk 0 and aborts with attn_multi_split: launch failed: invalid argument. Unknown flags are ignored silently, so --vram-reserve-mib does nothing. --draft is refused for Mini.

Scripts and logs are available if anyone wants to rerun them.

@cobra91

cobra91 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thank you everyone for the valuable reviews, fixtures, and benchmark numbers!

Here is the update pushed in commit 5b272b2b6:

  1. For @mercant1982:

    • KeyError: mmproj: moved mmproj = folder / fam["mmproj"] inside the vision guard (if vision != "none":) in terminal/setup.py.
    • KeyError: mtp: added "mtp": 0 to OWN_PATH_FAMILIES["inkling"].
    • Verified against your bounded CPU fixture: passes cleanly!
  2. For @baptisterajaut:

    • Huge thanks for taking the time to run the benchmarks on your RTX 3090 and validating the 120–124 tok/s throughput and bit-identical logits!
    • --prefill auto: ik2_engine.cu now handles "auto" cleanly (defaulting chunk to 2048 instead of std::atoi("auto") == 0 which crashed attn_multi_split).
    • --vram-reserve-mib: now explicitly parsed in ik2_engine.cu and added to the reserved VRAM headroom calculation (room).
    • --draft: confirmed that looped models (c.n_pass > 1) keep draft disabled for now to guarantee exact generation.
  3. For @merbanan:

    • Thank you for checking Turing support! Please feel free to open a PR against my branch (cobra91:feat/inkling2-support) or share patches, and I'll gladly review and merge them directly so we can include wider quant and architecture coverage together!
  4. PR Body & Attribution:

@Algo-Enthusiast

Copy link
Copy Markdown

Nice update! Bit late (I was looking for this but couldn't find anything so started work on my own for polystrata, but could help here)
So I've been working on DSpark MTP support for Inkling 2 Mini (n_pass = 3, 48 visits) on RTX 4060 Ti 8 GB + 32 GB DDR4 (Ryzen 5 5500GT), and got --draft working with bit-identical greedy output (64/64 tokens matching 1-token decode):
UD-IQ1_S (7.23 GiB): 35.5 tok/s → 50.9 tok/s avg (up to 57.6 tok/s on code, ~3.69 accepted tokens/verify),
UD-Q4_K_M (15.47 GiB, 4-bit): 11.4 tok/s → 22.5 tok/s (1.97× speedup, ~3.64 accepted tokens/verify)

A few findings from getting it working and tuned on a 8gb 4060 ti:

Exact generation with --draft on looped models (n_pass = 3) Each of the 48 visits has its own 4 causal conv states (K, V, attn_post, ffn_post). By saving per-token conv state snapshots during the 8-token verification window (rolling back to the last accepted token's snapshot on a partial rejection) and overwriting the temporary anchor/mask K/V slots in the draft cache with the accepted tokens' context K/V (k_proj_ctx / v_proj_ctx), greedy generation stays 100% bit-identical to 1-token decode.

dspark_norm.weight vs output_norm.weight in dflash GGUFs In the dflash GGUF, the two norm names are swapped relative to what you'd expect: output_norm.weight is the drafter's final norm (before the LM head), while dspark_norm.weight is the markov feature norm (markov_head.dflare_norm). Using them the other way around drops acceptance from ~3.69 tok/verify down to ~1.57 tok/verify.

Folding dspark_hidden_out into the LM head at load time In the 7-step Markov loop, d_out[i+1] + Wh @ latent_i + b_h feeds straight into the LM head (output) before the softcap. Precomputing W_fold = quant_q4_0(output @ Wh) ([200058, 256]) and b_fold = output @ b_h once at load time lets us run base = output @ d_out[1..7] as a single n = 7 batched GEMM outside the loop, and shrinks the 7 sequential Markov GEMVs by 9× (from [200058, 2304] to [200058, 256]).

8 GB VRAM & DDR4 tuning:
Quantizing the drafter's Q8_0 matrices to Q4_0 at load time and stacking Q+K+V, K_ctx+V_ctx, and gate+up saves ~200 MiB of VRAM (~91 extra cached experts on 8 GB) with zero acceptance loss.
Multi-token (NT = 1..4) AVX2 CPU expert kernels load a streamed CPU expert from DDR4 once when multiple tokens in the 8-token verification window route to the same expert.

@cobra91

cobra91 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Huge thanks @Algo-Enthusiast for sharing these valuable findings and confirming the ~3.64 accepted tokens/step on Inkling 2 Mini (looped MoE, 48 visits)!

We just pushed commit c7f7583a9 which officially brings dual-GPU resident fast-token decode and multi-token Tensor Core speculative verification to PR #6506:

1. Dual-GPU Resident fast_token (CUDA Graph + Mapped Staging)

  • Zero-Copy Mapped Staging Buffer (g_ep_stage, 648 KB): Allows seamless host-bounce EP communication across PCIe for dual-GPU systems without requiring physical NVLink aperture.
  • Multi-GPU Resident CUDA Graph: Successfully captures and replays resident EP launches with zero host overhead.
  • Performance: ~80.7 tok/s on dual-GPU (RTX 5080 + RTX 4060 Ti) with 100% resident experts (tested on greedy decode with bit-identical output).

2. Multi-Token Speculative Decoding (--draft) on Dual-GPU

  • Dynamic Looped Drafter Configuration: Automatically binds to 4 taps / 3 layers for looped Mini models (48 visits) and 8 taps / 5 layers for Small models.
  • Multi-Token Tensor Core MMA Acceleration:
    • Implemented to_f16_limbs_tokens for token-strided FP16 limb buffers.
    • Generalized experts_mma_kernel to index input limbs per-token (tok[slot]), allowing Tensor Core MMA execution during multi-token verify windows ($T \le 8$).
    • Added ep_combine_block for multi-token peer expert reduction.
  • Performance: 62.8 tok/s speculative throughput (3.62 accepted tokens/step on code tasks, 54.2 ms verification across all 48 looped visits, 0 cache misses, 100% bit-exact).

Also glad to see that the Windows MSVC / CUDA 13 port, session cache, and minimal effort fix are currently being proposed upstream in Project Maya PR mw00/project-maya#1106 by @mrexodia!

@mrexodia

Copy link
Copy Markdown

Not quite merged yet, I just opened a PR with my Windows changes 😅 Also included a bugfix for minimal thinking, tested support for 8GB cards and added a DRAM session cache so you can work with multiple coding agents without constantly invalidating the cache

@cobra91

cobra91 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Haha my bad @mrexodia, jumped the gun a bit! 😅 Really appreciate the clarification and the fantastic additions in #1106 (especially the session cache and minimal effort fix)!

@cobra91

cobra91 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

🚀 perf(ik2): Asymmetric Dual-GPU EP with Core P2P Tail-Skip & Per-Device Pool Sizing

Following our previous progress, we just pushed commit 3225c8831 which introduces Asymmetric Expert Parallelism and resolves pool-allocation starvation on multi-GPU setups.

📌 Overview & Root Cause

On heterogeneous multi-GPU systems (such as RTX 5080 16GB @ 1,000 GB/s + RTX 4060 Ti 16GB @ 288 GB/s), a naive symmetric 50/50 expert split caps overall decoding throughput to the memory bandwidth of the slowest GPU (80.7 tok/s), while forcing P2P transfer and event synchronization across all 48 layer visits per token.

Furthermore, we identified a critical pool sizing bug: the default allocator split pool slots proportionally to layer count across the whole model (e.g. 20 layers in Pool 0, 4 layers in Pool 1), causing a secondary GPU to over-allocate Pool 0 for experts it never owns while starving Pool 1, inadvertently causing unnecessary host RAM evictions.


🧠 What Commit 3225c8831 Implements

  1. Looped Core Pinning (IK2_EP_CORE_GPU0=1):

    • GPU 0 (Primary, 1,000 GB/s): Holds 100% of the looped core layers (layers 6–17, 1,536 experts).
    • GPU 1 (Secondary, 288 GB/s): Caches the outer encoder and decoder tail layers (layers 0–5 and 18–23, 1,536 experts).
  2. P2P Zero-Copy Tail-Skip (Ly.ep_has_peer = false):

    • When a layer has zero peer-owned experts (true for all 36 core loop visits per token, representing 75% of total layer execution), the engine bypasses cudaMemcpyPeerAsync, cudaEventRecord, and stream synchronization entirely.
    • GPU 0 evaluates 100% locally at native GDDR7 speed (1,000 GB/s).
  3. Per-Device Pool Capacity Capping (EC.ep_dev):

    • By capping each pool to the device's actual owned expert count (pmax[p] = std::max(1, n_owned)), both GPUs achieve 100% VRAM expert residency with zero PCIe evictions (GPU 0: 6.4 GiB experts; GPU 1: 8.3 GiB experts).
    • Fully general: for mono-GPU (n_gpu == 1) or symmetric splits (IK2_EP_CORE_GPU0=0), it preserves standard behavior without regression.
  4. Zero-Wait CUDA Graph Execution:

    • With 100% expert residency verified across both GPUs, resident EP: CUDA graph captured and instantiated! is fully unlocked, eliminating kernel launch overheads.

📊 Empirical Benchmark Results

  • Model: Inkling-2-Mini-UD-Q4_K_XL.gguf (17.63 GB, 24 layers, 128 experts, top-8 active)
  • Hardware: RTX 5080 16GB (Host 0) + RTX 4060 Ti 16GB (Peer 1) over PCIe 4.0 P2P, Windows 11, CUDA 13.4.
Architecture / Execution Path Prefill Speed Decode Speed Memory / Bus Status
Naive Symmetric Dual-GPU (50/50 split) ~20.0 tok/s 80.70 tok/s P2P stalls on all 48 passes; limited by 4060 Ti 288 GB/s bus
Mono-GPU RTX 5080 (CoreResident hybrid) 28.40 tok/s 89.24 tok/s 1,762 PCIe misses (exceeds single GPU 16GB VRAM)
Asymmetric Dual-GPU EP + Tail-Skip (This Commit) 49.30 tok/s 104.24 tok/s 100% in VRAM (0 misses) + CUDA Graphs instantiated

Net Gain: +29.2% decode speed over symmetric dual-GPU, +16.8% over mono-GPU, and breaking the 100 tok/s barrier on a 17.6 GB MoE model on consumer hardware.


🤝 Community Verification Request

If anyone in the thread (e.g. @baptisterajaut, @Algo-Enthusiast, @mrexodia, or others with 24GB cards such as RTX 3090 / 4090 or dual-3090 NVLink setups) has a chance to pull and test this commit, confirmation of decode speed and bit-exact validation on your end would be greatly appreciated!

Credits: Co-authored with @kuraneko1 for core-resident loop heuristics and hardware profiling insights; tail-skip architecture prototyped in lab/p2p-turbo.

Niko1221 added a commit that referenced this pull request Nov 22, 2026
… NUMA offload, and Dual-GPU EP

Unify official Hugging Face safetensors (thinkingmachines/Inkling-2-Mini + mtp.safetensors
+ vision) and community/Unsloth GGUF checkpoints (UD-Q4_K_XL, IQ3_S, IQ4_NL, IQ4_XS, Q4_K,
Q5_K, Q6_K, Q8_0, MXFP4, NVFP4, split multi-shard, and external dspark GGUF/safetensors)
directly inside strata-inkling while keeping native .strata v1.1 (SQ-20/15/10 + Vision)
as the flagship recommended default.

- Zero-requantization official HF safetensors adapter (ink_safetensors_loader.h): maps
  NVFP4 L0..19 straight to SF4 (code_id=15), MXFP8 L20..23 straight to MX8 (code_id=16),
  BF16 dense trunk, 3x loop-weighted vram_load_order, mtp.safetensors DSpark drafter,
  and model.visual.* vision weights (ink_vision.h).
- Community / Unsloth GGUF adapter (ink_gguf_loader.h): supports both llama.cpp master
  (GGUF_shard_rewrite) and PR #32187 layouts, split multi-shard GGUFs, bit-exact
  NVFP4 -> SF4 nibble-desplit repack, lossless SkCode::GGUF_RAW (id=20) native block
  dispatch across CPU and CUDA, full-array 200K o200k tokenizer + chat_template export,
  and Unsloth dspark-*.gguf (dflash arch) 54-tensor mapping.
- Ported PR #6520 CUDA-Graph mapped-memory doorbell + NUMA-aware AVX-512/AVX2 CPU expert
  worker pools + decayed-use background promotion (hybrid_doorbell.{h,cu}) and --kv
  k8v8|k8v4 KV compression (ink_batch.h, hybrid_doorbell.cu).
- Ported PR #6506 Dual-GPU Expert Parallelism (--gpus 2 / --ep-split / IK2_EP_SPLIT)
  with P2P / pinned fallback and native SF4/MX8/S_K/GGUF_RAW GPU kernels
  (ep_dual_gpu.{h,cu}) in modular non-conflicting files.
- Wired multi-format detection, community HF sources, local import args, and HF o200k
  tokenizer loading into terminal/setup.py, terminal/strata_cli/launch/catalog.py,
  terminal/tools/strata_tokenizer.py, and terminal/serve/test_inkling_formats.py.
- Preserved original MIT copyright headers (Project Maya, Baptiste Rajaut, merbanan,
  cobra91) and documented contributor credits for 0.2.19 release notes.
@merbanan

Copy link
Copy Markdown
Contributor
 This session's numbers (RTX 2060 SUPER 8 GB, Inkling-2-Mini IQ3_S, int8 K/V, --ctx 32768):
 
  ┌─────────────┬─────────────┬────────────────────────────┐
  │   Prompt    │  PP tok/s   │          TG tok/s          │
  ├─────────────┼─────────────┼────────────────────────────┤
  │ 51 tokens   │ 35.6 → 71.8 │ 53.1 → ~56                 │
  ├─────────────┼─────────────┼────────────────────────────┤
  │ 500 tokens  │ 222 → 289   │ ~51–58 (varies run to run) │
  ├─────────────┼─────────────┼────────────────────────────┤
  │ 5269 tokens │ 1096 → 1091 │ 44.9 → 48.5                │
  └─────────────┴─────────────┴────────────────────────────┘
  

This is with 52 patches ontop of https://github.com/cobra91/Strata-DualGPU/tree/feat/inkling2-support. I think this is close to the max this GPU is capable of.

@cobra91

cobra91 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Huge thanks @merbanan for testing our branch and sharing these impressive numbers! Getting ~53–58 tok/s decode on a consumer 8 GB card (RTX 2060 SUPER) with IQ3_S and int8 K/V is an extraordinary milestone. It confirms that with proper quant / KV support, this looped architecture can fly on consumer hardware. We'd love to see your 52 patches land alongside this PR!

@Niko1221 (Niko Veit) We have cleanly rebased and merged feat/inkling2-support with upstream v0.2.19 (origin/main) — all conflicts in model_family.hpp, setup.py, and strata_tokenizer.py are resolved, and the PR is now fully MERGEABLE and verified on Windows MSVC + CUDA 13.4.

To support integration into v0.2.20, here are our empirical benchmark numbers comparing the baseline dual-GPU implementation in v0.2.19 against this PR:

📊 Benchmark Comparison: Consumer Hardware

Configuration Model & Setup v0.2.19 Baseline This PR (feat/inkling2-support) Gain / Impact
Dual-GPU (Asymmetric)
RTX 5080 16GB + RTX 4060 Ti 16GB
Inkling-2-Mini-UD-Q4_K_XL.gguf
(17.63 GB, 128 experts, ctx 4096)
~35–80.7 tok/s
(Symmetric 50/50 split, PCIe P2P sync stalls on all 48 layer visits)
104.24 tok/s (49.3 tok/s prefill)
(Asymmetric Core Pinning + Zero-P2P Tail-Skip on core loop)
+29% to +190%
100% VRAM resident (0 misses) + CUDA Graph
Mono-GPU (16 GB)
RTX 5080 16GB
Inkling-2-Mini-UD-IQ3_XXS.gguf
(11.66 GB, FP8 KV cache)
2.2–28.4 tok/s (Q4 overflows 16GB VRAM, PCIe host paging) 79.63 tok/s (53.7 tok/s prefill)
(100% resident in 10.8 GB VRAM)
x3 to x35 faster
Zero PCIe thrashing
Mono-GPU (8 GB)
RTX 2060 SUPER 8GB (@merbanan test)
Inkling-2-Mini IQ3_S
(int8 KV cache)
OOM ~53–58 tok/s Accessible on 8GB VRAM

Why this matters for consumer hardware:

  1. Zero-P2P Tail-Skip (Ly.ep_has_peer = false): The 36 core loop visits (layers 6–17) represent 75% of total layer execution. By pinning them to GPU 0, all P2P events and copies are bypassed during the core loop, running at native GDDR7 bandwidth (1,000 GB/s) rather than being throttled by the secondary card's PCIe bus.
  2. Per-Device Pool Sizing (pmax[p] = std::max(1, n_owned)): Prevents GPU 1 from over-allocating Pool 0 for layers it doesn't hold, eliminating false VRAM starvation and ensuring 100% residency on asymmetric setups.

Ready for review whenever you have a moment for v0.2.20! 🚀

@EliahHofmann

Copy link
Copy Markdown

Two bugs in the dual-GPU EP path (IK2_EP=1 --gpus 2), found while running Inkling-2-Mini UD-Q4_K_XL on 2x Tesla T10 (Turing, sm_75, 16 GB each) on a Ryzen 7 5700G board, both cards behind the host bridge (PHB in nvidia-smi topo -m). Tested on merbanan's inkling2-turing branch (435cec2, on top of this PR); both spots are the same in this PR's head (a219ea6).

With both fixes, EP output is token-identical to one GPU (first 100 of 100 greedy tokens), and decode goes from ~50 to ~62 tok/s for a short prompt. Through the server with 256K context: 144K-token prompt 19 -> 33 tok/s, 253K-token prompt 16 -> 23 tok/s.

1. fast_token's ep_select_token calls don't pass K

The resident EP path (fast_token_launches, the else branch of if (!g_ep_fast)) calls k::ep_select_token(...) without the last argument, so K takes its default of 2 and tok[i] = i / 2. For one token, every pick from the third on reads a row of x the token doesn't have (stale or zero). The NVFP4 MMA kernels never read tok, so only the Q8_0 expert layers (20-23 in the UD quant) go wrong. The first generated token is still right (it comes from the prompt path, which already passes c.K); from the second on, the output is garbage. With IK2_FAST=0 it's correct, which is how I narrowed it down. In this PR's head there are four such calls (ik2_engine.cu around lines 2245, 2294, 2298, 2312); the prompt path's calls at 2689 / 2731 / 2744 already pass c.K.

2. Peer access is enabled without checking that the direct path carries data

On this board cudaDeviceCanAccessPeer says yes both ways and cudaDeviceEnablePeerAccess succeeds, but direct peer copies deliver wrong data (in a standalone test: every word wrong; without peer access, the driver-staged copies are exact). It's the same as #2666, which core/peer_experts.cpp already guards against with a test copy (p2p_copies_data); the ik2 engine enables peer access unconditionally. The patch below ports that probe (plus IK2_NO_P2P=1 to force the host route). With it, TP is correct too.

Careful with raw peer kernel stores on such a pair: in my standalone test they hung the receiving card (Xid 45, then 154 "GPU Reset Required"), and it took a reboot to recover. The engine only uses cudaMemcpyPeerAsync, so the probe is enough there.

Patch (against 435cec2)
--- a/engine/src/ik2/ik2_engine.cu
+++ b/engine/src/ik2/ik2_engine.cu
@@ -2475,11 +2475,11 @@
                 CU(cudaMemcpyAsync(dev_work(1).xq, g_ep_stage.d_xq[1], (size_t) C * 4, cudaMemcpyDeviceToDevice, g_s));
                 k::ep_select_token(g_ep_stage.d_route[1], (const float*)(g_ep_stage.d_route[1] + S), Ly.ep_tab_blob[1],
                                    Ly.ep_tab_sc[1][0], Ly.ep_tab_sc[1][1], Ly.ep_tab_sc[1][2],
-                                   S, dev_work(1).blob, dev_work(1).tok, dev_work(1).inv, dev_work(1).sg, dev_work(1).su, dev_work(1).wt, g_s);
+                                   S, dev_work(1).blob, dev_work(1).tok, dev_work(1).inv, dev_work(1).sg, dev_work(1).su, dev_work(1).wt, g_s, c.K);
             } else {
                 k::ep_select_token(dev_work(1).route_d, (const float*)(dev_work(1).route_d + S), Ly.ep_tab_blob[1],
                                    Ly.ep_tab_sc[1][0], Ly.ep_tab_sc[1][1], Ly.ep_tab_sc[1][2],
-                                   S, dev_work(1).blob, dev_work(1).tok, dev_work(1).inv, dev_work(1).sg, dev_work(1).su, dev_work(1).wt, g_s);
+                                   S, dev_work(1).blob, dev_work(1).tok, dev_work(1).inv, dev_work(1).sg, dev_work(1).su, dev_work(1).wt, g_s, c.K);
             }
             run_dev_exp(1, dev_work(1), g_s);
             if (g_ep_stage.d_y[1]) {
@@ -2493,7 +2493,7 @@
             use_dev(0);
             k::ep_select_token(dev_work(0).route_d, (const float*)(dev_work(0).route_d + S), Ly.ep_tab_blob[0],
                                Ly.ep_tab_sc[0][0], Ly.ep_tab_sc[0][1], Ly.ep_tab_sc[0][2],
-                               S, dev_work(0).blob, dev_work(0).tok, dev_work(0).inv, dev_work(0).sg, dev_work(0).su, dev_work(0).wt, g_s);
+                               S, dev_work(0).blob, dev_work(0).tok, dev_work(0).inv, dev_work(0).sg, dev_work(0).su, dev_work(0).wt, g_s, c.K);
             run_dev_exp(0, dev_work(0), g_s);
             CU(cudaStreamWaitEvent(g_s, g_ep_done, 0));
             const float* y_peer = g_ep_stage.d_y[0] ? g_ep_stage.d_y[0] : (dev_work(0).y32 + (size_t) S * C);
@@ -4674,11 +4674,37 @@
         int p01 = 0, p10 = 0;
         CU(cudaDeviceCanAccessPeer(&p01, 0, 1));
         CU(cudaDeviceCanAccessPeer(&p10, 1, 0));
+        if (getenv("IK2_NO_P2P") && std::atoi(getenv("IK2_NO_P2P"))) p01 = 0;   // by hand: copies through the host
         if (p01 && p10) {
             CU(cudaSetDevice(0));
             CU(cudaDeviceEnablePeerAccess(1, 0));
             CU(cudaSetDevice(1));
             CU(cudaDeviceEnablePeerAccess(0, 0));
+            // #2666 (core/peer_experts.cpp): behind a host bridge ("PHB") the driver can report P2P and enable it while the
+            // direct copies move nothing, so the MoE halves arrive wrong. Ask the pair once with a small copy each way.
+            constexpr size_t kN = 1 << 14;
+            std::vector<float> h(kN), back(kN);
+            for (size_t i = 0; i < kN; ++i) h[i] = 1.0f + (float) ((i * 2654435761u) % 4093u);
+            float* dp[2] = {nullptr, nullptr};
+            for (int d = 0; d < 2; ++d) { CU(cudaSetDevice(d)); CU(cudaMalloc((void**) &dp[d], kN * 4)); }
+            bool ok = true;
+            for (int from = 0; from < 2 && ok; ++from) {
+                const int to = 1 - from;
+                CU(cudaSetDevice(from)); CU(cudaMemcpy(dp[from], h.data(), kN * 4, cudaMemcpyHostToDevice));
+                CU(cudaSetDevice(to)); CU(cudaMemset(dp[to], 0, kN * 4));
+                cudaError_t e = cudaMemcpyPeer(dp[to], to, dp[from], from, kN * 4);
+                if (e == cudaSuccess) e = cudaDeviceSynchronize();
+                if (e != cudaSuccess) { (void) cudaGetLastError(); ok = false; break; }
+                CU(cudaMemcpy(back.data(), dp[to], kN * 4, cudaMemcpyDeviceToHost));
+                ok = back == h;
+            }
+            for (int d = 0; d < 2; ++d) { CU(cudaSetDevice(d)); CU(cudaFree(dp[d])); }
+            if (!ok) {
+                std::printf("peer access: a test copy between the GPUs arrived wrong (host bridge, no real P2P): copies through the host\n");
+                CU(cudaSetDevice(0)); (void) cudaDeviceDisablePeerAccess(1); (void) cudaGetLastError();
+                CU(cudaSetDevice(1)); (void) cudaDeviceDisablePeerAccess(0); (void) cudaGetLastError();
+                p01 = p10 = 0;
+            }
         }
         CU(cudaSetDevice(0));
         CU(cudaEventCreateWithFlags(&g_ep_x, cudaEventDisableTiming));

@cobra91

cobra91 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thank you so much @EliahHofmann for this exceptional and rigorous audit! 👏

You nailed both issues with absolute precision:

  1. Missing c.K in ep_select_token: In fast_token_launches, the 4 calls omitted c.K, causing K to default to 2 instead of 8. As a result, tok[i] = i / 2 read stale/zero rows from the 3rd pick onwards on Q8_0 layers (20-23 in the UD quant).
  2. Host Bridge (PHB) P2P probe: Porting the small bidirectional probe copy test from #2666 (core/peer_experts.cpp) ensures that multi-GPU topologies behind a host bridge gracefully fall back to the host-staged path when direct peer memory transfers do not carry data.

Both fixes have just been pushed in commit 50d0cc243!

Regarding the prefill gap on longer prompts (~511–810 tok/s vs ~1,718–1,882 tok/s on V100): we've also identified that the current ik2 engine computes the vocabulary projection head across all intermediate prefill chunks and relies on plain tiling attention rather than fused FlashAttention-2 with bulk split-KV (such as @kuraneko1's specialized Volta kernel in inkling2_kernels.cuh). We are working on adapting those optimizations into ik2 to close the prefill gap across both Volta and newer architectures.

Feel free to pull the latest commit on feat/inkling2-support and retest on your 2x Tesla T10 setup. Thank you again for your valuable feedback! 🚀

@ibbobud

ibbobud commented Nov 22, 2026

Copy link
Copy Markdown

@cobra91 looks like great work! You have any plans for Pascal SM_61 support for this?

I have dual Titan Xp's I can do any testing on for you when the time comes to assist.

@cobra91

cobra91 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@niko

@cobra91 looks like great work! You have any plans for Pascal SM_61 support for this?

I have dual Titan Xp's I can do any testing on for you when the time comes to assist.

It's possible but don't have this for test check or others so it's hard for me to verify

@cobra91

cobra91 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Post-fix validation on our rig — RTX 5080 + RTX 4060 Ti, Windows, build 50d0cc2 (MSVC + CUDA 13.4). Confirming @EliahHofmann's audit items are resolved on asymmetric hardware — all numbers below measured tonight, same build, flags listed.

Decode:

Config tok/s Notes
Dual-GPU Q4_K_XL, IK2_EP=1 96.3 → 103.3 every expert in VRAM across 2 GPUs, 0 misses, zero-wait GPU EP dispatch
Mono (RTX 5080) IQ3_XXS 80.4 full residency, CUDA graph path
Dual without IK2_EP=1 26.9 falls back to cache mode + misses — the env var is required for the asymmetric path

Prefill, head-to-head vs llama.cpp (iso conditions — identical 928-token prompt, same IQ3_XXS file, same GPU, same evening):

Strata ik2 llama.cpp
Prompt eval 1,143 tok/s 830 tok/s +38%
Decode (same run) 80.4 71.2 +11%

Caveats (measured, worth documenting):

  • Speculative --draft mtp on mono-GPU nets 36.3 tok/s vs 80.4 barefoot — verification costs 99.9 ms/step despite 3.76 accepted/step. Drafting is net-negative on fast single-GPU targets in this build.
  • Our Blackwell numbers (96–103 dual) sit below @baptisterajaut's 120–124 @ Q4 on a 3090 — the sm_120 kernel path appears to leave ~30–40% on the table vs Ampere. Worth a note for 50-series users.

@EliahHofmann

Copy link
Copy Markdown

Thanks for picking both up so fast!

50d0cc2 doesn't build for sm_75

I wanted to retest the head on the 2x T10, but ik2_kernels.cu fails in ptxas with -DCMAKE_CUDA_ARCHITECTURES=75:

ptxas ... ik2_kernels.ptx, line 207179; error   : Feature '.m16n8k16' requires .target sm_80 or higher

mma16816 (the FlashAttention prefill helper) uses mma.sync.m16n8k16 unguarded. merbanan's inkling2-turing (435cec2, which I tested on) has the Turing path: mma16816 as two m16n8k8 under __CUDA_ARCH__ < 800, plain loads/stores in place of cp.async, and one K/V tile buffer (kFaOne / kFaSmem1) so the block fits Turing's 64 KB of shared memory. Since the two trees have drifted apart (about 1,250 lines in ik2_kernels.cu), I didn't try porting it. The two fixes are running here on top of 435cec2.

Drafter (--draft mtp.safetensors) on 2x T10, EP

Same picture as on your 5080. UD-Q4_K_XL (with a LoRA merged in), IK2_EP=1 --gpus 2, greedy, 600 tokens, English chat prompts (a Python LRU cache with tests; a ~500-word explanation of reverse proxies), CLI path (--tokens ... --gen 600).

At --ctx 262144 the drafter takes 6.69 GiB of VRAM on GPU 0, so the experts no longer all stay resident and decode drops to 2-4 tok/s. At --ctx 32768 it takes 1.44 GiB and every expert stays in VRAM:

prompt no drafter IK2_DRAFT_B=8 IK2_DRAFT_B=4
code 60.1 tok/s 49.2 (3.33 tok/step, verify 60.5 ms) 57.0 (2.58, 38.5 ms)
prose 59.5 tok/s 29.7 (2.09, 63.2 ms) 42.0 (1.96, 39.6 ms)

Drafting itself is ~7 ms a step. One plain decode token costs ~16.5 ms, so an 8-token verify at ~60 ms needs ~3.7 accepted tokens a step just to break even.

Two things I noticed:

  • Even greedy, the drafted output doesn't match the plain output for long (first 57-186 of 300 tokens identical). I'd guess the batched verify forward rounds differently from the single-token resident path and flips near-ties, but I didn't dig into it.
  • The --serve loop never uses the drafter (it's only in the CLI generation path), so through server.py it wouldn't help even where it pays off.

@cobra91

cobra91 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @EliahHofmann for catching this and for the exact pointer!

The Turing (sm_75) FlashAttention compatibility path has been ported directly from merbanan's reference tree and is now pushed to feat/inkling2-support in commit beeca889e:

  • MMA fallback: mma16816 decomposes into two mma.sync.aligned.m16n8k8 operations (covering the k 0..7 and 8..15 fragment halves) when __CUDA_ARCH__ < 800.
  • Async copy fallback: cp_async16 / cp_async4 use direct synchronous int4 / int loads and stores with no-op commit/wait groups under __CUDA_ARCH__ < 800.
  • Shared memory cap (64 KB): Added the single-tile SMEM layout kFaSmem1 (~53 KB vs ~88 KB for double-buffering) and kFaOne single-buffer refill logic. Dynamically queried via major < 8 in attn_flash_launch.

Empirical compilation was validated locally with CUDA 13.4 and MSVC under both -DCMAKE_CUDA_ARCHITECTURES=75 and multi-arch -DCMAKE_CUDA_ARCHITECTURES="75;89;120" with zero errors.

Feel free to pull the latest head on your 2x T10 setup whenever you have a moment. Also appreciate your notes on the drafter's context overhead, verify cost, and CLI-only integration.

@merbanan

Copy link
Copy Markdown
Contributor

For me the experts needed for the verify step in MTP was often not available in VRAM so it never payed off for me.

@cobra91

cobra91 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Added golden tokenizer tests for Inkling 2 to this branch (beeca88..b1a0b46), ported from @okada-shogo's golden suite in simplexai-labs/PolyStrata #215 (commit 76ddc50) - thank you for writing it, and glad the exchange runs both ways.

serve/test_inkling_tokenizer.py: the tokenizer half of the suite - 51 golden strings (53 cases) checked against Hugging Face's reference ids, with the vocabulary subset fixture and, when $STRATA_INKLING_TOKENIZER points at a pack, the full 200,058-token vocabulary.

All 8 cases green on this branch, including test_where_llama_cpp_differs ("kwargs": one token here, three in llama.cpp) - so this project's tools/strata_tokenizer.py already implements tokenizer.json's ignore_merges (a piece that is a token is that token), which PolyStrata's #210 had to add on its side; the lineage carried it here.

The parser and template half of the suite (the <|end_message|>-in-a-string call, the forced call after thinking, the shared prefix's effort) stays in PolyStrata for now: that serve layer's parser has grown apart, and porting those cases is follow-up work with the fixes they test.

@EliahHofmann

Copy link
Copy Markdown

Retested b1a0b46 on the 2x T10 (sm_75, CUDA 12.9):

  • It builds for sm_75 now, and EP and TP both match one GPU (first 100 of 100 greedy tokens). The P2P probe still falls back to the host route here.
  • IK2_KV=fp8 still fails on Turing: ik2::k::attn_flash (shared memory): launch failed: invalid argument. The FP8 flash path keeps its two raw buffers next to the FP16 tile (~88 KB), and kFaOne only covers FP16. merbanan's tree avoids this with an int8 cache whose tiles are converted to FP16 while loading into the one buffer (fa_load_tile_i8).
  • With the FP16 cache, 256K of context takes 8.5 GiB on GPU 0, so not every expert fits any more: 19.2 tok/s at --ctx 262144 against 57.7 at --ctx 65536. merbanan's int8 cache on the same box gets ~61 at 256K.

Decode attention at long context

I profiled 435cec2 (int8 KV, EP) with a 250K-token prompt. Decode runs at 23.1 tok/s, against ~61 with a short prompt, and the whole gap is the full layers' attention (IK2_PROF: 32.6 vs 7.6 ms a token). attn_decode_mma_kernel reads the cache at ~185 GB/s, while a plain read on the T10 gets ~393 GB/s. Two changes, both measured on the 2x T10:

  1. Row-block mapping. With grid(Hkv, n_split), each block reads its one K/V head's 128 bytes from every row (1056-byte stride), and 8 blocks walk the same rows at different times. I made a block's 8 warps the 8 K/V heads of one run of keys: blockDim = Hkv * 32, g = threadIdx.x >> 5, w = blockIdx.x, n_split * kWaNW blocks, same body, same combine. Now a block reads whole rows. With 250K keys a call goes from 2.89 to 1.60 ms (330 GB/s), and the output is identical. This uses two waves of blocks (n_split = 2 × SMs × occupancy / 4). In the engine: 23.1 -> 29.7 tok/s at 250K; short context unchanged, tokens identical. Your tree has the same kernel, so this should carry over directly. It only applies when Hkv * 32 == 256 (8 K/V heads here).
  2. Split over both GPUs (EP). In EP, GPU 1 sits idle during attention. Now GPU 1 keeps a copy of the full layers' rows from 32K on: 3.6 GiB here, allocated before the expert cache takes the rest. On the resident token path, GPU 0 takes keys [0, s) and GPU 1 takes [s, n), with s = max(32K, n/2). The two GPUs swap q, r, the new K/V row and one merged partial per head through mapped host memory (no P2P), and GPU 0's combine takes GPU 1's partial as one more. The prompt path is unchanged (GPU 0 keeps the whole cache), and rows the prompt path writes are copied over before the next token. 250K: 29.4 -> 36.9 tok/s, with 255/256 tokens identical to the unsplit run (the last one is a rounding flip).

Through server.py (2x T10, 256K, int8 KV), before -> after: 144K-token prompt 32.8 -> 45.3 tok/s, 253K 22.8 -> 34.1. Short prompts and prefill are unchanged, the needle is found at 144K and 253K, and tool calls work.

The patch is against 435cec2 (merbanan's tree). Happy to share it or rebase it onto your branch if you want it.

@cobra91

cobra91 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing this initial monolithic prototype PR in favor of small, surgical upstream PRs directly targeting the official engine/src/inkling2/ architecture introduced in v0.2.19/v0.2.20.

Why closing this PR?

This PR served as the standalone R&D testbed that established and benchmarked Inkling 2 dual-GPU execution (reaching up to 104 tok/s with standalone strata-ik2). The branch feat/inkling2-support will remain permanently preserved and available on cobra91/Strata-DualGPU for historical reference, reproducibility, and anyone benchmarking the standalone prototype.

Now that upstream Strata has established its unified official architecture in engine/src/inkling2/, maintaining a parallel 15,000-line monolithic engine is redundant.

Next Steps & Superseding PR

The first surgical PR has been submitted directly against main:
👉 Superseded by #6811: perf(inkling2/cuda): asymmetric zero-P2P tail-skip (+37% decode, +53% prefill) and Turing sm_75 TC fallback (only 28 lines of code).

Follow-up PRs will port CUDA Graph fast-paths and compact trunk VRAM packing.

Thank you @Niko1221 and everyone in the community for testing and feedback! Moving discussion to #6811.

@cobra91

cobra91 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Also for the record and transparency regarding v0.2.20:

The support and benchmarking for Unsloth UD mixed quants (Inkling-2-Mini-UD-IQ3_XXS, Inkling-2-Mini-UD-Q4_K_XL, IQ2, IQ4_NL, etc.) was first developed, verified and pushed here in PR #6506 on Sunday morning at 07:39 CET (commit 62cab16fd: feat(ik2): support Unsloth UD mixed quants (IQ2, IQ4_NL, Q4_K) and resident CUDA graph fast-path).

11 hours later, it was adapted into commit 4aaa1cbdc (inkling2: accelerate Unsloth GGUF quants...) and announced in the v0.2.20 release ("New version: 0.2.20 All Inkling 2 Mini @unslothai quant's are supported").

Just as noted on PR #6406 (which was integrated line-for-line in 534802c8d without release credit), acknowledging community contributions in the v0.2.20 release notes would be greatly appreciated. In the meantime, our surgical follow-up PRs (#6811, #6815, and #6823) bring the necessary fixes (zero-P2P tail-skip, multi-GPU CUDA Graph capture, and compact Q8 trunk representation) to make these Unsloth quants run at their full potential in the official engine.

@dailybarid

Copy link
Copy Markdown

Report from 2x RTX 3060 12 GB (sm_86, Linux) — EP loads with 0-host experts, then does not produce a token. Not a benchmark; no number was obtained.

Hardware — 2x RTX 3060 12 GB, sm_86, 360 GB/s each, no P2P (separate root ports, nvidia-smi topo = PHB between them), Ryzen 7 5700X, 31 GB DDR4-3200, Linux Mint 22.3, driver 595.99.02.

What I ran — the released component strata-inkling 0.1.65 (BUILD.json: commit c6f6427d9de9, cuda 13.0, archs 75;80;86;89;120), on unsloth/Inkling-2-Mini-GGUF → Inkling-2-Mini-UD-Q4_K_XL.gguf (17,629,759,456 B). I have not built b1a0b46 yet — this box has no CUDA toolkit, that is the next step; so treat everything below as the release binary only.

Results

  1. --info — fine: arch=inkling2_loop layers=24 visits=48 hidden=2304 vocab=200058 experts=128.

  2. --selfcheck --native … --gpus 2 --kv fp8 — PASS:
    backend=cuda-ep2 (NVIDIA GeForce RTX 3060 (11911 MiB, sm_86) + NVIDIA GeForce RTX 3060 (11909 MiB, sm_86) [EP-2GPU split=0.500000, p2p=pinned, vram_exp=3004/3072])

  3. Load with the default VRAM reserve, 68–72 experts go to host, and --bench segfaults:

    [inkling2-ep] Loaded gguf (GGUF-NVFP4) | gpus=2 (p2p=pinned, ep_split=0.50) | experts: 3000 VRAM (GPU0=6.22 GiB, GPU1=7.93 GiB), 72 host (doorbell=off, numa=1, thr=0) | kv=fp16
    Thread 1 "strata-inkling" received signal SIGSEGV
    #0 strata::quant::sk::gemm_sk_q8_1(...)
    #1 strata::inkling2::eval_inkling2_expert_batch(...)
    #2 ink2::EpDualGpuCudaBackend::forward_batch(...)::{lambda(int,int,std::vector<float,...> const*)#2}::operator()
    #3 ink2::EpDualGpuCudaBackend::forward_batch(...)
    

    i.e. the host-side expert path gets GGUF-NVFP4 expert data and dies in the SK q8_1 GEMM. Same with --kv fp8 and --kv fp16, --parallel 1, prompt 512 or 1024.

  4. --vram-reserve-mib 0 — 0 host experts, so the fit is not the problem:
    experts: 3072 VRAM (GPU0=7.22 GiB, GPU1=7.49 GiB), 0 host (doorbell=off, numa=1, thr=0) | kv=fp8, cards at 11,455 / 11,116 MiB. --bench then segfaults after ~5.5 min with nothing printed (no trace captured).

  5. --serve --gpus 2 --kv fp8 --vram-reserve-mib 0 --max-context 32768 --parallel 1 — reaches READY 32768, then a GEN of a 2,048-token id list produces no token at all: GPU utilisation stays 0 %, 32 s of CPU time over 3.5 min, then the process exits without output. Looks like the p2p=pinned dispatch waiting on something that never completes, not a crash in a kernel.

  6. Separately: --gpus 1 on the same .gguf fails with init: Invalid .strata magic (expected STRATA\x00\x01), so I could not get a single-card comparison out of this file.

Not tested — head b1a0b46 (next), --draft/--vision, any 16 GB card, any P2P-capable pairing, and no recall/quality checks (nothing generated).

Asks — (a) is 12 GB per card in scope for this path at all, or is 16 GB the tested floor? (b) is --vram-reserve-mib 0 the intended way to reach zero spill on small cards, and does it cost anything I should know about? (c) is the pinned-host route expected to work without P2P on GeForce, or is a hang there expected behaviour that I should stop chasing? (d) if you know of a flag or a branch that makes the 12 GB case work, point me at it before I spend the build time.

Happy to build b1a0b46 and rerun the same five tests either way, and to follow docs/COMMUNITY_BENCHMARKS.md for the report once something generates.

@cobra91

cobra91 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed report on 2x RTX 3060 12 GB (sm_86, PHB / no-P2P).

You hit three known limitations of the 0.1.65 (c6f6427d9de9) [inkling2-ep] (ep_dual_gpu.cu) path that we have since addressed in a series of 4 follow-up PRs on InkCudaBackend:

Note: we haven't personally tested on 2x RTX 3060 12 GB (sm_86, Linux) — our dual-GPU tests were on RTX 5080 + RTX 4060 Ti 16 GB — so if you build and test from cobra91/Strata-DualGPU (perf/inkling2-iq2-moe, which stacks #6811 + #6815 + #6823 + #6832), your sm_86 Linux PHB feedback would be very valuable.

@dailybarid

Copy link
Copy Markdown

Update: same result on head b1a0b46, so this is not a release-binary artefact.

Built engine/src/inkling2 standalone from feat/inkling2-support @ b1a0b46bfe (CUDA 13.0.48, -DCMAKE_CUDA_ARCHITECTURES=86, gcc 13.3, Linux), same UD-Q4_K_XL:

  • --selfcheck --gpus 2 --kv fp8 — PASS, backend=cuda-ep2 … [EP-2GPU split=0.500000, p2p=pinned, vram_exp=3013/3072], 59 host.
  • --bench … --gpus 2 --kv fp8 --ep-split 0.6 — dies, nothing printed.
  • --serve --gpus 2 --kv fp8 --ep-split 0.6 --max-context 4096 — reaches READY 4096, then a 512-token GEN produces no token and hangs at 0 % GPU until killed. Same at 2048 tokens, same at 0.50/0.60/0.70.
  • --cpu-threads 8 (the #6520 doorbell NUMA pool, so host experts have threads) — still SIGSEGV in gemm_sk_q8_1 → eval_inkling2_expert_batch, with 84 host experts. So it is not "the host pool was uninitialised".

Two further observations that may pin it down:

  • The spill count does not move the way VRAM does: at ep_split=0.6, cards sit at 6.19 + 7.95 GiB (≈3.5 GiB free on GPU1, ≈5 GiB on GPU0) and still 73–84 of 3,072 experts go to host. With --vram-reserve-mib 0 I get 0 host (7.19 + 7.53 GiB) — but that option is documented as "activates hybrid offload", and in that mode generation hangs at 0 % GPU instead of crashing.
  • So: host experts → crash in the host SK GEMM; hybrid-offload path → hang. Both roads from 12 GB per card fail, and neither is a VRAM shortage.

If a 12 GB pair is out of scope for this path, say so and I will stop; if it is meant to work, the smallest useful next probe from your side is which of --vram-reserve-mib N / --cpu-threads N / --ep-split F you consider the supported combination on a pair that cannot hold every expert, since none of the three combinations I tried generates a token.

@cobra91

cobra91 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for testing b1a0b46bfe and narrowing this down — that explains everything!

Look at the log prefix in your run:
[inkling2-ep] Loaded gguf (GGUF-NVFP4)

b1a0b46bfe (feat/inkling2-support) is still routing --gpus 2 to the legacy ep_dual_gpu.cu backend ([inkling2-ep]), which has both bugs you observed:

  1. Its p2p=pinned (no-P2P PHB) path hangs at 0% GPU in --serve.
  2. Its host-expert path passes GGUF-NVFP4 data into gemm_sk_q8_1 (SIGSEGV), and its reserve + ep_split calculation under-allocates VRAM and spills experts to host even when several GiB remain free.
  3. Its --gpus 1 path on that older head fails with Invalid .strata magic on GGUF.

All four of our follow-up PRs (#6811, #6815, #6823, #6832) are on InkCudaBackend ([InkCUDA]), NOT ep_dual_gpu.cu ([inkling2-ep]), and make_default_backend() in that stack routes both --gpus 1 and --gpus 2 through InkCudaBackend:

If you want to verify on your 2x RTX 3060 12 GB (sm_86, Linux, PHB), please build perf/inkling2-iq2-moe from cobra91/Strata-DualGPU (which stacks all 4 PRs, and look for [InkCUDA] instead of [inkling2-ep] in the startup log). Note that you don't need --vram-reserve-mib 0 or --cpu-threads 8 there — standard --gpus 2 --kv fp8 (or --gpus 1 to compare) is the supported path.

@cobra91
cobra91 deleted the feat/inkling2-support branch November 24, 2026 22:49
chynggi pushed a commit to chynggi/Strata that referenced this pull request Nov 26, 2026
Inkling 2 Mini runs layers 6 to 17 three times a token: 36 of its 48 layer runs.  The plain "auto" shares layers
by free VRAM and puts the loop wherever the bytes fall.  On a fast and a slow card, with the server's "faster card
last" order (Niko1221#1352), that gives the slow card the loop: on an RTX 5080 + RTX 4060 Ti 16 GB the estimate is 12.6 ms
a token where the loop on the 5080 is 5.7 ms.

split_plan.hpp estimates a token's time for every legal start of the second card and both device orders.  Dense
weights are read once a run, expert_used_count/expert_count of the experts once a run, the output once a token.
Each card caches its most-run experts first and reads the rest on the CPU.  The cards run in turn, so the times
add.  layer_starts() takes the fastest layout when it is at least 3% faster than the plain one, and open() may then
swap which device takes the first layers.  Cards within 5% of each other's bandwidth (the server's Niko1221#1760 rule),
cards whose bandwidth is not known (HIP, Metal) and every other family keep the plain layout and order.
Bandwidth is the peak memory clock times the bus width; STRATA_POLY_CARD_GBS=a,b overrides it.  "auto" now probes
devices in turn when STRATA_POLY_CARDS asks for more parts than there are devices (it failed there before), so
the choice can be tried on one card.  poly_split_plan_test checks the choice on made-up cards, no GPU needed.

The idea of keeping the looped core on the faster card is cobra91's and kuraneko1's (Strata PR Niko1221#6506, their
two-card Inkling 2 layout); this is our own code for a plain layer split.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cobra91
cobra91 restored the feat/inkling2-support branch November 26, 2026 14:00
@cobra91 cobra91 reopened this Nov 26, 2026
@cobra91 cobra91 closed this Nov 26, 2026
@cobra91
cobra91 force-pushed the feat/inkling2-support branch from b1a0b46 to c234774 Compare November 26, 2026 14:00
@cobra91
cobra91 deleted the feat/inkling2-support branch November 26, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Engine] Inkling-2-Mini support (looped MoE from Thinking Machines)

9 participants