Skip to content

Skip CUDA transformer forward tests when TransformerBuilder is incompatible - #8200

Merged
sfc-gh-truwase merged 1 commit into
masterfrom
sfc-gh-truwase/fix-cuda-forward-cpu-skip
Jul 31, 2026
Merged

Skip CUDA transformer forward tests when TransformerBuilder is incompatible#8200
sfc-gh-truwase merged 1 commit into
masterfrom
sfc-gh-truwase/fix-cuda-forward-cpu-skip

Conversation

@sfc-gh-truwase

Copy link
Copy Markdown
Collaborator

Summary

tests/unit/ops/accelerators/test_accelerator_forward.py has three transformer-kernel test methods, but only TestCUDAForwardSmallBatchSize.test_forward_with_small_bsz guards on TransformerBuilder compatibility. TestCUDAForward.test_forward and TestCUDAForwardStochastic.test_forward_stochastic do not.

These tests build and run the CUDA-only DeepSpeedTransformerLayer. The module has a top-level fp16 gate:

if torch.half not in get_accelerator().supported_dtypes():
    pytest.skip(..., allow_module_level=True)

On CPU, CPU_Accelerator.supported_dtypes() includes float16 only when is_fp16_supported() is true, which resolves to torch.ops.mkldnn._is_mkldnn_fp16_supported() -- a runtime CPU-capability probe. GitHub's ubuntu-24.04 runners are heterogeneous:

  • On most runners the probe returns False, the module is skipped, and cpu-torch-latest is green (this is why scheduled master runs pass).
  • On a runner whose CPU advertises oneDNN fp16 support, the probe returns True, the module is not skipped, and test_forward / test_forward_stochastic run and fail trying to JIT-build a CUDA kernel on CPU (the sequential pytest pass in cpu-torch-latest).

This makes cpu-torch-latest flaky 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 by test_forward_with_small_bsz) to test_forward and test_forward_stochastic, so they are skipped whenever the CUDA TransformerBuilder op is not compatible on the host.

Test plan

  • cpu-torch-latest (including the -m sequential pass) is green regardless of runner CPU.
  • On CUDA hosts where TransformerBuilder is compatible, the tests still run as before.

Made with Cursor

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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@sfc-gh-truwase
sfc-gh-truwase added this pull request to the merge queue Jul 31, 2026
Merged via the queue into master with commit 7e07be2 Jul 31, 2026
13 of 15 checks passed
@sfc-gh-truwase
sfc-gh-truwase deleted the sfc-gh-truwase/fix-cuda-forward-cpu-skip branch July 31, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants