Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test(rocm): narrow optional-backend regression coverage
  • Loading branch information
zihaomu committed Oct 9, 2026
commit decc3d4e1337891fc31a45aa8a02fa383f24ae3f
17 changes: 5 additions & 12 deletions docs/install_amd.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,8 @@ actual target reported by `rocminfo`.

## Optional kernel backends

On ROCm, FreeToken does not probe or select its CUDA-only FlashInfer,
`sgl_kernel`, or vLLM kernel integrations, even if those packages are installed.
This restriction concerns the kernels FreeToken imports, not whether the
packages offer other AMD implementations. Do not install the `[accel]`, `[fi]`,
or `[sgl]` extras to enable these paths on AMD.

Generic attention with `--attention-backend auto` selects Triton; activation and
normalization use their Triton/PyTorch fallbacks. NVFP4 linear and MoE selection
also supports the native Triton kernels. Explicitly requesting FlashInfer/SGL
attention, NVFP4 Marlin, or NVFP4 b12x fails early with a ROCm-specific error.
Model-specific attention requirements still apply; this does not make every
checkpoint ROCm-compatible. CUDA discovery and kernel preferences are unchanged.
FreeToken's FlashInfer, `sgl_kernel`, and vLLM kernel integrations are CUDA-only.
On ROCm, these paths use the built-in fallbacks; do not install the `[accel]`,
`[fi]`, or `[sgl]` extras. Forcing `--attention-backend fi`, `fa`, or `trtllm`,
or NVFP4 Marlin/b12x (e.g. `--quant-backend moe.nvfp4=marlin` or
`--quant-backend moe.nvfp4=b12x`), fails with a ROCm-specific error.
12 changes: 6 additions & 6 deletions python/freetoken/kernel/backend.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Eligibility probes for the optional CUDA kernels used by FreeToken.
"""Availability probes for the optional native kernel packages.

On ROCm, flashinfer / sgl_kernel / vLLM donor paths are disabled before package
discovery or imports. This describes FreeToken's CUDA integrations, not whether
those packages have other AMD implementations. Callers use their Triton/PyTorch
fallbacks instead. On CUDA, cached ``find_spec`` checks retain the existing
package-discovery behavior; kernel-specific symbol checks happen at selection.
When flashinfer / sgl_kernel are installed the call-sites use their fused CUDA
ops; otherwise they fall back to the pure-Triton kernels in
``freetoken.kernel.triton``. ``find_spec`` only checks that the package is
importable (no import side effects), and the result is cached.
On ROCm, the optional-package probes return False so callers use the fallbacks.
"""
from __future__ import annotations

Expand Down
19 changes: 0 additions & 19 deletions tests/engine/test_attention_backend_arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,3 @@ def unexpected_probe(_name):
finally:
backend.is_flashinfer_installed.cache_clear()
backend.is_sgl_kernel_installed.cache_clear()


def test_cuda_sgl_attention_still_checks_symbols(monkeypatch):
import sys
from types import ModuleType

from freetoken.engine import engine
from freetoken.kernel import backend

parent = ModuleType("sgl_kernel")
module = ModuleType("sgl_kernel.flash_attn")
module.flash_attn_with_kvcache = object()
monkeypatch.setitem(sys.modules, "sgl_kernel", parent)
monkeypatch.setitem(sys.modules, "sgl_kernel.flash_attn", module)
monkeypatch.setattr(backend, "is_rocm", lambda: False)
assert engine._sgl_flash_attn_available()

del module.flash_attn_with_kvcache
assert not engine._sgl_flash_attn_available()
203 changes: 0 additions & 203 deletions tests/kernels/test_backend.py

This file was deleted.

Loading