Skip to content

vllm.platforms.rocm

Classes:

Functions:

  • get_rocm_version –

    Return the installed ROCm release as (major, minor, patch), or None.

RocmPlatform

Bases: Platform

Methods:

enable_multi_stream_overlap(aux_stream_list, attn_metadata) classmethod

ROCm multi-stream gates: streams and capture region.

Dict metadata marks piecewise cudagraph, whose eager breaks rebuild the attention inputs on the owning stream. Forking side streams there would rely on runtime HIP event sync, which is unreliable in this overlap on ROCm (event waits can hang), so multi-stream only runs where the fork/join becomes static graph edges: inside capture, or with non-dict metadata (full cudagraph or the profile run), which has no eager breaks.

get_all_device_numa_nodes() classmethod

Get NUMA nodes for all visible GPU devices.

get_mla_prefill_backend_cls(mla_selector_config) classmethod

On ROCm, prefer the AITER FlashAttention backend, falling back to FlashAttention.

Raises:

  • ValueError –

    If neither backend is valid for the configuration.

import_kernels() classmethod

Import ROCm-specific kernels.

insert_blocks_to_device(src_cache, dst_cache, src_block_indices, dst_block_indices) classmethod

Copy blocks from src_cache to dst_cache on GPU.

is_fully_connected(physical_device_ids) classmethod

Query if the set of gpus are fully connected by xgmi (1 hop).

prepare_ubatch_streams(device, streams, num_threads) classmethod

Fill torch's hipBLASLt handle pool for the microbatch threads.

hipblasLtCreate clears a new handle's Stream-K flags with a null-stream hipMemset that can land after a GEMM on the comm stream has started, and the GEMM then never finishes. Microbatch threads are new every step and take their per-stream handles from the pool.

set_device(device) classmethod

Set the device for the current platform.

swap_out_blocks_to_host(src_cache, dst_cache, src_block_indices, dst_block_indices) classmethod

Copy blocks from GPU to host (CPU).

_capability_from_gcn_arch(gcn_arch)

Parse (major, minor) from a GCN arch string, mirroring how HIP derives hipDeviceProp_t.major / .minor.

gfx
  • 1-digit major (gfx9xx): "gfx" + M + m + stepping
  • 2-digit major (gfx1xxx): "gfx" + MM + m + stepping

Examples:

gfx90a -> (9, 0) gfx942 -> (9, 4) gfx950 -> (9, 5) gfx1100 -> (11, 0) gfx1101 -> (11, 0) gfx1200 -> (12, 0)

Returns None only when the string is not gfx-prefixed at all (i.e. not a ROCm arch string). Raises on any string that looks like a GCN arch but does not match a known layout.

_get_gcn_arch()

Get GCN arch via amdsmi (no CUDA init), fallback to torch.cuda. Called once at module level; result stored in _GCN_ARCH.

_get_invalid_reasons(backend_class, device_capability, attn_selector_config, *, is_turboquant_run, is_ultraquant_run=False)

Why this backend cannot serve the layer, empty when it can.

_maybe_default_dsv4_mxfp4_indexer(vllm_config)

Default DeepSeek-V4's sparse indexer K cache to MXFP4 on CDNA4.

aiter's paged MXFP4 indexer is faster than FP8 on MI350/MI355 (lower TTFT/TPOT, ~9% more KV cache) with near-lossless accuracy. Only rewrite "auto" and fall back to FP8 silently when the MXFP4 path can't run, so configs that worked before never start failing.

_query_gcn_arch_from_amdsmi()

Query GCN arch from amdsmi. Raises if not available.

_query_total_memory_from_amdsmi(physical_device_id)

Query total VRAM (bytes) from amdsmi. Raises if not available.

_rocm_device_count_stateless(cuda_visible_devices=None) cached

Get number of ROCm devices, caching based on the value of CUDA_VISIBLE_DEVICES at the time of call.

This should be used instead of torch.accelerator.device_count() unless CUDA_VISIBLE_DEVICES has already been set to the desired value.

This can be removed and simply replaced with torch.cuda.get_device_count

after https://github.com/pytorch/pytorch/pull/122815 is released.

_shares_layout_with_turboquant(backend_class)

Whether this backend reads a KV cache layout TURBOQUANT reads too.

A turboquant_* run keeps its boundary layers at the native dtype (see TurboQuantConfig.get_boundary_skip_layers), so those layers pick a backend of their own while every other layer picks TURBOQUANT. One layout has to serve the whole worker, and get_supported_kv_cache_layouts() turns an empty intersection into a hard error at engine startup.

_shares_layout_with_ultraquant(backend_class)

Whether this backend reads a KV cache layout ULTRAQUANT reads too.

Same constraint as _shares_layout_with_turboquant: an ultraquant_4bit run keeps its boundary layers at the native dtype, and one layout has to serve the whole worker.

_sync_hip_cuda_env_vars()

Ensure HIP_VISIBLE_DEVICES and CUDA_VISIBLE_DEVICES are consistent. Treats empty string as unset. Raises on genuine conflicts.

_uses_turboquant(vllm_config)

Whether the run's KV cache dtype is one of the turboquant_* presets.

_uses_ultraquant(vllm_config)

Whether the run's KV cache dtype is the UltraQuant 4-bit format.

get_rocm_version() cached

Return the installed ROCm release as (major, minor, patch), or None.