Skip to content

Two tests fail on a CUDA host since #736 / #697: test_nvfp4_experts_restricted_to_triton_for_swigluoai (sm_120) and test_graph_capture_reuses_warm_offload_cache_before_capture (any Linux host with libcuda) #765

Open

Description

@gdevenyi

What happened

On an RTX 5080 (sm_120), on main cc56b6b:

FAILED tests/models/test_minimax_m3.py::test_nvfp4_experts_restricted_to_triton_for_swigluoai
    assert 'w4a4' == 'triton'
FAILED tests/moe/test_offload.py::test_graph_capture_reuses_warm_offload_cache_before_capture
    AttributeError: 'FakeGraph' object has no attribute 'raw_cuda_graph_exec'

The first fails only on sm_120. The second fails on any Linux host where libcuda.so.1 loads, even with CUDA_VISIBLE_DEVICES= (#739's description also lists it among the failures already on main on an RTX PRO 6000).

Minimal reproduction (CPU only, PYTHONPATH=python):

CUDA_VISIBLE_DEVICES= python -m pytest -q -p no:cacheprovider \
  "tests/moe/test_offload.py::test_graph_capture_reuses_warm_offload_cache_before_capture"
>       rc = upload(graph.raw_cuda_graph_exec(), stream.cuda_stream)
E       AttributeError: 'FakeGraph' object has no attribute 'raw_cuda_graph_exec'
python/freetoken/engine/graph.py:126: AttributeError
1 failed

The minimax test passes on a CPU host. The script below makes the same kernel selection as the test, then lets W4a4Nvfp4MoEKernel.worth_it() see what an sm_120 GPU reports:

import torch
from freetoken.kernel import backend, nvfp4_moe
from freetoken.layers.quantization import ModelOptConfig, MoEConfig, select_kernel
from freetoken.layers.quantization.moe import Nvfp4MoEMethod
backend.device_capability = lambda: (12, 0)  # what the test monkeypatches
backend.is_vllm_installed = backend.is_flashinfer_installed = lambda: True
cfg = MoEConfig(num_experts=256, hidden=6144, intermediate=3072, top_k=4, scheme=ModelOptConfig.SCHEMES["NVFP4"],
                strategy="offload", activation="swigluoai", alpha=1.702, limit=7.0)
print("CPU host:             ", select_kernel(Nvfp4MoEMethod.candidates, "auto", cfg).name)
torch.cuda.is_available = lambda: True  # what worth_it() sees on a real sm_120 GPU
torch.cuda.current_device = lambda: 0
nvfp4_moe.w4a4_available = lambda device_index: True
print("sm_120 GPU (worth_it):", select_kernel(Nvfp4MoEMethod.candidates, "auto", cfg).name)
CPU host:              triton
sm_120 GPU (worth_it): w4a4

Cause (current main, cc56b6b)

  • tests/models/test_minimax_m3.py:273-285: the test monkeypatches backend.device_capability to (12, 0) and expects auto to pick triton. perf(moe): prefill nvfp4 W4A4 moe kernel on sm_120 #736 put W4a4Nvfp4MoEKernel first in Nvfp4MoEMethod.candidates (layers/quantization/moe/nvfp4.py:623). Its worth_it() (nvfp4.py:99-102) does not use backend.device_capability. It asks the real device through torch.cuda.is_available() and nvfp4_moe.w4a4_available(torch.cuda.current_device()). On a CPU host that is False, so the test passes. On sm_120 it is True, and w4a4 is a Triton subclass that accepts swigluoai, so auto picks w4a4. The test's intent ("marlin / b12x hard-code silu") still holds. Only the expected name is stale.
  • tests/moe/test_offload.py:467-469: FakeGraph has only pool(). fix(engine): upload cuda graphs at capture so a stream wait cannot block the first launch #697 added _upload_graph after each capture (engine/graph.py:118-128, called at :222), and it calls graph.raw_cuda_graph_exec() whenever _cu_graph_upload() (graph.py:108-115) is not None, which is any Linux, non-HIP host with libcuda.so.1.

Proposed fix

  • minimax test: assert that auto picks neither marlin nor b12x (in ("w4a4", "triton")). Or pin the device side as well, with monkeypatch.setattr(W4a4Nvfp4MoEKernel, "worth_it", lambda self, cfg: False), so that the test does not depend on the host GPU.
  • offload test: monkeypatch.setattr("freetoken.engine.graph._upload_graph", lambda graph, stream: None), or give FakeGraph a raw_cuda_graph_exec() and stub _cu_graph_upload.

Environment

Seen on an RTX 5080 16 GB (sm_120, driver 615.78.08), torch 2.14.1+cu130; reproduction CPU-only on main cc56b6b.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions