Skip to content

[apps] Add LLM kernels (RMSNorm, LayerNorm, SwiGLU, GeGLU) and fuse cos FMAs - #553

Merged
hopang-0221 merged 2 commits into
mainfrom
hp/llm-kernels
Nov 26, 2026
Merged

hopang-0221 merged 2 commits into
mainfrom
hp/llm-kernels

Conversation

@hopang-0221

@hopang-0221 hopang-0221 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds four LLM kernels: the normalizations RMSNorm and LayerNorm, and the gated activations SwiGLU and GeGLU (FP32), and fuses the multiply-add pairs of the cos kernel into FMA instructions. It also fixes a race in the CI artifact clean-up.

Each new kernel sweeps its size (hidden size d for the normalizations, vector length for the gated activations), reports cycles and FLOP/cycle, and checks the full-size result against golden data. SwiGLU and GeGLU use the existing intrinsic __exp_2xf32; GeGLU uses the tanh approximation of GELU. All five apps are added to the CI simulation matrix.

The clean-up jobs deleted artifacts that later jobs still needed: clean-up-compile-runs removed benchmark-<config> once simulate finished, so roofline could fail when a benchmark job finished later. Re-running roofline alone could then never pass. clean-up likewise removed tc-llvm, which benchmark and check-clang-format download. Both clean-up jobs now also wait for those jobs.

Changelog

Fixed

  • CI: clean-up also waits for benchmark and check-clang-format, and clean-up-compile-runs for benchmark and roofline, so no job loses an artifact it still needs

Added

  • apps/rmsnorm, apps/layernorm, apps/swiglu, apps/geglu, with their default arguments in apps/common/default_args.mk
  • cos, rmsnorm, layernorm, swiglu and geglu in the CI simulate matrix

Changed

  • apps/cos/kernel/cos.h: 9 fused operations per element (vfmacc ×3, vfmadd ×5, vfnmsac ×1) in both the FP64 and FP32 paths
  • apps/.gitignore: ignore the generated `apps/*/data.S

Checklist

  • Automated tests pass
  • Changelog updated
  • Code style guideline is observed

@Navaneeth-KunhiPurayil Navaneeth-KunhiPurayil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hopang-0221
hopang-0221 merged commit 11ce9fa into main Nov 26, 2026
245 checks passed
@hopang-0221
hopang-0221 deleted the hp/llm-kernels branch November 26, 2026 17:28
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.

2 participants