Files
FreeToken/docs/install_amd.md
Xiaoze Fanandzihaomu 2010271266 refactor(cpu-moe): split the executor into weight formats and gpu sync backends (#670)
* refactor(cpu-moe): split the executor into weight formats and gpu sync backends

- move each expert weight format into kernels/<fmt>.cpp behind the MoeFormat
  interface in format.h; the executor keeps the threads, the work split and
  the pass 2 route sum
- pass each format its banks and integer options by name; MoeParams keeps only
  the shared shape and activation fields
- key the formats by name in one table that weight_formats() exports, replacing
  the integer format ids and the fp8_block_isa_name hook
- replace the per-(layer, batch size) flag slots, pinned IO buffers and task
  table with one doorbell word MoeTask{layer, num_tokens} and one shared pinned
  IO block of max_tokens rows
- move the GPU/CPU handshake behind GpuSync with a CUDA and a HIP backend picked
  by setup.py; HIP waits on signal memory and adds explicit batch-memop graph
  nodes where the runtime does not record the native memops under capture
- raise on graph capture when the handshake is off and host functions are not
  replay-safe
- allocate format scratch on 64-byte boundaries
- size max_tokens by the explicit cuda_graph_bs as well

Co-authored-by: zihaomu <zihaomu@outlook.com>

* perf(cpu-moe): skip the worker pool for tasks without routed experts

* perf(cpu-moe): publish and combine the cpu handshake with kernels

* fix(cpu-moe): clean up failed hip capability probes

---------

Co-authored-by: zihaomu <zihaomu@outlook.com>
2026-10-13 20:12:58 -07:00

2.1 KiB

AMD ROCm installation (WIP)

AMD support is experimental and remains a work in progress. See the AMD Support roadmap for the current integration and qualification status.

Requirements

  • Linux x86_64
  • AMD RDNA3/RDNA4 GPU (gfx1100-gfx1103, gfx1200, or gfx1201)
  • ROCm 7.14
  • Python >= 3.10

Install from source

Use an official ROCm PyTorch image whose PyTorch version satisfies the project's torch>=2.11,<2.12 constraint. For RDNA4, the matching ROCm 7.14 image is:

VIDEO_GID="$(getent group video | cut -d: -f3)"
RENDER_GID="$(getent group render | cut -d: -f3)"
docker run --rm -it \
  --device=/dev/kfd --device=/dev/dri \
  --group-add="$VIDEO_GID" --group-add="$RENDER_GID" --ipc=host \
  --cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
  -e PYTORCH_ROCM_ARCH=gfx1201 -e FREETOKEN_ROCM_ARCH=gfx1201 \
  -v "$PWD:/workspace/FreeToken" -w /workspace/FreeToken \
  rocm/pytorch:rocm7.14_ubuntu24.04_py3.12_pytorch_release_2.11.0 bash

Inside the container, preserve the ROCm-enabled PyTorch already supplied by the image and disable build isolation so it is also used to compile the extensions:

python -m pip install --no-build-isolation -e .

Set both architecture variables to gfx1200 for RX 9060 family GPUs, or to the actual target reported by rocminfo.

Optional kernel backends

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.

CPU and hybrid MoE

--moe-strategy cpu, hybrid and --moe-cpu-layers sync the GPU with the CPU expert pool through HIP stream memory operations. ROCm 10 records them into CUDA graphs itself; on ROCm 7.14, which does not, FreeToken adds the graph nodes explicitly. When the startup probe of that path fails, CUDA graph capture stops with an error; run those strategies with --cuda-graph-max-bs 0.