Skip to content

[Engine] inkling2: cache the three capability checks per device (#6808) - #6982

Closed
cobra91 wants to merge 0 commit into
Niko1221:mainfrom
cobra91:fix/inkling2-capability-cache-per-device
Closed

cobra91 wants to merge 0 commit into
Niko1221:mainfrom
cobra91:fix/inkling2-capability-cache-per-device

Conversation

@cobra91

@cobra91 cobra91 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem and result

Found the hard way: while testing #6811 with real long prompts, UD-Q4_K_XL on two different cards answered wrong and logged no error.

Before. On two different cards, sm120::available(), ink_has_int8_tc() and ink_has_wmma_f16() answer once for the whole process, on the first card that asks: stage 0 of a layer split, or the primary in EP. The other card is then sent kernels that are empty stubs on its architecture, for every batch with M >= 24. With UD-Q4_K_XL its NVFP4 experts add nothing to a prompt read, and no error is raised. Decode (M < 24) takes other kernels, so short chats look right.

After. Each check answers per device. Same revision without and with this change, Inkling-2-Mini UD-Q4_K_XL, RTX 5080 (sm_120) + RTX 4060 Ti (sm_89):

Two-GPU mode Build 8 short questions 17 prompts, 37 to 1220 tokens
layer split (Windows default) main 3/8 1 wrong
this PR 7/8 0 wrong
EP (--layer-split ep2) main 3/8 7 wrong
this PR 7/8 0 wrong

Wrong answers before the change read like "The user has pasted a long string of seemingly random words" or "I only see a fragment": the model does not get the end of its own prompt.

Related discussion

#6808. How this PR came about:

  1. I was testing the KV growth fix for the report in [Engine] inkling2: zero-P2P tail-skip for asymmetric dual-GPU and sm_75 TC fallback #6811 (dailybarid, 2x RTX 3060 12 GB) on my own pair, RTX 5080 (Blackwell) + RTX 4060 Ti (Ada), and I checked the answers, not only the speed. UD-Q4_K_XL on two cards went wrong in the expert-parallel mode, the one [Engine] inkling2: zero-P2P tail-skip for asymmetric dual-GPU and sm_75 TC fallback #6811 takes by default on Windows: 5 of 17 prompts wrong, and the model describing its own prompt as "a fragment" or "random words". Nothing in the log.
  2. I traced it to sm120::available() keeping one answer for the whole process, and measured a fix for that one check on my pair (5/8 -> 8/8 on the short questions).
  3. Before opening anything I searched the tracker for an existing report. [Engine] strata-inkling: capability checks are cached per process, so on a mixed sm_120 + sm_86 layer split the sm_86 stage runs the sm_120 FP4 MoE path (corrupted prefill, malformed tool calls) #6808 by @markie1006 is the same cause, found on another pair and shown with tool calls, and it goes wider than what I had seen: two more checks carry the same cache, and the layer split is hit too. My fix was one third of the fix.
  4. @Norhiro confirmed the EP path and the 0.2.20 package in that issue.

So thank you @markie1006 for the diagnosis and for the scope. This PR only turns it into code for the three checks; the measurements below are from my pair.

The last comment on #6808 (06:47 UTC) hands the PR to @Norhiro. This branch was built and measured before I read that. @Norhiro, if yours is on the way, say so and I close this one in favour of it.

Approach

One helper, ink_device_capability(probe) in ink_cuda.cuh: the answer is kept per current device behind a mutex, the shape device_ok() already uses in engine/src/kernels/cuda/nvfp4_decode_sm120.cu. The three checks keep their conditions and lose their own static.

Validation

Revision: this commit on main 6a6db7f. Windows 10.0.26300, driver 621.24, CUDA 13.4, MSVC, Release, -DCMAKE_CUDA_ARCHITECTURES=89;120. RTX 5080 16 GB (sm_120, GPU 0) + RTX 4060 Ti 16 GB (sm_89, GPU 1), no P2P. Models: Unsloth Inkling-2-Mini-UD-Q4_K_XL.gguf (experts NVFP4 on layers 0-19, Q8_0 on 20-23) and Inkling-2-Mini-UD-IQ3_XXS.gguf (the engine keeps none of its experts in the SF4 format). Engine in --serve, requests to /v1/chat/completions, temperature 0, max_tokens 2500.

cmake -S engine -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=89;120 -DSTRATA_BUILD_TESTS=OFF -DSTRATA_BUILD_INKLING=ON -DSTRATA_BUILD_INKLING2=ON
cmake --build build --target strata-inkling

strata-inkling --serve --model Inkling-2-Mini-UD-Q4_K_XL.gguf --gpus 2 --ctx 32000 --kv k8v4 --draft off
strata-inkling --serve --model Inkling-2-Mini-UD-Q4_K_XL.gguf --gpus 2 --layer-split ep2 --ctx 32000 --kv k8v4 --draft off
strata-inkling --bench --native Inkling-2-Mini-UD-Q4_K_XL.gguf --gpus 2 --kv k8v4 --max-context 32768 --prompt-len 4096 --gen 256 --draft off
strata-inkling --bench --native Inkling-2-Mini-UD-Q4_K_XL.gguf --gpus 2 --layer-split ep2 --kv k8v4 --max-context 32768 --prompt-len 4096 --gen 256 --draft off

Passed:

  • Build, cmake --build build --target strata-inkling on this revision: exit 0.
  • 8 questions and 17 prompts, Q4_K_XL, two cards, both modes: the table above.
  • Same checks, IQ3_XXS, EP, this PR: 7/8 (the same first request as under Failed) and 0/17.
  • Same checks on one card (RTX 5080), this PR: Q4_K_XL 8/8 and 0/17, IQ3_XXS 8/8 and 0/17.
  • Speed, Q4_K_XL, 4096-token prompt then 256 generated tokens, same session:
    • layer split: main prefill=996.9 ppts (4.11s) | decode=42.9 tps, this PR prefill=772.6 ppts (5.30s) | decode=42.7 tps
    • EP: main prefill=1378.7 ppts (2.97s) | decode=51.8 tps, this PR prefill=993.2 ppts (4.12s) | decode=52.0 tps

Failed:

  • 8-question battery on two cards with this PR: 7/8 in both modes. The miss is the first request after server start, "Echo the third line", answered with the second line. The same miss is on main (layer-split run) and with IQ3_XXS in EP; with this PR on one card it was answered right. Not caused by this change and not addressed (Limits).

Not run:

Limits

  • A prompt read is 22 % (layer split) to 28 % (EP) slower on this pair. That is the older card computing its experts.
  • The first request of a two-card server start is not reliable on that one question, before and after this change. It is separate from the cache and I have not looked into it.
The two checks

8 short questions with one right answer each, sent in this order: echo the third of three lines; first word of the third of four lines; last item of a four-item list; a number written at the very end of the message; third of five names; next letter after A, B, C, D; a word given in a French sentence; second word of a title. A question counts as right when the expected string is in the answer.

17 prompts: "Ignore the list above. Question: what is 17 + 25? Answer with the number only." behind a list of 0 to 512 plain words taken from a fixed list of 32 (17 sizes, 37 to 1220 tokens). A prompt counts as right when the answer contains 42.

@cobra91

cobra91 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

For anyone wanting to test the full Inkling 2 dual-GPU stack together (#6811 + #6815 + #6823 + #6832 + #6982) without mixing scopes across individual PRs, a dedicated integration branch is available at cobra91/Strata-DualGPU:lab/inkling2-full (0f302f582, smoke-tested on 2x 16 GB UD-Q4_K_XL --gpus 2 --kv k8v4: 1536 + 1536 / 0 host, 80.1 tok/s decode).

@Norhiro

Norhiro commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

FYI, in case it saves you a rebase: v0.2.21 includes ec46ef3 ("capability checks are per device, so a mixed-architecture split runs each card's own kernels (#6808 #6796)"). It does the same thing with a PerDeviceFlag per check. This PR now conflicts with it in ink_cuda.cuh, ink_moe_cuda.cuh and ink_moe_fp4_sm120.cu.

On v0.2.21 without this PR, my sm_120 + sm_86 layer split (RTX 5060 Ti + RTX 3060, SQ-15, --layer-split 21,3) answers 12/12 with no wrong output (#6808's symptom).

@cobra91

cobra91 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by commit ec46ef3b1 in v0.2.21 (see discussion in #6811 (comment)).

Saw that this landed in v0.2.21 via commit ec46ef3b1 ("fix(inkling): capability checks are per device, so a mixed-architecture split runs each card's own kernels (#6808 #6796)"), which implements the per-device caching approach and addresses the same root cause.

Because it went in as an independent commit, this PR still shows as open, and once again the v0.2.21 release notes omitted any community acknowledgments or attribution.

As detailed in #6811, having to reverse-engineer maintainer commits after each release to determine what was cherry-picked without credit or left unmerged makes ongoing upstream contributions unsustainable. We are closing our open superseded PRs here and consolidating all our active engine development, asymmetric multi-GPU optimizations, and low-bit MoE kernels on PolyStrata (https://github.com/simplexai-labs/PolyStrata).

@cobra91 cobra91 closed this Nov 24, 2026
@cobra91
cobra91 deleted the fix/inkling2-capability-cache-per-device branch November 24, 2026 22:49
@cobra91
cobra91 restored the fix/inkling2-capability-cache-per-device branch November 26, 2026 13:58
@cobra91 cobra91 reopened this Nov 26, 2026
@cobra91 cobra91 closed this Nov 26, 2026
@cobra91
cobra91 force-pushed the fix/inkling2-capability-cache-per-device branch from f253103 to c234774 Compare November 26, 2026 13:58
@cobra91
cobra91 deleted the fix/inkling2-capability-cache-per-device branch November 26, 2026 13:58
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.

2 participants