Skip to content

Idol CUDA decoder contract: tile-max P rounding in the reference, quicker self-attention gate 4 - #4508

Merged
ashhart merged 2 commits into
ashhart:mainfrom
jayleaton:idol-dec-attn-tiles
Nov 23, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
jayleaton:idol-dec-attn-tiles

Conversation

@jayleaton

@jayleaton jayleaton commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #1858, which merged at eea88db before this fix reached its branch. Thanks to @AIFlowML for the RTX 5090 run (#1858 (comment)). They showed that the tiled tf_idol_dec_attention failed the shapes gate at 16×1000×65: output 73111 was 1.35× the bound. They traced it to P being rounded at each 64-key tile's running maximum. Their run also timed out (exit 124 under timeout 360s) after the self-attention shapes gate.

Tiled rounding is the contract

The kernel is unchanged. The float64 reference now follows it.

Changes

  • zig/tests/cuda/contract_idol_dec_attn.zig: the reference's new weigh walks the keys in the spec's 64-key tiles. Each P is rounded to fp16 at the running maximum through its tile and carried to the final maximum. The midpoint allowance is taken at that running maximum. The few-row form keeps fp32 P.
  • Regression host test: three tiles whose P·V cancels exactly at tile 0's own maximum but not at tile 2's maximum, 0.2 higher. An fp32 online-softmax simulation of the kernel lands within the new allowance and more than 4× outside the old final-max one. Forcing the reference back to final-max rounding fails the test.
  • zig/tests/cuda/contract_idol_attn.zig, the timeout: gate 4 for the decoder's self attention runs at 8,192×8,192 and computed float64 outputs for every token ten times (a reference plus nine simulations), about 4e10 float64 steps. Its stress inputs make every key alike, so every token's outputs equal token 0's. It now computes token 0's once and copies them, and a host test checks the copies against the full computation.

Needs a GPU

I couldn't run or time this without a GPU. @AIFlowML or @ashhart, could one of you rerun timeout 360s tf-cuda-test idol-decoder-contract and confirm two things: that 16×1000×65 passes, and that the run reaches its SUMMARY within 360 s? I couldn't rebuild that exact fixture on the host, because its inputs come through the GPU rig.

Checks

On 8ce4741, over main c35d9f7:

  • zig fmt --check, git diff --check and lean (0 new) are clean. pr_check --pr 4508 gives 0 errors and 0 warnings.
  • cuda_common_check, cuda_fragment_check and the cuda_common_check_test unittest pass.
  • zig build -Dfixed-cpu test-gradient-serving test-idol-cuda-host test-kernel-contract compile-cuda-tests passes 61/61 steps and 320/320 tests.
  • The cross-build zig build compile-cuda-tests -Dtarget=aarch64-linux-gnu -Doptimize=ReleaseSafe passes 10/10.
  • The only changed file over 600 lines is CHANGELOG.md, as on main.

No GPU run yet: see above.

@AIFlowML

Copy link
Copy Markdown
Contributor

Retested exact head 8ce47419f691070c16635deeeda208083e82487a on Linux x86-64, RTX 5090 Laptop GPU (SM 12.0, driver 595.99.02), Zig 0.17.0 and nvcc 13.1.115. The tree merges cleanly into c35d9f73c.

zig build compile-cuda-tests -Dnvcc=/usr/local/cuda/bin/nvcc -Dsm=120 -Doptimize=ReleaseSafe -j2 --summary all
timeout 360s /path/to/tf-cuda-test idol-decoder-contract

The build passed 183/183 steps. 16×1000×65 now passes. The tiled cross-attention gate passed all 11 shapes, with zero refusals and a worst result of 0.537× its bound. The runner reached its full SUMMARY in 68.28 s and exited 0: 7/7 kernels passed gates 1–4, and 13/13 planted controls went red as expected.

On M5 Max the host target zig build test-idol-cuda-host -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j2 --summary all passed 42/42. Forcing final-max rounding in scratch tripped the new late-tile regression test. This covers the contract and timeout; GB10 and release-checkpoint parity remain separate.

Igor Lessio - AIFLOW LABS

jayleaton and others added 2 commits November 23, 2026 15:43
…ter ashhart#1858)

The tiled decoder attention rounds P to fp16 at each 64-key tile's running
maximum and rescales the sums, as torch's CUDA online-softmax kernels do.
The float64 reference rounded at the final maximum, so a later tile with a
larger score moved where P rounds and the shapes gate went red at
16x1000x65 (reported on an RTX 5090). The reference now follows the tile
maxima, with the midpoint allowance at the running maximum, and a host test
checks a fp32 online-softmax simulation against both.

Gate 4's self attention over 8,192 anchors computed every token's outputs
in float64 nine times, though alike keys make every token's outputs token
0's; it computes those once and copies them (about 4e10 float64 steps
fewer, untimed here: no GPU).
@ashhart
ashhart force-pushed the idol-dec-attn-tiles branch from 1ad99b1 to b57d141 Compare November 23, 2026 15:43
@ashhart
ashhart merged commit 95ed345 into ashhart:main Nov 23, 2026
3 of 12 checks passed
@ashhart

ashhart commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thank you @jayleaton. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

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.

3 participants