This document is relevant for: Trn2, Trn3
MLP Forward MXFP8 Kernel API Reference#
SwiGLU MLP forward with MXFP8-quantized matmuls, one contiguous token block per core.
Background#
mlp_forward_mxfp8_nki computes a single SwiGLU MLP, (SiLU(hidden @ gate) * (hidden @ up)) @ down, with MXFP8-quantized matmuls and no routing or expert affinities. It runs two blocks of T/2 tokens per core and returns the activation checkpoint consumed by mlp_backward_mxfp8_nki.
API Reference#
Source code for this kernel API can be found at: mlp_fwd_mxfp8_kernel.py
mlp_forward_mxfp8_nki#
- nkilib.experimental.mlp_mxfp8.mlp_fwd_mxfp8.mlp_forward_mxfp8_nki(hidden_states: nl.NkiTensor, gate_up_proj_weight: nl.NkiTensor, down_proj_weight: nl.NkiTensor, config: MXFP8MOEFwdConfig = None, gate_up_weight_scales: nl.NkiTensor = None, down_weight_scales: nl.NkiTensor = None) tuple#
Compute a SwiGLU MLP with one contiguous token block per core.
- Parameters:
hidden_states (
nl.NkiTensor) – Input hidden states[T, H]on HBM; T a positive multiple of 256.gate_up_proj_weight (
nl.NkiTensor) – Fused gate/up projection weights, BF16[H, 2, I](packed MXFP8[2*H/4, I]with scales).down_proj_weight (
nl.NkiTensor) – Down projection weights, BF16[I, H](packed MXFP8[I/4, H]with scales).config (
MXFP8MOEFwdConfig) – Kernel configuration (tiling, dtypes, and per-projectionquant_schemeviagate_up_config/down_config);Noneuses defaults.gate_up_weight_scales (
nl.NkiTensor) – MX scales for the gate/up weights; required for packed MXFP8 weights.down_weight_scales (
nl.NkiTensor) – MX scales for the down weights; required for packed MXFP8 weights.
This document is relevant for: Trn2, Trn3