Track 1 (1.167 min on 8xH100, -5.15% same-node): Reduced-width QK and packed FP8 attention - #344
Track 1 (1.167 min on 8xH100, -5.15% same-node): Reduced-width QK and packed FP8 attention#344Glitchfix wants to merge 5 commits into
Conversation
cad54ae to
afe5885
Compare
|
Interesting how the difference was way bigger (~3.68 s) on 8xH200 |
actually the gain shown was against in the H100 run was comparison with the leaderboard run the bandwidth happens to be the bottleneck for packing and transpose operation benefit, I think the gain would be much better in newer GPUs |
|
This PR is the next one up to get merged into main. However there are some conflicts with the DC attention layer. |
|
@ClassicLarry let me resolve the conflicts |
cda0fe0 to
b6aff47
Compare
Project Q/K at 96 dimensions while preserving 128-dimensional values. Fuse QK normalization, RoPE, layout conversion, and padding in Triton. Reuse dual FP8 layouts during backward to avoid extra transposes. Signed-off-by: Shivanjan Chakravorty <schakravorty846@gmail.com>
Signed-off-by: Shivanjan Chakravorty <schakravorty846@gmail.com>
Use 45 final-lr extension iterations to establish the required loss significance and replace the provisional H200 evidence with four fresh H100 runs. Signed-off-by: Shivanjan Chakravorty <schakravorty846@gmail.com>
Run all four MLP backward GEMMs through FP8 using cached row-major and transposed weight layouts. Refresh exact-current weight scales with Triton reductions and emit both layouts from a single weight read, while keeping activation scales lagged to avoid a mid-step synchronization. Eliminate the saved MLP pre-activation by reconstructing relu(pre) from the stored squared activation. Quantize logical QK/V packs without materializing concatenations or full-size abs temporaries, and reuse register-resident lane swaps in QK normalization and RoPE. Let the DC correction consume reduced-width Q/K views directly while retaining 128-wide V, avoiding padding copies and redundant score work. Signed-off-by: Shivanjan Chakravorty <schakravorty846@gmail.com>
Seeds 2, 4, 42 and 1337 at 45 extension iterations give 3.274725 mean loss (p=0.001585) and 70.094 seconds (1.1682 minutes), against a 73.897 second (1.2316 minute) same-node f411b3d baseline. Make 45 the checked-in default so an unmodified run.sh reproduces the submitted 1315-step configuration. Signed-off-by: Shivanjan Chakravorty <schakravorty846@gmail.com>
b6aff47 to
c4c209d
Compare
|
@ClassicLarry I have resolved the conflicts I also found some more optimizations I found that dropping the saved pre activation since relu(pre) is recoverable from the stored squared activation, and the both FP8 weight layouts that I have been improved they now come out of one weight read instead of two this was something I had missed earlier The retest is substantially faster than the current master's baseline of 1.23min I have updated the description to reflect the same |
|
@kroggen I ran this on 8xH200 again
while the master baseline ran in 72.028s I am really curious to optimize these on bigger GPUs, need more GPU credits 😄 |
|
Yeah, I was expecting the opposite: smaller difference on H200 because the master baseline would also be faster. They are the same architecture with just difference in HBM size and speed (4.8 TB/s vs 3.35 TB/s) Maybe the baseline is more memory-bound on H100 and more compute-bound on H200 |
Summary
This PR reduces the Q/K head width from 128 to 96 while keeping V and the residual stream at 128 dimensions. It packs the Q, K, and V projections into a shared FP8 projection and adds Triton kernels for the associated layout, normalization, RoPE, and backward work.
The routing vectors used by attention do not necessarily need the same width as the value vectors carrying content. Normalized Q/K vectors can use a smaller geometry, reducing projection work without narrowing V or the model residual.
The branch has been rebased onto current main. The DC attention layer conflicts are resolved and the candidate has been re-measured against a same-node baseline, which the earlier revision of this PR could not provide. Resolving the conflicts also exposed some redundant memory traffic that the earlier revision still had.
Changes
relu(pre)from the stored squared activation instead of saving and reloading the pre-activation.kernels-community/flash-attn3. This PR does not include a custom FA3 implementation.Results
Four candidate seeds and a same-node
f411b3dbaseline, run back to back on one Prime Intellect node with 8x NVIDIA H100 80GB HBM3 (datacrunch, FIN-02). Stockrequirements.txt: Python 3.12, PyTorch 2.10.0+cu128 for CUDA 12.8, Triton 3.6.0. The training and validation token streams and the validation calculation are unchanged,requirements.txtis unmodified, and thetorch.compilecall sites and_inductor.configlines are identical tof411b3d.Candidate
Loss sample standard deviation 0.001209. The one-sample, one-sided test against 3.28 gives
t=-8.723776andp=0.001585, which satisfies the Track 1 loss requirement.Same-node baseline (
f411b3d)Speed
70.094 / 73.897 = 0.94854, a 5.15% reduction in training time on identical hardware, which projects 1.1667 minutes against the 1.23-minute record thatf411b3dholds. The baseline measured 1.2316 min on this node against 1.23 published, a 0.13% difference, so the node is not unusually fast or slow.Per step the candidate is 7.31% faster, 53.30 ms against 57.51 ms. The 45 extension iterations mean 1315 steps against main's 1285, and that 2.33% step-count increase gives back roughly a third of the per-step gain.
The earlier revision of this PR reported 77.812 s over 1425 steps and could only be compared against a published time from a different node, which gave 1.75%. Part of the absolute difference since then is the shorter schedule this branch picked up in the rebase. The 5.15% above is the portion measured on one node with both arms run back to back, and the FP8 backward coverage and reduced memory traffic listed under Changes are what moved it.
Alternate configuration
records/track_1_short/2026-08-03_FP8MLPBackwardPackedQKV/alternate_ext65/holds a 65-extension configuration that also passes, at mean loss 3.270500 and 71.892 s (ratio 0.97433, projecting 1.1984 min), with its own three-run baseline inalternate_ext65_baseline/. The 45-extension result above is the one being submitted. Since the leaderboard time is a ratio, the shorter schedule gives the better record provided its loss sample is tight enough to reach significance.Reproduction and validation
Candidate runs were launched as:
NUM_EXTENSION_ITERATIONS=45andQK_HEAD_DIM=96are the checked-in defaults, so a plain./run.shreproduces the submitted 1315-step configuration.Recalculate the submitted statistics with:
Additional checks completed:
python -m py_compile train_gpt.py triton_kernels.pyRaw logs, per-seed results, environment output, and the statistics script are in
records/track_1_short/2026-08-03_FP8MLPBackwardPackedQKV.