Add an opt-in deterministic execution policy (#8917)
# Add an opt-in deterministic execution policy
Draft contribution related to #8915, prepared following the submitter's
offline
discussion with DeepSpeed developers. Maintainer design review is
requested.
## Changes
- Add boolean `deterministic_mode`, default false, with small
config/engine wiring
and a 31-line runtime helper.
- On CUDA, select strict PyTorch deterministic algorithms, disable
TF32/cuDNN
benchmarking and enable deterministic cuDNN. Validate cuBLAS workspace
environment; do not attempt to install it after CUDA use.
- Preserve communication precision, NCCL algorithm, GAS, TP/EP and
overlap
settings. Do not prohibit configurations merely because they are
untested.
- Forward PyTorch's deterministic state to FPDT FlashAttention backward
across
GPU/offload and supported version branches.
- Reject legacy `stochastic_mode=True` during
construction/forward/backward
when deterministic algorithms are enabled.
- Bypass Triton grouped GEMM timing autotuning with an existing fixed
configuration for forward/dx/dw, without mutating shared autotune
caches.
- Add configuration, runtime and custom-path tests, config docs and
tutorial.
## Verification
Initial isolated flag branch at baseline `fc7bc301f`:
```bash
PYTHONPATH=/opt/tiger/DeepSpeed-deterministic-minimal \
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 CUDA_VISIBLE_DEVICES=8 \
python -m pytest tests/unit/runtime/test_ds_config_model.py \
tests/unit/runtime/test_determinism.py -q --disable-warnings
```
32 tests passed. Device cases: single NVIDIA L20, FP32 Torch AdamW,
ZeRO0/2/3, GAS2, three updates, two independent subprocess launches per
stage.
Exact outputs/gradients/weights/moments and update counters repeat.
Environment: driver535.261.03, Python3.11.2, PyTorch2.9.1/CUDA13.1,
NCCL2.27.5. These results predate the three custom-path additions.
After custom-path additions:
```bash
PYTHONPATH=/opt/tiger/DeepSpeed-deterministic-minimal \
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest \
tests/unit/runtime/test_custom_determinism.py \
tests/unit/runtime/test_ds_config_model.py -q --disable-warnings
```
29 CPU config/policy tests passed. Actual Triton wrapper inspection
confirmed
Autotuner -> JITFunction for both grouped kernels. YAPF, changed-file
flake8
and `git diff --check` passed.
## Coordination
AI assistance was used in tests writing and this tutorial. The submitter
has
confirmed review and authorized DCO sign-off using zimingzh@umich.edu.
Modified-file pre-commit checks passed before submission.
---------
Signed-off-by: ziming.zhou <zimingzh@umich.edu>