Skip to content

feat(runtime): NVFP4 module split, CUBIN opt-in, col-copy guard, f16out kernels#71

Merged
TheTom merged 7 commits into
feature/cuda-hip-vulkanfrom
tom/iron-runtime-recovery
Jul 23, 2026
Merged

feat(runtime): NVFP4 module split, CUBIN opt-in, col-copy guard, f16out kernels#71
TheTom merged 7 commits into
feature/cuda-hip-vulkanfrom
tom/iron-runtime-recovery

Conversation

@TheTom

@TheTom TheTom commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What

Runtime-side companion to the Laguna prefill PR in the FFAI tree (thewafflehaus/butter#70).

  • CUDA runtime re-landed as the committed module split (mod.rs + nvfp4_moe.rs): the working tree previously ran an uncommitted monolith that was lost; this commits the recovered, coherent surface. The batched-Marlin entry points that existed only in the monolith are stubbed in marlin_pending.rs with clear errors and inline reconstruction notes (NemotronH-only consumers; the Laguna path dispatches raw kernels and never calls them).
  • NVRTC image selection: PTX + driver JIT stays default (measured slightly better for latency-bound decode kernels on GB10, equal on prefill); MT_NVRTC_NATIVE=1 opts into native-arch SASS via nvrtcGetCUBIN.
  • strided_col_copy: bounds guard + ceiling-division grid; non-64-multiple shapes previously dropped tail elements silently (latent, no live caller affected). Regression test with a deliberately misaligned shape included.
  • f16-out RMSNorm + gated-group-norm kernel variants land in metaltile-std (previously existed only on the GB10 working tree; consumers already reference them).

Validation

  • cargo check clean across the workspace on both dev machines (this change is what unified the two trees; the long-standing phantom skew errors are gone)
  • Laguna decode + prefill continuation gates re-run green on GB10 after these changes
  • Non-aligned col-copy unit test, plus the existing kernel suites

Lesson encoded

The monolith loss came from a blind cross-machine sync; the recovery plan and the both-trees-identical end state are documented in the working notes. Commit early on shared branches.

@github-actions github-actions Bot added the feature New feature label Jul 23, 2026
@TheTom
TheTom marked this pull request as ready for review July 23, 2026 20:49
TheTom added 7 commits July 23, 2026 15:50
…rename

Add ffai_moe_gather_q4, the no-activation sibling of the ReLU2 gather, so
gated (SwiGLU) MoE paths can gather the gate and up expert stacks with
in-kernel expert indexing. Add ffai_cast_f32_bf16 / ffai_cast_bf16_f32
elementwise casts for bf16 residual streams.

Rename the misleading d_f32 parameter to d_f16 on the five kernels whose
per-block scales are f16 (gemv_q4 coalesced/relu2/accum, moe_gather_q4
relu2/down) and document the scale dtype contract on each kernel in the
family; uploading f32 scale bytes into these silently reinterprets them
as garbage f16 and inflates every output.
…ifiers

Mechanical cargo fmt over the crate (the CUDA feature line had never run
through repo CI, so format debt across many files surfaces on the first
PR from it) plus a typos config accepting the intentional short
accumulator/nibble names (ba/bb/na/nb) in the hand-rolled GEMV kernels.
No behavior change; cargo check clean.
Repo-wide cargo fmt, clippy fixes across the codegen crates (collapsed
ifs, dropped useless format! calls, allow on the 9-arg spirv emit_op),
typos config for the intentional optin identifiers, and the missing
metaltile-core/metaltile-codegen dev-dependencies that the in-module
smoke tests in metaltile-std reference (this also un-breaks the full
test-target build, which previously failed with unresolved-crate errors
before any test ran). No behavior change.
The CI clippy gate runs with --all-features, which pulls the cuda and
vulkan device modules into the lint set: allow attrs on the FFI-handle
wrappers (not_unsafe_ptr_arg_deref on graph_launch/_batch, dead_code on
the CUDA FFI constant surface, too_many_arguments on the grouped-CUTLASS
entry), a dropped never-read init, and doc-comment list formatting.
Typos config gains dout/ERRO (d-out signal name, log-level tag). No
behavior change.
The typos gate reads .github/configs/typos-cli.toml explicitly; add the
short GEMV accumulator/nibble identifiers (ba/bb/na/nb) and the
dout/erro/optin word stems there and drop the stray root config the
checker never consults.
…ut kernels

Re-lands the CUDA runtime surface as the committed split (mod.rs plus the
nvfp4_moe module) after the working-tree monolith was lost; the
batched-Marlin entry points that existed only in that monolith are
stubbed in marlin_pending.rs with clear errors (NemotronH-only path,
reconstruction notes inline).

NVRTC: PTX with driver JIT stays the default (A/B on GB10 measured it
slightly ahead for latency-bound decode kernels); MT_NVRTC_NATIVE=1 opts
into native-arch SASS via nvrtcGetCUBIN.

strided_col_copy gains a bounds guard and ceiling-division grid so
non-64-multiple shapes stop silently dropping tail elements (latent, no
live caller affected; regression test included). Also lands the f16-out
RMSNorm and gated-group-norm kernel variants that previously existed only
on the GB10 working tree.
…ormat names

The recovered module split predated the workspace fmt sweep; bring it in
line. The typos gate flagged the ue4m3/ue8m0 unsigned microscale format
names (bare and embedded in FFI constant names); scope an ignore regex to
that token shape rather than allowlisting the bare fragment.
@TheTom
TheTom force-pushed the tom/iron-runtime-recovery branch from f72d51b to 150a4ac Compare July 23, 2026 20:51
@TheTom
TheTom merged commit 2dfc36c into feature/cuda-hip-vulkan Jul 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant