Skip to content

Model L: D3D12 ports of the two projections, byte for byte against their HIP kernels - #123

Merged
phantoslayer21 merged 4 commits into
mainfrom
model-l/l-project-d3d12-pr
Nov 14, 2026
Merged

phantoslayer21 merged 4 commits into
mainfrom
model-l/l-project-d3d12-pr

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Model L (#89): the D3D12 ports of Model L's two projections, byte for byte against their HIP kernels:
l_project_gather (the encoder's output projection) and l_dec_project (the decoder's input projection) of l_ops.co
(clean/l/kernels/l_ops.hip).

Stacked on #122 (input linears; it adds this group's cases to #122's harness). Depends on #115 for the HIP
kernels it is checked against (checked at #115's head 0ec574e). CI needs neither: nothing here runs without a GPU.

  • clean/dx12/kernels/l_ops_project.hlsl (new): both kernels from one source (PJ_DEC).
    • per group of 32 inputs: two FP8 WMMAs, then RN16 (a running FP16 sum from the bias);
    • gather: tokens read their 2 x 2 pixels as the four groups, then clamp to +-6.28125, FP8 out;
    • dec: 128 outputs per token scattered to its 2 x 2 pixels, FP8 out;
    • lanes, blobs, K order and maps as HIP (clean/l/FORMATS.md); each tile's loads before its first matrix
      instruction;
    • no branch, as in Model L: D3D12 ports of the input linears, byte for byte against their HIP kernels #122: a lane past the last token computes the last token (its inputs are clamped there as in
      HIP) and stores that token's bytes to that token's place.
  • clean/l/runner/l_d3d12_ops_check.py: the projections' cases. Six token grids: 8 x 12, 18 x 34, 4 x 4, 34 x 50,
    and 3 x 5 and 2 x 9, which are partly filled waves.

Refs #89

Tested

Local, Windows, Radeon RX 9000 series card, with #115's HIP kernels:

  • GPU (one GPU slot), l_d3d12_ops_check.py --run --seeds 6 --kernels l_project_gather,l_dec_project:
    • l_project_gather: 36 of 36 cases identical (6 seeds x 6 grids; 943,488 output bytes);
    • l_dec_project: 36 of 36 identical (1,886,976 bytes);
    • the Model M control swin_block_c96_nc: 36 of 36 identical (3,167,424 bytes);
    • 0 differing bytes in every case; the negative control (half grid) caught (22,784 bytes);
    • compared as raw downloaded bytes, each output filled beforehand with its back end's own non-zero sentinel
      (HIP 0xA5, D3D12 0x5A).
  • build_dx12.py --isa: l_project_gather 4 buffer_store, 32 v_wmma; l_dec_project 8 buffer_store, 32
    v_wmma; 0 branches (the stores the kernels must issue).
  • python tools/ci/check_line_endings.py: 0 problems. Public gates (secrets, personal data, licence, chunks) pass.

Not tested

  • In a whole Model L frame (waits for the L runtime frame).
  • NaN inputs to the gather's clamp (none occur in the synthetic data; HIP and D3D12 both use the number-preferring
    max / min).

…eir HIP kernels

l_ops_project.hlsl ports l_project_gather and l_dec_project of l_ops.co
(clean/l/kernels/l_ops.hip, #115): two FP8 WMMAs then RN16 per group of 32 inputs,
the gather's clamp, FP8 out; no branch (a lane past the last token stores its
clamped token's bytes to that token's place). l_d3d12_ops_check.py gains their
cases (6 token grids, two of them partly filled waves).

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 01:42
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Base automatically changed from model-l/l-linear-d3d12-pr to main November 14, 2026 02:03
@phantoslayer21
phantoslayer21 merged commit 70c9937 into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/l-project-d3d12-pr branch November 14, 2026 02:10
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.

1 participant