Deterministic bwd kernel for mamba2 #827
Open
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.
An attempt at enabling E2E deterministic training runs for hybrid models.
Atomic add non-determinism
Source of non-determinism are atomic operations in mamba2 bwd triton kernels as well as causal-conv1d. Submitting MR88 in parallel to causal-conv1d repo.
This MR modifies triton kernels to have deterministic path without the use of atomics.
Autotuner / kernel-shape non-determinism
Additional source of non-determinism is usage of tl.cumsum in triton kernels. tl.cumsum will produce different outputs for BLOCK_SIZE_H=1 vs BLOCK_SIZE_H>1. See triton-lang/triton#3017.
Current implementation doesn't make use of triton.autotune cache_results, which leads to chance of introducing non-determinism via different block sizes used for tl.cumsum. Also don't believe latest NGC torch images have version of triton new enough that supports this flag anyway.
Per-kernel breakdown
seqlen=2048
seqlen=4096
seqlen=16384