Skip to content

Inkling 2 Mini on AMD Strix Halo (strix-hip): Strict, Spark, DSpark - #403

Merged
AzeezIsh merged 10 commits into
mainfrom
feat/inkling2-hip-pr
Nov 23, 2026
Merged

AzeezIsh merged 10 commits into
mainfrom
feat/inkling2-hip-pr

Conversation

@AzeezIsh

@AzeezIsh AzeezIsh commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Based on main. #401 merged as 992eab2, including its file-size split 9132aa7. The branch is a linear series of 10 commits (the earlier merges of #401 heads were replayed as a rebase; the tree equals the verified 48df64f plus #401's split and #402's docs). The last commit, inkling2 on AMD: split moe_ops / ops under the 500-line cap (code moves only), keeps CI's file-size cap green. On framework (f376/f378) it is exact: greedy Strict and Spark identical, pd 96/96 x6 and NLL 0.63689 / 0.89618 to every digit under f373's serve setup. DevLab strix-hip build 45117369384: success.

What and why

Inkling 2 Mini (#401, by @data-angel) on AMD Strix Halo (gfx1151, strix-hip): Strict and Spark modes, the DSpark drafter, prefix caching, and a start script.

  • Target: kernels/strix-hip/inkling-2-mini links the gb10 Inkling kernels, except inkling2_moe_gemm.cu, which is its own WMMA file.
  • AMD branches: the gb10 Inkling kernels that use NVIDIA-only PTX get AMD branches, each under a macro nvcc never defines.
  • Routing: spark-model routes around the remaining PTX-only kernels under cfg!(atlas_scale).
  • Start script: scripts/serve-inkling2-strix-linux.sh, described in the QUICKSTART section below.
  • History: every step and intermediate measurement is on feat/inkling2-hip. Its tree matched this PR's pre-rebase head 48df64f.

HIP replacements for each GB10-only instruction

gb10 strix-hip
inkling2_moe_gemm_w4a4 / _w8a8 (mma.sync kind::mxf4nvf4 / kind::mxf8f6f4) and the cvt.rn.satfinite.e2m1x2 / e4m3x2 activation quantizers trap stubs. Prefill takes BF16 rows on the target's WMMA grouped GEMMs (__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32), which dequantise the stacked NVFP4 / MXFP8 experts in gb10's order, with the softcapped SwiGLU between gate_up and down
inkling2_flash_prefill (mma.sync m16n8k16, cp.async, ldmatrix) stub. Every prefill size takes the per-head WMMA paged body (strix-hip/common/prefill_paged_compute.cuh), which gains the Inkling relative bias computed in place (bit-identical to inkling2_rel_bias_table) and per-row sinks
inkling2_msg_gate_fused (mma.sync) WMMA branch with the same phases and roundings
expert decode GEMVs: cvt.rn.f16x2.e2m1x2 exact, branch-free decode: the code's bits are placed in an FP16, then multiplied by 2^14
ld.global.nc.L1::no_allocate plain 16-byte load
__syncwarp (not available in hipcc) wavefront fence + __builtin_amdgcn_wave_barrier
(float)__nv_fp8_e4m3 (non-standard on the AMD compat header) bit-math E4M3 decode
common/dense_gemv_bf16_batchm.cu through inkling2_router_gemv.cu's #include 64-bit __shfl_down_sync mask on AMD. Included text skips build.rs's mask widening, and ROCm 10.1 static-asserts on 32 bits

DSpark needed no AMD-specific code.

QUICKSTART

MODE=spark DSPARK=0 PORT=8391 scripts/serve-inkling2-strix-linux.sh   # MODE=strict, DSPARK=1, --check

The script:

DSpark is off by default because it loses on AMD everywhere except Strict code (see below).

Verification (framework = Framework Desktop, Strix Halo 128 GB, ROCm; runner = DevLab Strix Halo)

Binary = sha256 prefix of spark. Measured on the merged head 48df64f unless the row names another head.

check where / binary result
prefill (echo) vs decode logprobs, the same 96 greedy token ids, prompts 166–11,886 tokens framework 2c7f8270136c (f373) 96/96 aligned on all 6 prompts; mean |Δlogp| 0.007–0.027, max 0.37. Identical to every earlier head since 317d3f6
NLL (nll_probe, 57,648 tokens) same code 0.63689 / text 0.89618. Identical across the db19431, 878d7a7, c4db7a3 and e6a8a04 merges
task_probe (30 math + 10 tool calls) same; Spark 317c5b254a16 30/30 + 10/10, equal to SparkInkling's GB10 receipt
prefix cache on: cache hit vs cold same 4,624–4,640 tokens cached of about 4,647; text identical, 4/4
ssm-state-poisoning-gate (thinking off, cache on) framework f369 / f374 Strict 12/12 invariant (run-1795375710053355310); Spark 12/12 invariant (run-1795334924154916371)
cross-contamination framework f369 contaminated 0, persistent 0. C>1 text parts from solo at near-ties (batched kernels), the same class as #401's verify note
start script from a clean worktree framework f364, 9c7999f4893e strict, spark and strict + DSPARK=1 all --check rc 0; READY, 17 * 23 = 391
ST-995 (bfcl-subset, no overrides; start script, prefix cache on) runner 45004728162 / 45004731040 Strict 79.3 / 80.09, Spark 79.1 / 79.63 (overall / normalized). GB10 Spark is about 80.0
agentic-webserver ×10, prefix cache on runner + framework Strict 10/10, 10/10 (9.95 / 10.58 s/turn); Spark 10/10, 10/10 (7.54 / 6.89 s/turn)
C1 decode (decode-floor, 1,500 tokens) framework f367 Spark 42.3 tok/s, Strict 28.2 (9/9 runs each)
aggregate C1/2/4/8 framework (decode_h2h, f371) Spark 42.4 / 51.5 / 69.7 / 89.4 tok/s
prefill framework f373 4,778 tokens in 3.47 s (1,376 tok/s); 16,725 tokens 1,266 tok/s
DSpark (drafter) framework f365 Spark + DSpark prose / code / json 23.6 / 40.7 / 30.7 vs Spark plain 43.2, so the default is off
strix-hip all-models build runner 45058890114 ✅
CI 45058887405 fmt, clippy, cargo test, kernel shadow, typos, SPDX ✅. The env budget and PR benchmark gate checks fail on main itself (run 44991651911) and on #401's head; this PR adds no ATLAS_* names

Profiling-driven changes: the WMMA expert GEMM cut prefill time 2.5× against grouped GEMVs (f350 → f351), and the WMMA fused gates sped prefill up 11% (f358 → f360). The single-warp NVFP4 GEMV for Spark decode is bit-identical (8/8 greedy) and +1.4% at C1 (f371). A 64-wide-K GEMM variant measured 9% slower and was dropped.

Head-to-head (each block on one runner, same client and prompts; reasoning off; medians)

engine C1 decode prose / code / json aggregate C1 / 2 / 4 / 8 prefill 7.8K / 31K tokens agentic ×10 ST-995
Atlas Spark (this PR) 40.9 / 40.9 / 40.9 40.2 / 47.9 / 63.5 / 81.2 1,190 / 951 tok/s 10/10, 7.5 s/turn 79.1
Ciru v1.2.2, single, DSpark K=7 (its fitted weights) 40.1 / 60.1 / 47.5 40.3 / 47.1 / 45.7 / 46.7 1,514 / 1,132 10/10, 4.1 s/turn running
Ciru, concurrent (8 seqs) 20.1 / 26.2 / 24.0 20.6 / 34.0 / 55.2 / 87.9 1,299 / 1,060
Ciru, no-spec 46.6 / 46.6 / 46.4 46.2 flat 1,347 / 1,096
Ciru --original-weights fails: FileNotFoundError 'layer6.pt' (its launcher has no path for the checkpoint's own experts)
llama.cpp master, ggml-org Q8_0 20.3 / 20.3 / 20.3 20.2 / 29.5 / 40.6 / 50.2 276 / 187 9/10, 15.0 s/turn
Halogen 0.20.1 cannot serve Inkling: thinkingmachines/Inkling-2-Mini has no qwen38-flash-next-v2.hgn (Flash-Next-only pack format)

Runs: Atlas / llama.cpp 44993335678; Ciru + Atlas anchor 44998230706; Ciru agentic 45004732792; llama.cpp agentic 45004734856.

Atlas leads llama.cpp on every leg and Ciru's concurrent mode at C1–C4. Ciru leads on C1 decode, prefill, C8 and agentic turn time. Ciru serves its own fitted expert weights, and its checkpoint-expert path does not start, so this is not fully like-for-like. Closing the gap is follow-up work: launch gaps (85% GPU busy), NVFP4 GEMV efficiency, a multi-head prefill attention kernel, and the expert GEMM at about 19 TFLOP/s.

Known gaps

  • Prefill expert inputs: AMD prefill feeds BF16 rows to the experts; gb10 quantizes them to the checkpoint's declared W4A4 / W8A8 inputs. Decode uses BF16 rows on both.
  • DSpark: loses on prose and in Spark mode. The C1 draft depth isn't tunable (ATLAS_DFLASH_BATCH_DEPTH sets the batched depth only).
  • Speed vs Ciru: behind on the legs listed above.
  • strix (58 GB box): untested; the script caps util at 0.82 there.
  • GB10 PTX byte-identity: the gb10 .cu files got AMD-only branches (inkling2_flash_prefill, _head_ops, _moe_decode, _moe_prefill, _prefill_attn, and common/dense_gemv_bf16_batchm.cu). The GB10 PTX byte-identity check is pending from the GB10 worker. Every NVIDIA token stream is unchanged by construction.

Credit

Inkling 2 support, its kernels, DSpark and the Spark overlay are @data-angel's (#401, Enntity/sparkinkling). References: huggingface/transformers#51050, ggml-org/llama.cpp#32694, vllm-project/vllm#69028.

🤖 Generated with Claude Code

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

GB10 no-change check: the gb10 PTX of this PR is identical to its base. This PR (head afff3de) adds AMD-only branches to five kernels/gb10/inkling-2-mini/nvfp4/*.cu files. The check: compile them for GB10 and compare against base/inkling2-401 = #401 head 878d7a7.

Setup:

  • Builds: native cargo builds on sparky (GB10, nvcc sm_121a), the build system's own --ptx -O3 --Werror all-warnings flags, ATLAS_TARGET_HW=gb10 ATLAS_TARGET_QUANT=nvfp4.
  • Base 878d7a7: inkling-2-mini binary b695b0361273479c, qwen3.8-27b binary 98ee88e583035c0d.
  • This PR afff3de: inkling-2-mini binary b43e309f58d6ece5, qwen3.8-27b binary f818285493051c1f.
target PTX files byte-identical differ
inkling-2-mini 213 211 moe_permute, moe_topk_softmax_bias
qwen3.8-27b 221 219 the same two
  • The five touched files are byte-identical: inkling2_flash_prefill, inkling2_head_ops, inkling2_moe_decode, inkling2_moe_prefill, inkling2_prefill_attn.
  • The two that differ are untouched common kernels. They differ only in the worktree path baked into the PTX (the __FILE__ assert string and nvcc's path-hashed _INTERNAL_<hash> namespace). After normalising those two, both files are identical in both targets. The same two files differ the same way between any two worktrees, for example main vs Inkling 2 Mini (inkling2_loop) on GB10: Strict and Spark modes, DSpark drafter #401.

Conclusion: on GB10 the AMD branches compile out. This PR changes no gb10 PTX for inkling-2-mini or qwen3.8-27b, so no GB10 serving re-test is needed for it.

🤖 Generated with Claude Code

AzeezIsh and others added 10 commits November 23, 2026 00:22
…essage gates

The gb10 Inkling kernels that are NVIDIA-only PTX get AMD builds; the plain-CUDA
ones (decode attention + combine, short convs, block residuals, head norm, the
two-kernel message gates, misc glue, the DSpark drafter kernels, logit softcap)
compile unchanged under hipcc.

- Prefill attention: inkling2_flash_prefill is mma.sync / cp.async / ldmatrix and
  builds as a trap stub under __SCALE__ / __HIP_PLATFORM_AMD__; under
  cfg!(atlas_scale) every prefill row count takes the per-head paged body, which on
  strix-hip is the WMMA port in strix-hip/common/prefill_paged_compute.cuh. That
  body gains the gb10 INKLING2_PREFILL_BIAS / INKLING2_ROW_SINKS hooks and
  INKLING2_PREFILL_BIAS_INLINE: the relative bias is computed where it is added
  (BF16(sum_j rel[j] * rel_proj[j][dist]) in fp32 j order, as
  inkling2_rel_bias_table rounds it) instead of a [rows, heads, 1024] table written
  and read every visit, whose grid.y passed 65,535 from 2,731 rows on this path.
- Message gates: inkling2_msg_gate_fused (mma.sync) is a stub on AMD and the
  two-kernel path (msg_gate_z + msg_gate_out) runs for every row count.

NVIDIA preprocessing is unchanged: every AMD branch sits under a macro nvcc never
defines, and the gb10 bias path keeps its table.

Verified on framework (Strix Halo gfx1151) with the rest of this series: prefill
(echo) logprobs vs decode logprobs on the same 96 greedy token ids, prompts 166 to
11,886 tokens, 96/96 aligned, mean |dlogp| 0.007-0.032; the in-place bias left
those numbers and the NLL bit-identical to the table path (f351 vs f353).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Expert decode GEMVs (inkling2_moe_decode.cu): an AMD branch for the instructions
  hipcc lacks.
  - E4M3 scales decode by bit math (the AMD compat __nv_fp8_e4m3 -> float decode is
    not the standard format; same decode as common/dense_gemv_fp8w.cu).
  - cvt.rn.f16x2.e2m1x2 -> exact and branch-free: a code's sign and 3 magnitude bits
    placed at FP16 bits 15 and 9..11 read as 2^(e-15)(1 + m/2), or m 2^-15 when
    subnormal, and times 2^14 that is E2M1 exactly. Two codes a half2.
  - ld.global.nc.L1::no_allocate -> a plain 16-byte load.
  - __syncwarp (not in hipcc) -> a wavefront fence + wave barrier around the
    shared scale rows.
- Activation quantizers (inkling2_moe_prefill.cu): e2m1 / e4m3 cvt PTX, used only by
  the block-scaled W4A4 / W8A8 GEMMs; trap stubs on AMD. interleave_rows (load time)
  is unchanged.
- strix-hip inkling2_moe_gemm.cu: the W4A4 / W8A8 (mma.sync kind::mxf4nvf4 /
  kind::mxf8f6f4) entries and their tile list as stubs; under cfg!(atlas_scale)
  prefill rows take the grouped expert GEMVs over BF16 rows. The next commits replace
  this with a WMMA GEMM.

Measured on framework: an earlier E2M1 stand-in (select + float assembly) ran
the NVFP4 gate_up / down GEMVs at 304 / 162 us against 120 / 68 us for the
LUT it replaced (rocprofv3, f361); this form brought Strict C1 decode from 20.5
back to 28.2 tok/s (f362) with prefill-vs-decode logprobs and NLL identical to
the digit (value-exact).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kernels/strix-hip/inkling-2-mini serves Inkling 2 Mini (Strict and Spark) on Strix
Halo: its nvfp4/ links the gb10 target's Inkling kernels (with the AMD branches of
the two previous commits) over strix-hip/common, plus its own inkling2_moe_gemm.cu.
No kernel_source (the gb10 target's, laguna-s-2.1, has no strix-hip twin; every
module it supplies is in strix-hip/common). KERNEL.toml sets -DHDIM=128: the
inherited paged decode / prefill bodies size per-lane vectors from HDIM (default
256) and would read past each 128-wide head silently. MODEL.toml is the gb10
target's plus [expected_absent] for the SSM h-dtype and token-overlay probes the
model build issues (both gated on handle != 0, neither on Inkling's path).

DSpark needs no AMD-specific code: its drafter kernels (inkling2_dspark.cu) are
plain CUDA and the DFlash head runs on strix-hip/common's kernels.

Verified on framework (Strix Halo, ROCm, util 0.80, BF16 KV), with this series:
boots (20.4 GB pre-KV, 307,984 KV tokens), 0 ERROR / panic / hipError lines;
greedy answers coherent and deterministic; SparkInkling task_probe 30/30 math,
10/10 tools in Strict and Spark (= the GB10 release receipt); the DSpark drafter
loads (3 layers, rnn_hidden rank 256, taps 5/23/41/48) and serves coherent text.
The DevLab Strix runner's all-models strix-hip build passes (runs 44951388440,
44954659451).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
strix-hip's inkling2_moe_gemm.cu gains the BF16-row grouped expert GEMMs on
__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32 (the path gb10 carried until #401's
cb10558 moved its prefill to W4A4 / W8A8 only): NVFP4 and MXFP8 stacked
checkpoint tensors dequantised per 32-wide K step to BF16 in gb10's order
(BF16(e2m1 * (E4M3(scale) * s2[e])), BF16(E4M3(code) * 2^(E8M0 - 127))), E4M3 by bit
math, tiles 128 (NVFP4) / 64 (MXFP8) rows x 128 outputs, 8 waves, WMMA operands by
16-byte shared loads; and inkling2_softcap_swiglu between gate_up and down.
moe_prefill takes moe_prefill_bf16 under cfg!(atlas_scale) (kernel handles
resolved only there) instead of the grouped GEMVs.

A/B on framework (grouped GEMVs f350 vs WMMA f351, Strict, one sequence): the
same ~1.8K-token prefill chunks 13.3 / 8.0 / 8.2 / 15.9 s -> 5.3 / 3.2 / 3.2 / 6.2 s
(2.5x); NLL over 57,648 tokens code 0.63694 -> 0.63704, text 0.89798 -> 0.89694
(noise); prefill-vs-decode logprobs 96/96 aligned on all six prompts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
inkling2_msg_gate_fused gets an AMD branch on
__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32 with the gb10 kernel's phases,
arguments and roundings: rms of every gate's h and m rows; z = BF16(D BF16([rms0(h);
rms0(m)])) on waves 0-3 (one 16-wide rank tile each); then 64 channels a step,
F z on waves 0-3 and G z on waves 4-7 staged in fp32, and
out = (1 - tanh(F z)) * h + tanh(G z) * m with every gate's inputs read before its
outputs are written (out may alias h). Operands by 16-byte shared loads; BF16
staged element-wise (hipcc's bf16 header has no __floats2bfloat162_rn).
spark-model takes it on AMD from 16 rows, as on gb10.

Why: rocprofv3 of a 4,778-token prefill (f355) put the two-kernel path at 15.6%
of prefill (msg_gate_z 4.2 ms + msg_gate_out 2.2 ms per visit and chunk).
A/B on framework (f358 two-kernel at 6eaa417 vs f360 this, which also carries
#401 db19431): prefill 4,778 tokens 3,917 -> 3,524 ms (1,220 -> 1,356 tok/s),
16,725 tokens 1,140 -> 1,266 tok/s; NLL code 0.63704 -> 0.63689, text 0.89694
-> 0.89618; prefill-vs-decode logprobs 96/96 aligned, mean |dlogp| 0.007-0.027.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One entry point in the serve-nemotron-strix-linux.sh mould: MODE=spark|strict
and DSPARK=0|1 (default spark, no drafter: on framework DSpark gains only on
Strict code). Downloads the pinned checkpoint, and the Spark overlay or the
DSpark drafter as asked; assembles the index-mapped Spark directory (as
SparkInkling's spark_overlay.py does) and #401's drafter directory
(mtp.safetensors as model.safetensors, config = mtp_config + vocab_size).
Refuses without /dev/kfd or a gfx1151 agent, caps GPU_UTIL at 0.82 below 80 GiB
GPU-visible (the 64 GB-class host OOM line), builds the inkling-2-mini target
when its inputs changed, serves with prefix caching on and prints a ready curl;
--check starts, sends one request and stops. MODEL.toml gains a QUICKSTART note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Formatting only: attn_ops.rs (AMD prefill ensure!) and moe_ops.rs
(moe_prefill_bf16 launches), as cargo fmt lays them out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…V on AMD; rustfmt

- pdl_tests::pdl_target_kernels_wait_exactly_when_listed reads every definition
  of a listed kernel, AMD branches included: the AMD stubs of
  inkling2_flash_prefill and the activation quantizers, and the WMMA branch of
  inkling2_msg_gate_fused, now call atlas_pdl_enter() (a no-op off sm_90+).
- #401 c4db7a3's inkling2_router_gemv.cu #includes
  common/dense_gemv_bf16_batchm.cu; included text skips build.rs's warp-mask
  widening, and ROCm 10.1 (DevLab runner) static-asserts on the 32-bit
  __shfl_down_sync mask (run 44997959809). The AMD branch passes 0xFFFFFFFFULL;
  NVIDIA tokens are unchanged.
- inkling_turn_tests.rs: cargo fmt layout of one assert (CI fmt).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Spark overlay's NVFP4 projections took w4a16_gemv for one row: 27% of Spark
decode, 288 calls a token at ~20 us (~133 GB/s; rocprofv3 f370, bin
00d6e75e4aa3). Under cfg!(atlas_scale) one row takes w4a16_gemv_sw when it
resolves: the same partial and reduction (bit-identical outputs), 8 outputs a
256-thread block on one wave each instead of 4 on two. NVIDIA unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es only)

moe_ops.rs 564->455 (moe_prefill_bf16 + the GEMM_M_TILE_* consts ->
moe_prefill_hip.rs), ops.rs 519->392 (the MsgGate/msg_gate cluster ->
gate_ops.rs, re-exported as ops::* like attn_ops/moe_ops). No logic
changes; with #401's four splits the CI file-size cap goes green.
@AzeezIsh
AzeezIsh force-pushed the feat/inkling2-hip-pr branch from 48df64f to 0ecff7a Compare November 23, 2026 05:22
@AzeezIsh
AzeezIsh changed the base branch from base/inkling2-401 to main November 23, 2026 05:22
@AzeezIsh
AzeezIsh marked this pull request as ready for review November 23, 2026 06:09
@AzeezIsh
AzeezIsh merged commit 855df74 into main Nov 23, 2026
26 of 47 checks passed
data-angel added a commit to Enntity/atlas that referenced this pull request Nov 23, 2026
…split, Atlas-Inf#403, Atlas-Inf#404, Atlas-Inf#406, Atlas-Inf#410) into the images follow-up

Two conflicts, both from the split of 401: layers/inkling2/mod.rs declares
owner_runs and proj, and inkling2_proj_gemv joins the PDL list in its new
file pdl_inkling2.rs. The tree equals this branch's five commits replayed
onto main.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
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.

1 participant