Documentation
¶
Overview ¶
Package prefill lowers block-FP8 prefill projections to Tile IR.
This package is outside the compatibility promise of github.com/tmc/lib/nvidia. Its API may change or be removed in patch releases.
Package prefill lowers block-FP8 prefill projections to Tile IR.
Index ¶
- type BlockFP8
- func (p BlockFP8) Compile(ctx context.Context, opts ...tileir.Option) (*Program, error)
- func (p BlockFP8) CompileDynamic(ctx context.Context, opts ...tileir.Option) (*Program, error)
- func (p BlockFP8) CompileOverlap(ctx context.Context, opts ...tileir.Option) (*Program, error)
- func (p BlockFP8) CompilePanel(ctx context.Context, opts ...tileir.Option) (*Program, error)
- func (p BlockFP8) CompileWideOverlap(ctx context.Context, opts ...tileir.Option) (*Program, error)
- func (p BlockFP8) DynamicModule() (*tileir.Module, error)
- func (p BlockFP8) Grid() ([3]int, error)
- func (p BlockFP8) Module() (*tileir.Module, error)
- func (p BlockFP8) PanelGrid() ([3]int, error)
- func (p BlockFP8) PanelModule() (*tileir.Module, error)
- type Buffers
- type Kernel
- type Program
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockFP8 ¶
type BlockFP8 struct {
Tokens, Outputs, Depth int
}
BlockFP8 describes a static token-major prefill projection for sm_121a. Grid returns the required launch geometry. There are five device pointers, in this order:
- x: E4M3FN activations [Tokens, Depth]
- w: E4M3FN weights [Outputs, Depth]
- xs: float32 activation scales [Depth/128, Tokens]
- ws: float32 weight scales [ceil(Outputs/128), Depth/128]
- y: float32 results [Tokens, Outputs]
All arrays are dense row-major and their storage must be disjoint. Tokens must be at least 64. Depth must be a positive multiple of 128. Partial token and output tiles are padded on load and clipped on store. Input producers and output consumers must be ordered on the launch stream or through explicit stream synchronization.
func (BlockFP8) Compile ¶
Compile assembles the projection for compute capability 12.1. The options configure tileiras, for example tileir.WithPath. Compile never opens a GPU.
func (BlockFP8) CompileDynamic ¶
CompileDynamic assembles DynamicModule. The resulting kernel can launch any admitted token count from 64 up to Tokens with the same cubin.
func (BlockFP8) CompileOverlap ¶
CompileOverlap assembles the K128 panel with a loop-carried successor load. It uses the same launch and buffer requirements as CompilePanel.
func (BlockFP8) CompilePanel ¶
CompilePanel assembles PanelModule and checks the packed, aligned launch contract. Its runtime-token ABI is the same as CompileDynamic.
func (BlockFP8) CompileWideOverlap ¶
CompileWideOverlap assembles the staged K128 panel with 64 output columns per CTA. Buffers follow the CompileOverlap contract.
func (BlockFP8) DynamicModule ¶
DynamicModule lowers a projection with the same buffer layouts as Module and a final int32 token count argument. Tokens is its admitted upper bound. Activation scale rows are packed using the actual token count as the stride.
func (BlockFP8) Module ¶
Module lowers the projection. It uses ordinary E4M3 mmaf and keeps the checkpoint's float32 scales. For each K128 group it accumulates four K32 products, multiplies the scales, and performs one float32 FMA into the output accumulator. Hardware mmaf_scaled has different scale encodings.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/x/tile/prefill"
)
func main() {
p := prefill.BlockFP8{Tokens: 65, Outputs: 160, Depth: 256}
grid, err := p.Grid()
if err != nil {
fmt.Println(err)
return
}
mod, err := p.Module()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(mod.Functions[0].Name, grid)
}
Output: block_fp8_prefill [2 10 1]
func (BlockFP8) PanelGrid ¶
PanelGrid returns the launch geometry of PanelModule at the actual shape.
func (BlockFP8) PanelModule ¶
PanelModule lowers a runtime-token projection with 32 output columns per tile and whole K128 panel loads. The activation and weight base addresses must be aligned to 16 bytes. The four K32 products and FP32 scale application are the same as DynamicModule.
type Buffers ¶
type Buffers struct {
Activations, Weights cuda.Slice[uint8]
ActivationScales, WeightScales cuda.Slice[float32]
Output cuda.Slice[float32]
}
Buffers supplies the device slices in a BlockFP8 projection. Each slice must have room for its documented shape. Extra elements are ignored.
type Kernel ¶
type Kernel struct {
// contains filtered or unexported fields
}
Kernel is a loaded projection. Its zero value is closed.
func (*Kernel) Close ¶
Close unloads the device program. The caller must finish all launches, including graph replays, before closing it.