Repository navigation
Conversation
The forward and backward kernels placed rows on CUDA grid dimension 1, which holds at most 65,535 blocks, so more than 65,535 rows failed to launch. Both kernels now use a 1D grid. Widths up to 256 columns process several rows per 4,096-element tile as an autotune dimension, instead of one program per row, which starves the GPU on narrow rows. Wider rows keep one row per program, and the backward kernel runs up to four persistent programs per SM on the row-tiled path. Padded rows are now masked out after the arithmetic in the backward kernel: with infinite alpha, tanh(inf * 0) is NaN and masked loads alone let it poison the parameter gradients. dalpha and dbeta now take their parameters' dtypes, like dgamma already did, instead of rounding float32 parameter gradients through x.dtype. The output keeps the x.dtype contract.
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Modification to the shape handling in the fused DyT kernels that gives
a major performance gain in my application: a small network with DyT,
as tested on an H100.
65,535 blocks, so more than 65,535 rows failed to launch. Both kernels
now use a 1D grid.
columns now process several rows per 4,096-element tile, exposed as a
BLOCK_Mautotune dimension; wider rows keep one row per program, andthe backward kernel runs up to four persistent programs per SM on the
row-tiled path.
kernel: with infinite
alpha,tanh(inf * 0)is NaN and masked loadsalone let it poison the parameter gradients.
dalphaanddbetanow take their parameters' dtypes, likedgammaalready did, instead of rounding float32 parameter gradients through
x.dtype. The output keeps thex.dtypecontract.Because the autotuned
BLOCK_Nis not known before launch, the backwardbuffers are sized for the worst-case config and zeroed, so unused
programs/column blocks contribute nothing to the reductions.
Testing Done
Hardware: H100 (80GB HBM3).
make checkstyle: passes.make test: passes (5294 passed, 1146 skipped, 21 xfailed, including all 45test/transformers/test_dyt.pycases).make test-convergence:169 passed, 10 skipped, 3 xfailed, 3 xpassed(1 unrelated failure inmini_qwen3_5_moebf16 due toLigerExpertsMoE non-determinism on H100, verified identical onmain).