Skip CUDA transformer forward tests when TransformerBuilder is incompatible - #8200
Conversation
TestCUDAForward.test_forward and TestCUDAForwardStochastic.test_forward_stochastic build and run the CUDA-only DeepSpeedTransformerLayer (TransformerBuilder), but unlike their sibling test_forward_with_small_bsz they lacked the TransformerBuilder compatibility guard. On cpu-torch-latest runners whose CPU advertises oneDNN fp16 support, the module-level fp16 skip is bypassed (CPU_Accelerator.supported_dtypes() then includes float16), so these tests run and fail trying to build a CUDA kernel on CPU. Add the same skipif guard so they are skipped when TransformerBuilder is not compatible. Signed-off-by: Olatunji Ruwase <tunji.ruwase@snowflake.com> Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f820289573
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| world_size = 1 | ||
| reuse_dist_env = True | ||
|
|
||
| @pytest.mark.skipif(not deepspeed.ops.__compatible_ops__[TransformerBuilder.NAME], |
There was a problem hiding this comment.
Add the required Signed-off-by trailer
This reviewed commit is a non-merge commit with one parent, but its commit message does not contain a Signed-off-by trailer. The repository requires every non-merge commit to be signed off, so this needs to be recreated or amended with --signoff before it can satisfy the project’s commit requirements.
AGENTS.md reference: AGENTS.md:L8-L8
Useful? React with 👍 / 👎.
Summary
tests/unit/ops/accelerators/test_accelerator_forward.pyhas three transformer-kernel test methods, but onlyTestCUDAForwardSmallBatchSize.test_forward_with_small_bszguards onTransformerBuildercompatibility.TestCUDAForward.test_forwardandTestCUDAForwardStochastic.test_forward_stochasticdo not.These tests build and run the CUDA-only
DeepSpeedTransformerLayer. The module has a top-level fp16 gate:On CPU,
CPU_Accelerator.supported_dtypes()includesfloat16only whenis_fp16_supported()is true, which resolves totorch.ops.mkldnn._is_mkldnn_fp16_supported()-- a runtime CPU-capability probe. GitHub'subuntu-24.04runners are heterogeneous:False, the module is skipped, andcpu-torch-latestis green (this is why scheduled master runs pass).True, the module is not skipped, andtest_forward/test_forward_stochasticrun and fail trying to JIT-build a CUDA kernel on CPU (thesequentialpytest pass incpu-torch-latest).This makes
cpu-torch-latestflaky depending on which runner the job lands on.Fix
Add the existing
@pytest.mark.skipif(not deepspeed.ops.__compatible_ops__[TransformerBuilder.NAME], ...)guard (already used bytest_forward_with_small_bsz) totest_forwardandtest_forward_stochastic, so they are skipped whenever the CUDATransformerBuilderop is not compatible on the host.Test plan
cpu-torch-latest(including the-m sequentialpass) is green regardless of runner CPU.TransformerBuilderis compatible, the tests still run as before.Made with Cursor