Repository navigation
Conversation
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.
Stack from ghstack (oldest at bottom):
Problem
#202218 added
triton.enable_fp_fusion: with it off, Inductor's Triton kernels round every multiply and add separately, so results no longer depend on the block size ornum_warpsthat autotuning, coordinate descent or the default heuristic picks. Deterministic mode itself still left contraction on, so a deterministic-mode run could still produce different bits depending on which pointwise config timing picked.Change
batch_invariant) now compiles Inductor's generated Triton kernels withenable_fp_fusion=False, via a newtriton_fp_fusion_enabled()helper inutils.pyused bytriton_meta_common.triton_helpersare written as explicittl.fma, so they keep a single rounding regardless of the contraction setting:welford_reduce,welford_combine,online_softmax_combine(_with_sum), andrand_eager_kernel(bit-neutral there, sinceinv = 2**-32makes the product exact).triton_metaand keep Triton's contraction. In deterministic mode their config is already chosen without benchmarking. Underbatch_invariantalone, templates and their fused epilogues are not covered by this PR.Numerics outside deterministic mode
The
tl.fmacalls intriton_helpersare unconditional. In modes where contraction was already off before this PR (triton.enable_fp_fusion=False,emulate_precision_casts, andnumerics="strict"/strict_pointwise, which imply it), welford (var_mean,layer_norm) and online-softmax results can change in the last bit. With contraction on (the default), Triton was already free to form these FMAs.Performance
Turning contraction off costs speed in deterministic mode only; default mode is unchanged. On better-benchmark (1724 kernels, H100, Nov 2 nightly),
triton.enable_fp_fusion=Falsemeasured +0.25% geomean. The slowdowns are concentrated in a few latency-bound reductions where a product feeding an add is no longer fused, e.g. two softmax kernels (+30%), a+12%) and avar_mean(sum(~+10%). These per-kernel numbers were measured on an earlier revision of this PR; the kernels were attributed to contraction being off, not to the helper changes. The online-softmax change below this PR (#204321) recovers the cross-entropy kernels (amax_sum_sum_a97be2219d64: 1782 us in deterministic mode today -> 1378 us).Note: without the Dynamo fix at the bottom of this stack (#204320),
config.deterministicset alone is turned off after the first compiled frame.Test plan
test_fp_fusion: deterministic mode turns offenable_fp_fusion; the flag alone still works as before.test_pointwise_config_numericsruns with deterministic mode alone and withtriton.enable_fp_fusion=Falsealone: forcing XBLOCK=128 vs 256 by timing gives bitwise-equal outputs.test_kernel_online_softmax_combine: reference updated to the explicit-FMA form.This change was authored with an AI assistant (Claude Code), with the change and tests reviewed in the session.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo