Repository navigation
Conversation
|
Thanks @jschmied, this is a tidy port. It reuses the shared CUDA pieces wherever they fit, and the contract finding the all-NaN router row is a good catch. #1377 has landed as rewritten commits, so this branch no longer merges with main: it conflicts in Before this leaves draft:
To your questions: moving both headers under Then we'll run the kernel contract and its limits at 13.0 and 13.2, and compare Nemotron's head-128 machine code with main. Then we'll serve the 4-bit export on a GB10: drafted against plain, concurrent against solo at 1, 4 and 8 streams, and speed. |
bcf3650 to
7390fb3
Compare
|
Thanks @ashhart. All five are done, and the branch is rebased onto main (
The served checks were rerun on the rebased head (GB10, |
The shared-window chunk and merge bodies move to paged_attn_segs.cuh, included twice by nemotron_attention.cu: Nemotron's head-128 kernels keep their names and SASS, and head 64 adds tf_paged_attn_chunk_segs_64 and tf_paged_attn_merge_segs_64. prefill_attention.cu instantiates pattn_kernel<64, 8, 4, 8> over paged caches. sassid on sm_80/86/89/120/121: 0 functions changed, 15 added.
lfm2_moe.cu holds what the shared operators do not: the short conv over each stream's state with every window row's snapshot, the commit of an accepted row's conv state, and the router (fp32 weights, top-4 of sigmoid + bias, ties to the lower id, a NaN ranked as -inf). Each has a planted control. Launch records cover these kernels and the head-64 paged attention on nvcc 13.0, with one 13.2 override.
The MLX 4-bit checkpoint (embedding at 4, 6 or 8 bits) on the shared affine-4 projections and experts, with prompt chunks of 1024 rows, one-row decode and copy-drafted windows over --parallel streams. The ten attention layers keep their keys and values in 512-position pages, and each stream has its own conv state. There is no drafter and no prompt cache yet.
…ount The gated short conv over each stream's state and the conv-state commit move out of lfm2_moe.cuh into liquid_conv.cuh, templated on the tap count, so LFM3 (7 taps) can take the same bodies as LFM2.5 (3). lfm2_moe.cu keeps the router and instantiates the 3-tap pair as tf_liquid_conv_3 and tf_liquid_commit_3; the controls become tf_ctl_liquid_conv_3 and tf_ctl_liquid_commit_3. cuobjdump -sass on sm_80/86/89/120/121, nvcc 13.0 and 13.2: the moved bodies are identical under their new names, every other function unchanged.
… against float64 tf_paged_attn_chunk_segs_64 with tf_paged_attn_merge_segs_64 and pattn_kernel<64, 8, 4, 8> run over shuffled 512-key pages, decode rows over up to eight streams a launch, and are held head by head to contract_attn's float64 bound. Two controls in contract_controls.cu read the values from the neighbouring lane's dims (decode) and from the neighbouring 8 dims (prompt rows). To build them from the same bodies, nemotron_attention.cu's page and tile helpers move to paged_attn.cuh and prefill_attention.cu's to prefill_attention.cuh; every existing function's SASS is unchanged on sm_80/86/89/120/121 under nvcc 13.0 and 13.2.
… of every top-1 miss ref64.py dequantizes the MLX 4-bit weights exactly and runs the forward in float64; --bf16 adds the engine's bf16 storage points. It checks the CUDA engine's greedy picks on teacher-forced prompt rows and on reply rows; REF64.md lists each miss with the prompt, the position, both tokens and both margins.
The recipe gets a CUDA section (build, serve, revision, GB10 receipt, licence), the README row names one NVIDIA GPU beside the Mac, and the contract's coverage lists LFM2.5's CUDA kernels.
7390fb3 to
0a9de29
Compare
Part of #1488. Rebased onto main (
80b30ed8a); #1377's commits are gone from the branch.What
LFM2.5-24B-A2B (
lfm2_moe) served natively on CUDA fromLiquidAI/LFM2.5-24B-A2B-MLX-4bit: plain serving with--parallel Nand TF's built-in drafts. No DSpark drafter yet. The engine reuses the shared CUDA pieces wherever they fit.addRmsTailnorms, the SwiGLU act with group sums,qk_rows(q/k norm + RoPE), the page KV write, the Affine4 experts with the grouped plan, the MoE combine, andtree_roundargmax / sampling.prefill_attention's prompt kernel at head dim 64, and the paged shared-window attention at head dim 64. Its body moves from Nemotron's file into a neutralpaged_attn_segs.cuh, and its prelude intopaged_attn.cuh. Head 64 exportstf_paged_attn_chunk_segs_64/tf_paged_attn_merge_segs_64, and Nemotron's head-128 symbols keep their names and machine code.liquid_conv.cuh, templated on the tap count (tf_liquid_conv_3/tf_liquid_commit_3), so LFM3's 7-tap conv (lfm3: serve LFM3-1.7B on CUDA: NVFP4 and FP8 weight-only, MLX 4-bit (stacked on #1513, #1492 and #1503) #1508) reuses them; only the router stays inlfm2_moe.cu.Commits:
751ec79e9cuda: the paged shared-window attention at head dim 643b613a26dlfm2_moe: CUDA glue kernels under the contract5e5477f51lfm2_moe: serve LFM2.5-24B-A2B on CUDAf3b5e60fbcuda: Liquid's short conv and its commit in liquid_conv.cuh, by tap count22eba9470kernel contract: the limits check reads lfm2_moe's fatbine2fb1c492kernel contract: the head-64 paged attention, decode and prompt rows, against float64f52c228a9tools: LFM2.5-24B-A2B's float64 reference on the CPU, and its receipt of every top-1 miss7390fb391docs: LFM2.5-24B-A2B on CUDA, its receipt and the weights' licence34 files, +3,171 / −251 against main.
Verification (GB10, sm_121)
nemotron_attention45 functions (+10 new),prefill_attention35 (+5),contract_controls250 (+30).contract_attn.zig's float64 bound (attention_ref), over shuffled 512-key pages with several streams a launch. Decode rows run the chunk and merge pair at 1/3,000, 16/1,500, 128/700 and 8/4,000 rows/keys. Prompt rows runpattn_kernel<64, 8, 4, 8>at 256 rows with no history, 64 rows after 3,000 keys, and 100 after 500. A NaN query, ±inf values and a NaN key are planted.--parallel 8, greedy:tools/lfm2_moe/ref64.py, CPU, the MLX weights dequantized exactly, every op in float64): the engine's greedy token on 421 of 435 teacher-forced prompt rows and 123 of 128 reply rows. With the engine's bf16 storage points it's 424/435 and 123/128.tools/lfm2_moe/REF64.mdlists all 19 misses with both tokens and both margins.lean_check: 0 new problems against main.zig fmt --check zigandzig build testpass.Speed (GB10, before the rebase)
Cold TTFT: 0.32 s at 2.8k prompt tokens, 1.32 s at 11.2k.
Docs
docs/recipes/lfm2.5-24b-a2b.md: a CUDA section with the command, the revision (667408d4), the GB10 receipt and the weights' licence (LFM Open License v1.0).README.md: the LFM2.5 row names one NVIDIA GPU with the 4-bit export.docs/kernel-contract.md: LFM2.5's kernels and the two attention controls under Coverage.Not in this PR
paged_attn_segs.cuhandliquid_conv.cuhunderzig/kernels/cuda/common/, once cuda: shared device primitives in zig/kernels/cuda/common (#1409, part 1: SASS unchanged) #1440 lands.