Skip to content

lfm3 CUDA: serve the block FP8 export weight-only and the MLX 4-bit export as stored (stacked on #1508) - #1634

Merged
ashhart merged 9 commits into
ashhart:mainfrom
jschmied:lfm3-cuda-fp8
Nov 25, 2026
Merged

ashhart merged 9 commits into
ashhart:mainfrom
jschmied:lfm3-cuda-fp8

Conversation

@jschmied

@jschmied jschmied commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Current head f3d0fd7051: ashhart's rebase onto main 22d77f7839 (6d91aa5cb) plus one docs commit. That commit says the contract in docs/recipes/lfm3-cuda.md: weight-only, with the stored FP8 and NVFP4 weights served as loaded with bf16 inputs. The release's input scales are read and not applied, the dynamic FP8 input step is not applied, and activations stay bf16. The served receipts (FP8, MLX 4-bit, LFM2.5 against main) and the 8-stream cache timing ran on 6d91aa5cb, whose code this head keeps unchanged; they are in #1634 (comment).

  • The 8-stream FP8 decode loss is withdrawn: on 6d91aa5cb against 2b748e000 it is +0.10 % (noise floor 0.56 %), WITHIN NOISE. The "Don't land yet" rows below are history.
  • The cold-turn cost of the prompt cache is a separate result.
    • With the cache on, FP8's cold first token is 2.8 % slower than with --prompt-cache-gib 0 (5 of 5 rounds), and decode is about 5 % faster.
    • LFM2.5 on main shows the same pattern: cold first token -0.5 %, within its noise but 5 of 5; decode +4 to 5 %.
    • So it comes from the prompt cache's keep path, which main already has, not from this PR's code. It is not attributed to any one base commit.

The sections below describe earlier heads.

Stacked on #1508 (head 0fa0fa122); every commit after it is this PR's own. The head is 82cb493d8. Rebased onto
#1508 after its rebase onto main e7e24243d: our ref64.py commit 4ab6a44e6 dropped out (main has the same file
byte for byte, from #1696), and so did the tools part of the docs commit.

What

LFM3-1.7B's other two text exports on CUDA, beside #1508's NVFP4:

  • Admission (503883283): LiquidAI/LFM3-1.7B-FP8 (revision 243955da, compressed-tensors FP8_BLOCK). The
    recipe, the ignore list and all 402 tensors are checked as published.
  • Refused by name where it isn't served (503883283, 042028b62): servedOn refuses fp8_block with
    Lfm3Fp8BlockNotOnMetal or Lfm3Fp8BlockNotOnXpu, beside lfm3: serve LFM3-1.7B on CUDA: NVFP4 and FP8 weight-only, MLX 4-bit (stacked on #1513, #1492 and #1503) #1508's two NVFP4 refusals, and servedProblem words
    all four. Metal's and XPU's opens already ask servedOn (lfm3: serve LFM3-1.7B on CUDA: NVFP4 and FP8 weight-only, MLX 4-bit (stacked on #1513, #1492 and #1503) #1508), before any weight is read and, on XPU, before
    the Level Zero driver. No new path: the FP8 case is one more arm of the same switch.
  • Served (7c0fa775e, 8faf23426):
    • FP8 weight-only: the FFN and q/k/v/o on the block-FP8 lane, activations bf16; the export's dynamic FP8
      input quantization is not applied. The bf16 attention gate is a projection of its own.
    • LiquidAI/LFM3-1.7B-MLX-4bit (revision d0ca73dc) as stored: every projection and the tied head as
      affine-4 tiles, prompt chunks on the affine prompt GEMM, decode rows on the verify tiles.
    • The 6- and 8-bit MLX exports and VL are refused by name. Each load line says what is served.
  • Docs (d986410d1): the recipe's table of the three exports. The float64 receipts are main's
    tools/lfm3/REF64.md.
  • Receipt (82cb493d8): docs/receipts/lfm-cuda-sass-fad7e142/ regenerated against main e7e24243d.

No kernel changes, and no file outside families/lfm3, the XPU refusal test and the docs. Liquid's shared backend
and LFM2.5 are #1508's, unchanged.

Verification (GB10, sm_121, real weights, on this head)

Speed (GB10)

A-B-B-A, 4 servers an arm, the same 6 cold chats (10.4k tokens) on every server, paired medians.

this head reference paired
FP8 decode, 1 / 4 / 8 streams (tok/s) 254.9 / 359.1 / 584.8 255.3 / 358.9 / 590.8 (3551fd822)
FP8 cold chat turn 1.183 s 1.188 s -0.7 ms, 10 of 24 slower
MLX 4-bit decode, 1 / 4 / 8 196.8 / 676.0 / 1067.4 197.2 / 678.1 / 1067.9 (3551fd822)
MLX 4-bit cold chat turn 0.642 s 0.644 s +0.1 ms, 12 of 24 slower
NVFP4 decode, 1 / 4 / 8 120.2 / 420.4 / 750.8 120.3 / 421.0 / 750.6 (#1508 0fa0fa122)
NVFP4 cold chat turn 0.825 s 0.824 s +0.3 ms, 13 of 24 slower
LFM2.5 decode, 1 / 4 / 8 173.7 / 192.6 / 281.2 174.5 / 192.4 / 281.6 (main e7e24243d)
LFM2.5 cold chat turn, 3 runs main, main, #1508 +7.0 ms 18/24, +7.2 ms 13/24, +5.1 ms 16/24

Two rows are paired losses, said plainly. Don't land yet until both are explained:

Proposed CHANGELOG line

- LFM3-1.7B FP8 (block, weight-only) and MLX 4-bit (as stored) served on CUDA; Metal and XPU refuse the FP8 export by name (#1634, after #1508)

Licence

The weights are under Liquid AI's LFM Open License v1.0 (license: other, lfm1.0), as the NVFP4 and MLX exports
are.

@ashhart

ashhart commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied, and thanks for splitting this out so cleanly. Reusing the affine-4 tiles for the MLX export as stored, and the float64 receipts listing every miss for both exports, are what we were hoping for.

This one waits on #1508, which waits on #1492, #1503 and #1513, so we can't run it yet. When you rebase the stack onto main, note that main has since moved the shared attention helpers (texp, ldmatrix, the cp.async commit and wait) into common/qmm_frag.cuh and common/cp_async.cuh. prefill_attention.cu now conflicts with the move into prefill_attention.cuh, and the SASS receipt will need regenerating after that.

One small thing in the new commits: in lfm3/cuda_weights.zig the load log if (!fp8) ... "LFM3 NVFP4 on CUDA serves weight-only" also prints for the MLX 4-bit export, which is served as stored. Could it say so for MLX, or print nothing?

Once it's on main, we'll serve both exports on a GB10: drafted against plain, concurrent against solo, prompts across the sliding window, and resumed against fresh. If you have time before then, those same checks for FP8 and MLX 4-bit (you listed them as not run) would speed things up.

@jschmied

Copy link
Copy Markdown
Contributor Author

One commit added on top, 4ab6a44e6: tools/lfm3/ref64.py now also runs on numpy without torch.

  • Why: the Intel GPU work (LFM3-1.7B on the XPU backend (Intel GPUs, Iris Xe first) #1666) checks its LFM3 forward against these dumps on a machine without torch.
  • The numpy path: MLX affine is dequantized exactly. NVFP4 and FP8 still need torch and say so.
  • New in both paths: --bf16-points (the storage points of a bf16 engine) and dump / check subcommands.
  • The torch path is unchanged: on the GB10, the old and new script give byte-identical output for all four receipt runs (MLX, FP8, NVFP4, NVFP4 --bf16). The numpy path matches torch exactly on MLX.
  • REF64.md gains a short "Without torch" section.

@jschmied

Copy link
Copy Markdown
Contributor Author

Thanks @ashhart, fixed in 3551fd822. The MLX 4-bit export now logs "LFM3 MLX 4-bit on CUDA serves the export as stored: affine-4 weights, bf16 activations". The NVFP4 weight-only line prints for NVFP4 only. Lean, test and CI are green.

On the rebase: noted that main moved the shared attention helpers into common/qmm_frag.cuh and common/cp_async.cuh. I will rebase the stack and regenerate the SASS receipt once #1508 is ready, or earlier if you want it.

@ashhart

ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied, the load log is right now: FP8, MLX 4-bit and NVFP4 each say what's served, and the MLX line says it's served as stored. The numpy path for ref64.py is the same file #1696 carries, so whichever lands first keeps it.

This still waits on #1508, and that's on us: #1508 needs #1492 and #1503 first, and we owe their runs. When you rebase, please regenerate the SASS receipt after the move into common/qmm_frag.cuh and common/cp_async.cuh. Once it's on main, we'll serve both exports on a GB10: drafted against plain, concurrent against solo, prompts across the sliding window, and resumed against fresh. If you run any of those for FP8 or MLX 4-bit first, paste them here.

@ashhart

ashhart commented Nov 6, 2026

Copy link
Copy Markdown
Owner

/atc exchange 79fc1ac2936caca2ede559f5aa3603fb08bf85d2ae72e9b9534e31a700a86b66

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

(Optional: nothing new from the author since our last note.)

Thanks @jschmied, a quick status note. Nothing is needed on this PR yet. #1492 is on main now, so the stack below this
is down to #1503 and #1508. #1503 has one small ask on its own thread, and #1508 follows it. When #1508 rebases, its
pages switch (zig/src/families/liquid/cuda_native.zig:57-58, read with getenv and on for anything but 0) will need
to go through platform/environment.zig like the other settings.

When you rebase this after #1508: tools/lfm3/ref64.py and REF64.md are already on main byte for byte (they came in with
#1696), so 4ab6a44e6 should drop out. Please regenerate the SASS receipt against that day's main, and add a CHANGELOG
line under ## Unreleased with "(#1634, after #1508)". Then we serve both exports on a GB10: drafted against plain,
concurrent against solo, prompts across the sliding window, and resumed against fresh. Main is frozen for a release
right now, so the stack moves once that's out.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied, a status note. Nothing is needed on this PR yet: #1503 is queued to land, and #1508 follows it with the rebase you've taken on. We read this head against today's main so the rebase holds no surprises:

  1. tools/lfm3/ref64.py and tools/lfm3/REF64.md on main are byte-identical to this branch's, so 4ab6a44e6 drops out.
  2. servedOn refuses fp8_block only on Metal (zig/src/families/lfm3/config.zig:377). Once lfm3: serve LFM3-1.7B on CUDA: NVFP4 and FP8 weight-only, MLX 4-bit (stacked on #1513, #1492 and #1503) #1508 gives Backend its .xpu case for the XPU LFM3 path, please refuse the FP8 export there by name too, with a test through the XPU open, as we asked for NVFP4 on lfm3: serve LFM3-1.7B on CUDA: NVFP4 and FP8 weight-only, MLX 4-bit (stacked on #1513, #1492 and #1503) #1508.
  3. As before: regenerate the SASS receipt in docs/receipts/lfm-cuda-sass-fad7e142/ against that day's main, and add a CHANGELOG line under ## Unreleased with "(lfm3 CUDA: serve the block FP8 export weight-only and the MLX 4-bit export as stored (stacked on #1508) #1634, after lfm3: serve LFM3-1.7B on CUDA: NVFP4 and FP8 weight-only, MLX 4-bit (stacked on #1513, #1492 and #1503) #1508)".

Then we serve both exports on a GB10: drafted against plain, concurrent against solo, prompts across the sliding window, and resumed against fresh.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied, and thanks again for the per-server rows and harness: they make the decode comparison easy to repeat.

We've read the current head against today's main, and there's nothing left for you on the code:

When this is rebased, the overlaps with main are all simple list merges, and we'll take care of them.

What remains:

  • Landing order: this lands after lfm3: serve LFM3-1.7B on CUDA: NVFP4 and FP8 weight-only, MLX 4-bit (stacked on #1513, #1492 and #1503) #1508.

  • Served receipts: the LFM3 and LFM2.5 checkpoints aren't on our test machines, so the served checks need to come from your side: both exports against the serial reference, and LFM2.5 against main, since the Liquid backend is shared.

  • The 0.6% FP8 decode cost at eight streams with the prompt cache on: please use your A/A setup to see whether it comes from the shared cache path in the base, and whether LFM2.5 on main pays it too.

  • Synthena

@jschmied

Copy link
Copy Markdown
Contributor Author

@ashhart Receipts for 6d91aa5cb on its base, main 22d77f7839, on a GB10 (sm_121).

Setup

Binary md5
head 8de1844f
2b748e000 7c6d8c95
main e767b079
  • Host: the LFM3, Liquid, LFM2.5 and XPU-refusal host tests, test-gradient-serving and check-native-cuda-host: 40/40 steps, 126/126 tests.

Served, full replies

  • Same gate as on lfm3: serve LFM3-1.7B on CUDA: NVFP4 and FP8 weight-only, MLX 4-bit (stacked on #1513, #1492 and #1503) #1508: reasoning_content + content hashed, an empty reply fails, --parallel 8, 8 chats x 4 turns, greedy and seeded.
  • Five setups: the prompt cache on, off and at 0.1 GiB, under memory pressure, and on fixed pages.
  • Each setup checks:
    • replies equal to the reference;
    • resumed turns equal to fresh ones;
    • 4 and 8 streams equal to serial, greedy and seeded, so serial is the reference within each server too;
    • drafted equal to plain;
    • 8 long prompts at once equal to serial.
  • Across setups: the reference's own serial and 8-stream replies equal the head's, and a restart gives the same replies. Every drain reads the pool free.
Export Reference Result Hash Pool under pressure
FP8 2b748e000 equal in all five setups 08dd45137673299c 260/260
MLX 4-bit 2b748e000 equal in all five setups 547177753a9cf9ab 390/390
LFM2.5 main 22d77f7839 equal in all five setups 4ff0de75305c9165 72/72

The FP8 decode cost at 8 streams (abba5.py)

  • Each comparison runs 3 A-against-A rounds for the noise floor, then 5 rounds of A, B, B, A, each on a fresh server.
  • Cells: a cold ~9k-token chat's first token, 1-stream decode, and 8 streams at once.
  • Tokens were equal across all runs of each comparison.
  • Below, + means B is better. Each row is the median paired change, with the noise floor in brackets.
Cell 1. FP8, head (B) against 2b748e000 (A), cache on 2. FP8 head, cache on (B) against --prompt-cache-gib 0 (A) 3. LFM2.5 on main, cache on (B) against --prompt-cache-gib 0 (A)
decode, 8 streams +0.10 % (0.56 %), within noise +5.06 % (0.16 %), faster 5 of 5 +4.27 % (0.17 %), faster 5 of 5
decode, 1 stream -0.05 % (0.44 %), within noise +5.35 %, faster +5.08 %, faster
cold first token +0.17 % (0.31 %), within noise -2.77 % (0.09 %), slower 5 of 5 -0.53 % (0.72 %), within noise, but slower 5 of 5
  • Comparison 1: the 0.6 % (earlier 1.0 %) loss at 8 streams doesn't reproduce on this head against the previous one.
  • Comparisons 2 and 3: the cache path behaves the same in FP8 on this head and in LFM2.5 on main, so it is the base's, not this PR's.
    • Decode with the cache on is about 5 % faster than with it off. That is not a cost. I haven't isolated why the cache-off server decodes slower.
    • The cost is on the cold turn: saving kept states at the marks adds 2.8 % to FP8's first token. On LFM2.5 on main it points the same way but stays inside its noise floor.

I didn't change any code, and the list merges stay with you as you said.

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied. The current A/A comparison answers the old eight-stream decode question: that loss no longer reproduces as reported. The Windows guard and named FP8 refusals are also present, and the new full-reply comparisons are useful.

The weight pin identifies LiquidAI's own FP8 release. The remaining exactness question is its activation recipe: the config requires dynamic FP8 inputs, while the runtime explicitly skips that operation. Comparing with the previous weight-only head does not establish equality with the published recipe. Please preserve the published activation behavior and compare with its exact serial reference, or provide an agreed interpretation and exact equivalence proof. The cache-on/off results do not isolate a base commit; the new cold-turn cost should stay clearly separated from the withdrawn decode loss. Integration and changelog placement remain ours.

  • Synthena

@jschmied

Copy link
Copy Markdown
Contributor Author

@ashhart before I add an activation path here, one question on which rule applies, the same one I asked on #1508.

When #1145 landed (your landing note), imported low-bit weights deliberately stayed on bf16 rows: no input_scale is read, and --precision checkpoint was left out. Main still follows that for NVFP4 and FP8 projections (core/modelopt_part.zig: input_scale "left to the family (not read, not marked used)"). #1634 runs LiquidAI's FP8 release the same way: e4m3 weights under their scales, bf16 activations, and the dynamic FP8 input step that the config names is not applied.

So which do you want for this export?

I'll follow whichever you choose. On the cache-on/off cold-turn cost: agreed, I'll keep it separate from the withdrawn decode loss and won't attribute it to a base commit.

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied. To answer your question: the contract is weight-only. TensorFold serves the stored FP8 weights exactly as loaded and runs them with BF16 inputs, as main already does in its other weight-only modes; our code adds no activation quantization of its own. So the export's dynamic FP8 input step stays out, and the serial reference is the same stored weights with BF16 inputs.

On that contract, your completed serving checks and the withdrawn eight-stream decode loss stay credited, and no activation-path change is needed. Please say weight-only in the description and docs (the input scales are read and not applied), and keep the separate cache cold-turn result and its attribution clear. Integration with current main is on our side.

  • Synthena

@jschmied

Copy link
Copy Markdown
Contributor Author

@ashhart Thanks. The head is now f3d0fd7051: your 6d91aa5cb plus one docs commit. No code changed, so the receipts from 6d91aa5cb carry over.

  • docs/recipes/lfm3-cuda.md and the description say the contract is weight-only. The stored FP8 and NVFP4 weights are served as loaded with bf16 inputs. The release's input scales are read and not applied, and the dynamic FP8 input step is not applied; activations stay bf16.
  • The description keeps two results apart.
    • The withdrawn 8-stream decode loss: +0.10 %, within noise.
    • The prompt cache's cold-turn cost: FP8's first token is 2.8 % slower with the cache on, and LFM2.5 on main points the same way. It is attributed to the cache's keep path that main already has, not to a base commit or to this PR's code.

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied. The explicit weight-only agreement and updated description and recipe close the remaining contract question. The code is unchanged, so the completed serving comparisons remain credited. No activation-path change is needed.

The withdrawn decode loss and separate cache cold-turn cost are now clearly distinguished. This is ready to land after the NVFP4 parent, with the remaining main integration handled on our side.

  • Synthena

ashhart pushed a commit to jschmied/TensorFold that referenced this pull request Nov 25, 2026
…1634

ashhart#1634 changes nothing under zig/kernels, so main against its code head 042028b
reaches ashhart#1508's functions only: prefill_attention 70 of 70 identical (+5),
contract_controls 450 of 450 (+15), nvcc 13.0 and 13.2, sm_80/86/89/120/121.
ashhart pushed a commit to jschmied/TensorFold that referenced this pull request Nov 25, 2026
…1634

ashhart#1634 changes nothing under zig/kernels, so main against its code head 042028b
reaches ashhart#1508's functions only: prefill_attention 70 of 70 identical (+5),
contract_controls 450 of 450 (+15), nvcc 13.0 and 13.2, sm_80/86/89/120/121.
@AIFlowML

Copy link
Copy Markdown
Contributor

Now that #1508 is on main, I trial-merged 316bf9e9ff cleanly into 47a605aa12 on M5 Max. All 101 focused LFM3, Liquid, XPU refusal and serving-pin checks passed. The native CUDA server also compiled for ARM64 Linux in 10/10 build steps.

zig build test-lfm3-host test-lfm3-cuda-host test-liquid-cuda-host \
  test-lfm3-xpu-refusal-host test-gradient-serving -Dfixed-cpu -j2 --summary all
zig build check-native-cuda-host -Dtarget=aarch64-linux-gnu -Dfixed-cpu -j2 --summary all

I also tested the landing order with #1502 after #1634. It leaves the same four conflicts as #1502 on its own. Keep the existing NVFP4 and FP8 weight fixtures alongside the vision fixtures, preserve the native Metal refusal checks, and retain the shared Safetensors header parser in the CUDA test shim. That combined tree passed 145 host tests with five skipped and the ARM64 Linux CUDA compile.

This verifies the integration path and the weight-only host contract. The prior author receipts cover CUDA serving. I did not rerun device serving or performance on the combined tree.

Igor Lessio - AIFLOW LABS

jschmied and others added 9 commits November 25, 2026 10:58
LiquidAI/LFM3-1.7B-FP8 (compressed-tensors, FP8_BLOCK): e4m3 weights with a bf16
scale per 128 x 128 block on the FFN and q/k/v/o, dynamic FP8 inputs in groups of
128; the convs, the attention gate, the embedding and the head stay bf16. The
recipe, the ignore list and the 402 tensors are checked as published. Metal
refuses it by name (Lfm3Fp8BlockNotOnMetal).
…as stored

- FP8: the FFN and q/k/v/o on the block-FP8 lane, activations bf16 (the
  export's dynamic input quantization is not applied). The bf16 attention gate
  is a projection of its own, written into the merge's sums buffer after the
  attention.
- MLX 4-bit g64: every projection and the tied head as affine-4 tiles, prompt
  chunks on the affine prompt GEMM, decode rows on the verify tiles over their
  64-value sums; the embedding rows read the same codes. Wrapped names
  (language_model.model.*) come from the admission. 6- and 8-bit MLX and VL
  are refused by name.
The receipts are main's tools/lfm3/REF64.md (ref64.py dequantizes block FP8
exactly, from ashhart#1696). FP8 agrees on 824 of 829 prompt rows and 128 of 128 reply
rows, MLX 4-bit on 825 and 128; every miss is listed with its float64 margin
(0.004 to 0.085). Concurrent == solo at 4 and 8 streams.
…gh the open

servedOn's .xpu case (from ashhart#1508) now names fp8_block too:
Lfm3Fp8BlockNotOnXpu, beside Lfm3ModeloptNvfp4NotOnXpu. The XPU open asks
before the Level Zero driver, as it does for NVFP4, and the engine's init asks
again before its stream. The test writes only the export's config.json and opens
it through xpu.zig; with the check removed it fails at the driver instead
(LoaderUnavailable).
…1634

ashhart#1634 changes nothing under zig/kernels, so main against its code head 042028b
reaches ashhart#1508's functions only: prefill_attention 70 of 70 identical (+5),
contract_controls 450 of 450 (+15), nvcc 13.0 and 13.2, sm_80/86/89/120/121.
@ashhart
ashhart merged commit bef3a77 into ashhart:main Nov 25, 2026
1 check failed
ashhart pushed a commit that referenced this pull request Nov 25, 2026
#1634 changes nothing under zig/kernels, so main against its code head 042028b
reaches #1508's functions only: prefill_attention 70 of 70 identical (+5),
contract_controls 450 of 450 (+15), nvcc 13.0 and 13.2, sm_80/86/89/120/121.
@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thank you @jschmied. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

ashhart added a commit to Bizuayeu/TensorFold that referenced this pull request Nov 25, 2026
ashhart added a commit that referenced this pull request Nov 25, 2026
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.

3 participants