Write fp8 kernel

From tensormux/kernel-skills · View interactive version

Write fp8 kernel is an AI agent skill from the GitHub repository tensormux/kernel-skills. Guide the agent through designing and implementing FP8 compute kernels for inference and training on NVIDIA Hopper (sm_90) and Ada Lovelace (sm_89) hardware, covering FP8 format selection, scaling str

How to use this skill

Skill file

Skill: Write an FP8 Kernel

Purpose

Guide the agent through designing and implementing FP8 compute kernels for inference and training on NVIDIA Hopper (sm_90) and Ada Lovelace (sm_89) hardware, covering FP8 format selection, scaling strategy, tensor core usage via WGMMA or cuBLAS, and dequantization epilogue design.

Use this when

Do not use this when

Inputs the agent should gather first

Required reasoning process

  1. Select the FP8 format for each tensor role. The industry-standard mapping is:
  1. Design the scaling strategy. FP8 has a max representable magnitude of ~448 (E4M3). Any value exceeding this overflows to infinity or saturates. Scaling maps the input range to fit within FP8:
  1. Choose between cuBLAS FP8, CUTLASS, and custom WGMMA. In order of implementation effort:
  1. Design the quantization pass. Quantization from fp32/fp16/bf16 to FP8 must:
  1. Design the GEMM and epilogue. For a standard FP8 GEMM producing fp16 output:
  1. Handle the amax feedback loop for training. In training with delayed scaling:
  1. Validate numerics. After implementing:

Kernel design rules

Correctness requirements

Performance requirements

Output format

The final response must include:

  1. FP8 format choice: E4M3 or E5M2 for each tensor, with justification.
  2. Scaling strategy: per-tensor, per-channel, or delayed — with the amax computation and scale update formula written out explicitly.
  3. Implementation path: cuBLAS, CUTLASS, or custom WGMMA, with justification.
  4. Quantization code: explicit conversion with satfinite and scale application.
  5. GEMM and epilogue code: accumulation in fp32, scale multiply, output cast.
  6. Accuracy validation: comparison against fp32 reference with expected error bound.
  7. Performance estimate: expected TFLOPS/s relative to hardware peak and fp16 baseline.

Common failure modes

Review checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.