Repository navigation
[Common] Swizzle MXFP8 scaling factors with one CTA per scale tile - #3658
Conversation
The MXFP8 scale swizzle is latency bound. The narrow-K and narrow-M kernels put up to 32 128x4 scale tiles in one 1024-thread CTA, so the scaling factors of a 4096-row activation are swizzled by a single CTA. Give every 128-row M-tile (row-wise) or 128-column x 32-row block (column-wise) its own CTA, which moves a contiguous chunk with coalesced 16-byte loads and stores through shared memory. Multi-tensor launches group tiles per CTA only when the grid would otherwise be very large. The existing kernels remain for NVFP4, unaligned buffers, and row-wise scales too wide for 48 KB of shared memory. Signed-off-by: Siddhartha Raman S <sraman@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The column-wise multi-tensor case that selects 128-row chunks had only four scale rows. Add one with 132 scale rows per tensor: a full 128-row chunk and a clipped last chunk. Signed-off-by: Siddhartha Raman S <sraman@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflicts in swizzle.cu with NVIDIA#3600, which replaced the file-local get_max_dynamic_smem() with cuda::max_shared_memory_per_block_optin(): keep the tile-kernel dispatch, and take the new shared-memory check in the narrow-K and narrow-M branches it falls back to. Signed-off-by: Siddhartha Raman S <sraman@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/te-ci L1 pytorch |
Select the per-tile MXFP8 scale-swizzle kernels with NVTE_MXFP8_PER_TILE_SWIZZLE=1; by default, the existing kernels run as before. Give the per-tile code descriptive names (for example TileSwizzleDesc -> PerTileSwizzleTensor, tpc -> tiles_per_block, k4_magic -> words_per_row_magic), document the variable, and run the single- and multi-tensor swizzle tests with it unset and set. Signed-off-by: Siddhartha Raman S <sraman@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
│ Scaling factors of │ Row-wise: existing → per-tile │ Column-wise: existing → per-tile │ |
|
/te-ci L1 pytorch |
|
/te-ci L1 pytorch |
1 similar comment
|
/te-ci L1 pytorch |
|
LGTM. Perf is definitely better compared to the existing kernels for DSV3 sizes of weights/activations. However, currently the kernels are gated by env variable, since we want to make sure the perf is consistent across the board for all sizes. The variable will be removed once that is verified. |
The MXFP8 scale swizzle is latency bound. The narrow-K and narrow-M kernels put up to 32 128x4 scale tiles in one 1024-thread CTA, so the scaling factors of a 4096-row activation are swizzled by a single CTA.
Give every 128-row M-tile (row-wise) or 128-column x 32-row block (column-wise) its own CTA, which moves a contiguous chunk with coalesced 16-byte loads and stores through shared memory. Multi-tensor launches group tiles per CTA only when the grid would otherwise be very large. The existing kernels remain for NVFP4, unaligned buffers, and row-wise scales too wide for 48 KB of shared memory.
Description
Please include a brief summary of the changes, relevant motivation and context.
Fixes # (issue)
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: