Skip to content

[upstream_ut] test/dynamo/test_higher_order_ops.py test_dropout failed with RuntimeError: CUDA not available - #9

Draft
Stonepia wants to merge 1 commit into
mainfrom
agent/issue-3361
Draft

[upstream_ut] test/dynamo/test_higher_order_ops.py test_dropout failed with RuntimeError: CUDA not available#9
Stonepia wants to merge 1 commit into
mainfrom
agent/issue-3361

Conversation

@Stonepia

@Stonepia Stonepia commented May 12, 2026

Copy link
Copy Markdown
Collaborator

[upstream_ut] test/dynamo/test_higher_order_ops.py test_dropout failed with RuntimeError: CUDA not available

Fixes intel/torch-xpu-ops#3361

Root Cause: The test test_dropout uses @requires_cuda_and_triton which skips when CUDA is unavailable, but the XPU CI environment has CUDA libraries present (satisfying the decorator at module-load time) yet no working CUDA GPU. When AOTAutograd's create_functionalized_rng_ops_wrapper is invoked with functionalize_rng_ops=True, it unconditionally calls CUDARngStateHelper.get_torch_state_as_tuple (graph_capture_wrappers.py:580) which hard-raises RuntimeError('CUDA not available') with no CUDA guard. The function get_torch_state_as_tuple is CUDA-only but functionalize_rng_ops is a generic config flag that can be activated on non-CUDA backends.

Failed Tests:

  • test/dynamo/test_higher_order_ops.py::ActivationCheckpointingTests::test_dropout

Diff stat:

torch/_dynamo/variables/builder.py                       | 3 ++-
 torch/_functorch/_aot_autograd/graph_capture_wrappers.py | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

[upstream_ut] test/dynamo/test_higher_order_ops.py test_dropout failed with RuntimeError: CUDA not available
@kdrozd-dev

Copy link
Copy Markdown

This does not fix the issue as test_dropout:

    @requires_gpu_and_triton
    @torch._functorch.config.patch(functionalize_rng_ops=True)
    def test_dropout(self):
        def gn(x, y):
            return torch.nn.functional.dropout(torch.matmul(x, y), p=0.2)

        def fn(x, y):
            return torch.utils.checkpoint.checkpoint(
                gn, torch.sin(x), y, use_reentrant=True
            )

        x = torch.randn(4, 4, device=GPU_TYPE, requires_grad=True)
        y = torch.randn(4, 4, device=GPU_TYPE, requires_grad=True)

        fw_compiler = functools.partial(
            count_ops, freq=1, op=torch.ops.rngprims.philox_rand.default
        )
        # philox_rand is passed from fwd
        bw_compiler = functools.partial(
            count_ops, freq=0, op=torch.ops.rngprims.philox_rand.default
        )
        backend = aot_autograd(fw_compiler=fw_compiler, bw_compiler=bw_compiler)
        self._validate(
            fn, backend, x, y, skip_check=True
        )  # dropout decomp is known to diverge with eager

python -m pytest dynamo/test_higher_order_ops.py -k dropout -vs fails with:

============================= test session starts ==============================
platform linux -- Python 3.12.3, pytest-9.0.2, pluggy-1.6.0 -- /home/gta/pytorch/.venv/bin/python
cachedir: .pytest_cache
hypothesis profile 'dev' -> database=None, max_examples=10, suppress_health_check=(HealthCheck.too_slow,)
rootdir: /home/gta/pytorch
configfile: pytest.ini
plugins: hypothesis-6.151.9, repeat-0.9.4
collecting ... collected 220 items / 218 deselected / 2 selected
Running 2 items in this shard

dynamo/test_higher_order_ops.py::ActivationCheckpointingTests::test_dropout FAILED [0.4392s]
dynamo/test_higher_order_ops.py::ActivationCheckpointingTests::test_dropout_inductor SKIPPED [0.0002s]

=================================== FAILURES ===================================
__________________ ActivationCheckpointingTests.test_dropout ___________________
Traceback (most recent call last):
  File "/usr/lib/python3.12/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/usr/lib/python3.12/unittest/case.py", line 634, in run
    self._callTestMethod(testMethod)
  File "/usr/lib/python3.12/unittest/case.py", line 589, in _callTestMethod
    if method() is not None:
       ^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/testing/_internal/common_utils.py", line 3534, in wrapper
    method(*args, **kwargs)
  File "/usr/lib/python3.12/contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/test/dynamo/test_higher_order_ops.py", line 6920, in test_dropout
    self._validate(
  File "/home/gta/pytorch/test/dynamo/test_higher_order_ops.py", line 6849, in _validate
    result = opt_fn(*cloned_args)
             ^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_dynamo/eval_frame.py", line 1134, in compile_wrapper
    raise e.remove_dynamo_frames() from None  # see TORCHDYNAMO_VERBOSE=1
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_dynamo/output_graph.py", line 3075, in _call_user_compiler
    raise BackendCompilerFailed(
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_dynamo/output_graph.py", line 3049, in _call_user_compiler
    compiled_fn = compiler_fn(gm, example_inputs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_dynamo/repro/after_dynamo.py", line 159, in __call__
    compiled_gm = compiler_fn(gm, example_inputs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/__init__.py", line 2561, in __call__
    return self.compiler_fn(model_, inputs_, **self.kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_dynamo/backends/common.py", line 123, in __call__
    cg = aot_module_simplified(gm, example_inputs, **self.kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/aot_autograd.py", line 1233, in aot_module_simplified
    aot_graph_capture = aot_stage1_graph_capture(aot_state, functional_call)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_compile.py", line 244, in aot_stage1_graph_capture
    ) = aot_dispatch_autograd_graph(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture.py", line 527, in aot_dispatch_autograd_graph
    fx_g, saved_updated_joint_inputs = _create_graph_and_save_traced_inputs(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture.py", line 279, in _create_graph_and_save_traced_inputs
    _create_graph(fn_to_trace, flat_args, flat_args_descs, aot_config=aot_config),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture.py", line 130, in _create_graph
    fx_g = make_fx(
           ^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 3032, in wrapped
    return make_fx_tracer.trace(f, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 2934, in trace
    return self._trace_inner(f, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 2895, in _trace_inner
    t = dispatch_trace(
        ^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_compile.py", line 54, in inner
    return disable_fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_dynamo/eval_frame.py", line 1382, in _fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 1669, in dispatch_trace
    graph = tracer.trace(root, concrete_args)  # type: ignore[arg-type]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_dynamo/eval_frame.py", line 1382, in _fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/_symbolic_trace.py", line 914, in trace
    (self.create_arg(fn(*args)),),
                     ^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/_symbolic_trace.py", line 753, in flatten_fn
    tree_out = root_fn(*tree_args)
               ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 1739, in wrapped
    out = f(*tensors)  # type:ignore[call-arg]
          ^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture.py", line 113, in inner_f
    out, out_descs = call_and_expect_output_descs(f, args)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/utils.py", line 778, in call_and_expect_output_descs
    outs_pair = fn(*args)
                ^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 1233, in inner_fn
    outs, outs_descs = call_and_expect_output_descs(fn, args)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/utils.py", line 778, in call_and_expect_output_descs
    outs_pair = fn(*args)
                ^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 1175, in joint_helper
    return _functionalized_f_helper(primals, tangents)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 905, in _functionalized_f_helper
    f_outs, f_outs_descs = call_and_expect_output_descs(fn, f_args)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/utils.py", line 778, in call_and_expect_output_descs
    outs_pair = fn(*args)
                ^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 497, in joint_helper
    return inner_fn_with_anomaly(primals, tangents)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 489, in inner_fn_with_anomaly
    return inner_fn(primals, tangents)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 319, in inner_fn
    (outs, tangent_mask), (outs_descs, _) = call_and_expect_output_descs(
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/utils.py", line 778, in call_and_expect_output_descs
    outs_pair = fn(*args)
                ^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 180, in inner_fn
    outs, outs_descs = call_and_expect_output_descs(fn, args_maybe_cloned)  # type: ignore[arg-type]
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/utils.py", line 778, in call_and_expect_output_descs
    outs_pair = fn(*args)
                ^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_compile.py", line 207, in orig_flat_fn2
    out = orig_flat_fn(*args)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/graph_capture_wrappers.py", line 1537, in functional_call
    out = PropagateUnbackedSymInts(mod).run(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/interpreter.py", line 197, in run
    self.env[node] = self.run_node(node)
                     ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/symbolic_shapes.py", line 8700, in run_node
    result = super().run_node(n)
             ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/interpreter.py", line 294, in run_node
    return getattr(self, n.op)(n.target, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/interpreter.py", line 377, in call_function
    return target(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_higher_order_ops/wrap.py", line 363, in __call__
    return checkpoint(Interpreter(function).run, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_compile.py", line 54, in inner
    return disable_fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_dynamo/eval_frame.py", line 1382, in _fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/utils/checkpoint.py", line 518, in checkpoint
    ret = function(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/interpreter.py", line 197, in run
    self.env[node] = self.run_node(node)
                     ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/interpreter.py", line 294, in run_node
    return getattr(self, n.op)(n.target, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/interpreter.py", line 377, in call_function
    return target(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/nn/functional.py", line 1443, in dropout
    return handle_torch_function(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/overrides.py", line 1779, in handle_torch_function
    result = mode.__torch_function__(public_api, types, args, kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 1794, in __torch_function__
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/nn/functional.py", line 1449, in dropout
    _VF.dropout_(input, p, training) if inplace else _VF.dropout(input, p, training)
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_decomp/decompositions.py", line 1183, in dropout
    return aten.native_dropout(input, p, train)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_ops.py", line 1275, in __call__
    return self._op(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_compile.py", line 54, in inner
    return disable_fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_dynamo/eval_frame.py", line 1382, in _fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_subclasses/functional_tensor.py", line 611, in __torch_dispatch__
    outs_unwrapped = func._op_dk(
                     ^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_compile.py", line 54, in inner
    return disable_fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_dynamo/eval_frame.py", line 1382, in _fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/utils/_stats.py", line 29, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 1979, in __torch_dispatch__
    return proxy_call(self, func, self.pre_dispatch, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 1158, in proxy_call
    r = maybe_handle_decomp(proxy_mode, func, args, kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 3105, in maybe_handle_decomp
    out = decomp_table[op](*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_decomp/__init__.py", line 118, in _fn
    return f(*args, **kwargs, out=None if is_none else out_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_prims_common/wrappers.py", line 313, in _fn
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_decomp/decompositions.py", line 1198, in native_dropout
    bool_mask = torch.rand_like(input) > p
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_compile.py", line 54, in inner
    return disable_fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_dynamo/eval_frame.py", line 1382, in _fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/utils/_stats.py", line 29, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 1979, in __torch_dispatch__
    return proxy_call(self, func, self.pre_dispatch, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 1158, in proxy_call
    r = maybe_handle_decomp(proxy_mode, func, args, kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/fx/experimental/proxy_tensor.py", line 3105, in maybe_handle_decomp
    out = decomp_table[op](*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_decomp/decompositions_for_rng.py", line 56, in rand_like
    throw_on_non_cuda(device)
  File "/home/gta/pytorch/.venv/lib/python3.12/site-packages/torch/_decomp/decompositions_for_rng.py", line 23, in throw_on_non_cuda
    raise RuntimeError(
torch._dynamo.exc.BackendCompilerFailed: backend='compiler_fn' raised:
RuntimeError: You are trying to functionalize a xpu RNG operator but xpu does not use Philox/counter-based RNG. Therefore, functionalizing a xpu RNG operator is not supported. We are discussing the possibility of a Philox-based RNG implementation for CPU.

While executing %dropout : [num_users=1] = call_function[target=torch.nn.functional.dropout](args = (%matmul,), kwargs = {p: 0.2})
Original traceback:
  File "/home/gta/pytorch/test/dynamo/test_higher_order_ops.py", line 6905, in fn
    return torch.utils.checkpoint.checkpoint(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gta/pytorch/test/dynamo/test_higher_order_ops.py", line 6902, in gn
    return torch.nn.functional.dropout(torch.matmul(x, y), p=0.2)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Use tlparse to see full graph. (https://github.com/pytorch/tlparse?tab=readme-ov-file#tlparse-parse-structured-pt2-logs)

While executing %wrap_activation_checkpoint : [num_users=1] = call_function[target=torch.ops.higher_order.wrap_activation_checkpoint](args = (%wrap_body_0, %sin, %l_y_), kwargs = {use_reentrant: True})
Original traceback:
  File "/home/gta/pytorch/test/dynamo/test_higher_order_ops.py", line 6905, in fn
    return torch.utils.checkpoint.checkpoint(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Use tlparse to see full graph. (https://github.com/pytorch/tlparse?tab=readme-ov-file#tlparse-parse-structured-pt2-logs)

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"


To execute this test, run the following from the base repo dir:
    python test/dynamo/test_higher_order_ops.py ActivationCheckpointingTests.test_dropout

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
=========================== short test summary info ============================
FAILED [0.4392s] dynamo/test_higher_order_ops.py::ActivationCheckpointingTests::test_dropout
================= 1 failed, 1 skipped, 218 deselected in 3.20s =================

The issue is rooted a bit deeper. I am currently working on a proper solution.

@Stonepia

Stonepia commented May 13, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @kdrozd-dev , Thanks for the comment! This is just an agent workflow test, so I didn't quite read the code yet. Thanks for the fix!

chuanqi129 pushed a commit that referenced this pull request Jun 24, 2026
…#188024)

Some gfx950 (MI350) 2-GPU runner pods come up with a container that cannot read
part of the KFD/HSA topology. RCCL then fails every collective init with
"ncclUnhandledCudaError: Call to CUDA function failed / Could not read node #N"
(N is a fixed topology-node index for that pod, e.g. #2 or #9). When a
distributed shard lands on such a pod, the first collective crashes and a later
test hangs the whole shard until the 270-minute job timeout. Host-side rocminfo
still enumerates the GPUs on these pods, so the existing "Runner check GPU
count" gate does not catch it -- the failure is the container's deeper topology
read, not agent enumeration.

Diagnosis: the same RCCL error appears across many different distributed tests
and both worker-crash and downstream-hang forms; in the logs it is constant per
pod and present from the very first collective, and world_size is 2 so "node #N"
cannot be a rank -- it is a system topology node. So it is a per-pod container
health problem, not a PyTorch or per-test bug.

Fix: add a fast in-container RCCL pre-flight (.ci/pytorch/rocm_preflight.py) that
spawns a min(2, ngpu)-rank process group and does one all_reduce. For
distributed shards _rocm-test.yml runs it (wrapped in `timeout 180`) before the
suite; on failure or hang the job fails in seconds with a clear message instead
of hanging for 270 minutes, and the bad pod is identifiable for draining.
Non-distributed shards are unchanged.

Test Plan:

```
python -m py_compile .ci/pytorch/rocm_preflight.py
lintrunner -a .ci/pytorch/rocm_preflight.py .github/workflows/_rocm-test.yml
```

Validated the pre-flight directly. Locally on 8x A100 (the nccl backend
exercises the same init/collective path RCCL uses) the script passes:

  ROCm/RCCL pre-flight passed (2-rank all_reduce)

and the failure path is exercised too: when the process group cannot initialize,
mp.spawn raises, the script prints the "::error::" message and exits 1 -- the job
fails fast instead of hanging.

In CI, dispatched the gate on the gfx950.2 distributed pool: the pre-flight ran
inside the container and passed on healthy pods (exit 0, suite proceeded). The
broken-pod case is the same exit-1 fast-fail path; it only reproduces when a pod
with the broken KFD topology is in rotation, and the pool was healthy during
testing, so that specific case was not caught live.

Authored with Claude.

Pull Request resolved: pytorch#188024
Approved by: https://github.com/frgossen
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.

[upstream_ut] test/dynamo/test_higher_order_ops.py test_dropout failed with RuntimeError: CUDA not available

2 participants