fix(kernels): remove global --use_fast_math; selective per-kernel intrinsics only (T3.1) - #143
Merged
Merged
Conversation
…max only (T3.1) Drop --use_fast_math from NVCC_FLAGS: the flag swapped every expf/tanhf/logf/division for unsafe approximations library-wide; the non-saturating fast tanhf caused the GELU blowup behind the GPU f32 CrossAsset cliff (ztensor#125). Per the torch numerics convention (zerfoo plan-gpu-training-hardening T3.1) fast intrinsics are now re-enabled selectively in kernel source, only where the PyTorch-oracle gate proves equivalence within tolerance: - kernel_softmax keeps __expf AFTER max-subtraction (argument <= 0, result in (0,1], ~2^-21 relative error -- inside the Softmax tolerance atol 1e-6 / rtol 1e-4). - Everything else gets the accurate libdevice functions. - The tanh saturation clamp (ztensor#125) is RETAINED as defense-in-depth. Gate plumbing: oracle-gen grows -engine gpu (GenerateAllWith records compute.GPUEngine bundles through the same format -- the GPU-side oracle gate the scripts/oracle README reserved for T3.x), and compute/gpu_kernel_bench_test.go adds per-kernel GPU micro-benchmarks for the ops whose codegen changed, for the before/after perf delta. Verifies zerfoo UC-GH-5.
…, perf delta within noise
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.
Linear re-roll of #142 (same content; #142 grew a merge commit resolving the T2.4 devlog conflict, which GitHub's rebase-merge refuses to replay). All GB10 evidence lives on #142:
__expffwd max_rel 1.4e-7 (tol 1e-4); Tanh exact.VALIDATION_OK_new2, podztensor-t31-gate-new2-dbcb0da).Implements zerfoo plan-gpu-training-hardening T3.1 + S3.1.1 (verifies UC-GH-5).
ztensor-t31-build-393d8eb)