Skip to content

feat(ops): mt_cast_f32_bf16 + mt_add_rms_norm_f16norm (carved from #13) - #31

Merged
TheTom merged 1 commit into
devfrom
pr13/p7-ops-cast-addrmsnorm-f16
Jun 22, 2026
Merged

feat(ops): mt_cast_f32_bf16 + mt_add_rms_norm_f16norm (carved from #13)#31
TheTom merged 1 commit into
devfrom
pr13/p7-ops-cast-addrmsnorm-f16

Conversation

@TheTom

@TheTom TheTom commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the kernels/ops reorg (#18), carving the two genuinely-novel ops kernels out of the NVFP4/CUDA kitchen-sink branch (#13). Conformed to the reorg: mt_ names, placed in kernels/ops/unary.rs next to their siblings.

Kernels

  • mt_cast_f32_bf16 , f32 to bf16 narrowing cast, sibling of mt_cast_f32_f16. For models whose residual stream / cache dtype is bf16 (wider exponent range than f16). The reverse bf16 to f32 widening is already covered by the generic mt_cast_to_f32, so only the narrowing direction is added.
  • mt_add_rms_norm_f16norm , fused add + RMSNorm with an f16 normed output, residual stream stays f32 (no narrowing drift over long decodes). Folds the standalone cast_f32_f16(normed) into the producer epilogue, saving one cast dispatch per residual-add+norm pair on bf16/f16-activation paths. Bit-identical to add_rms_norm(f32) -> cast_f32_f16.

Context

Audit of #13 found that most of its std-kernel surface is pre-reorg parallel snapshots already superseded by the reorg (format-axis fold, renamed dsv4/sgload kernels, etc). These two ops kernels are the only std additions in #13 that are not present anywhere in the reorg tree, so they get a home here. The CUDA/NVFP4 backend itself is carved separately.

cargo check -p metaltile-std green on macOS (Metal DSL).

@TheTom
TheTom force-pushed the ek/kernel-reorg-steel branch from ffad7fc to 6a2035a Compare June 22, 2026 21:36
Two ops kernels carved from the NVFP4/CUDA work, conformed to the
kernels/ops/ reorg with mt_ names:

  mt_cast_f32_bf16      f32 to bf16 narrowing cast, sibling of
                        mt_cast_f32_f16. The reverse bf16 to f32 widening
                        is already covered by the generic mt_cast_to_f32.
  mt_add_rms_norm_f16norm  fused add + RMSNorm with an f16 normed output,
                        residual stream stays f32. Folds the standalone
                        cast_f32_f16(normed) into the producer epilogue.
                        Bit-identical to add_rms_norm(f32) -> cast_f32_f16.

Both land in kernels/ops/unary.rs next to their f32/f16 siblings.
cargo check -p metaltile-std green.
@TheTom
TheTom force-pushed the pr13/p7-ops-cast-addrmsnorm-f16 branch from 73ed415 to 2b0cd4f Compare June 22, 2026 22:05
@TheTom
TheTom changed the base branch from ek/kernel-reorg-steel to dev June 22, 2026 22:05
@TheTom TheTom changed the title std/ops: mt_cast_f32_bf16 + mt_add_rms_norm_f16norm (follow-up to #18, carved from #13) feat(ops): mt_cast_f32_bf16 + mt_add_rms_norm_f16norm (carved from #13) Jun 22, 2026
@github-actions github-actions Bot added the feature New feature label Jun 22, 2026
@TheTom
TheTom merged commit 076849c into dev Jun 22, 2026
14 of 17 checks passed
@ekryski
ekryski deleted the pr13/p7-ops-cast-addrmsnorm-f16 branch July 13, 2026 22:19
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