Repository navigation
[ROCm][RDNA] Load and call hippihx V1 from RDNA_ATTN decode (opt-in) - #27
Merged
Merged
Conversation
hippihx (github.com/BlivionIaG/hippihx) owns the RDNA tile contracts and a torch-free C consume ABI (include/hippihx/v1.h, rev 4). This adds the serve half, so the fork can load and call it: - vllm/model_executor/layers/hippihx_v1.py: with VLLM_HIPPIHX=1, dlopen VLLM_HIPPIHX_LIB (libhippihx_v1.so) through hippihx.v1_ctypes, then hippihx_v1_load the current device's hippihx_<arch>.hsaco from VLLM_HIPPIHX_CODE_OBJECT. The load is refused for a wrong-arch object or when HSA_OVERRIDE_GFX_VERSION is set. Plans are cached per op and params, made outside graph capture, and their scratch is zeroed once (256-byte aligned). Run builds V1 tensor descriptors from torch views and passes the current stream. - RDNA_ATTN decode tries attention.fa_fdot2 first and writes straight into `output`. It uses hippihx only when the plan is ready; otherwise fa_rdna2_decode_paged runs exactly as before. - vllm/envs.py: VLLM_HIPPIHX (default off), VLLM_HIPPIHX_LIB, VLLM_HIPPIHX_CODE_OBJECT. No behavior change by default. With the flag on, every hippihx op still plans as not ready until its body migrates, so the extras kernels keep running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YM2kXWFyL3J2Gs4F1oZk7Y Claude-Session: https://claude.ai/code/session_0147zxyqwsKMmBLRn8xgBaHL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Adds the serve half of the hippihx V1 consume ABI, so this fork can load hippihx and call it from the RDNA_ATTN decode path. hippihx owns the RDNA tile contracts and a torch-free C ABI (
include/hippihx/v1.h, rev 4). The change is opt-in and does nothing by default.vllm/model_executor/layers/hippihx_v1.py(new). WithVLLM_HIPPIHX=1, it opensVLLM_HIPPIHX_LIB(libhippihx_v1.so) throughhippihx.v1_ctypes. It then callshippihx_v1_loadwith the current device's arch and itshippihx_<arch>.hsacofromVLLM_HIPPIHX_CODE_OBJECT, which can be the file or its directory. hippihx refuses a wrong-arch object, or any process withHSA_OVERRIDE_GFX_VERSIONset, withERR_FOREIGN_ISA. Plans are cached per op and params and are never created during graph capture. Each plan owns a scratch buffer that is 256-byte aligned and zeroed once. A run builds V1 tensor descriptors from torch views and uses the current stream.vllm/v1/attention/backends/rdna_attn.py. The decode branch (max_seqlen_q <= 1) triesattention.fa_fdot2first and writes straight intooutput. It returns early only when the plan is ready and the run is accepted. Otherwisefa_rdna2_decode_pagedruns exactly as before, with the same arguments.vllm/envs.py:VLLM_HIPPIHX(off by default; only"1"enables it),VLLM_HIPPIHX_LIB,VLLM_HIPPIHX_CODE_OBJECT.What changes today
attention.fa_fdot2ready.CUDA graphs. RDNA_ATTN captures uniform single-token decode in full graphs. Whenever graphs are on, vLLM sets
cudagraph_num_of_warmups = 1and runs each FULL capture's warmup eagerly withforce_attention=True, so hippihx loads and plans outside capture. As a backstop,plan()never creates a plan while the stream is capturing, and that shape keeps the extras kernel.Depends on BlivionIaG/hippihx#25 (commit
51dc4ad). It adds the publichippihx.v1_ctypesandhippihx.v1.find_specthat this module imports, instead ofhippihx._lib. If hippihx is not installed,VLLM_HIPPIHX=1logs a warning and falls back.Not a duplicate. No PR in this repo, open or closed, mentions hippihx. None of the open PRs against
rdna_extrastouch the RDNA_ATTN decode path.AI assistance. This change was written with AI assistance (Claude Code). The human submitter must review every changed line and run the on-hardware check below before this is marked ready.
Test Plan
Host-only (done, see results):
On gfx1030 (V620), still to do before merge:
hippihx:log lines and unchanged output.VLLM_HIPPIHX=1 VLLM_HIPPIHX_LIB=/path/libhippihx_v1.so VLLM_HIPPIHX_CODE_OBJECT=/path/to/hsaco_dir vllm serve ...Expect
hippihx: loaded .../hippihx_gfx1030.hsaco (gfx1030), V1 ABI rev 4.and noplan refusedorrun refusedwarnings. Greedy output should match flag off, because FA is not ready yet and the extras kernel still runs.No model eval is attached. This PR changes no kernel, and output is unchanged with the flag on or off until
attention.fa_fdot2is ready. The hippihx change that flips it ready needs an eval.Test Result
tests/kernels/attention/test_rdna_v1_consume.py: 5 passed, with CPU torch and a host-stub hippihx build. This ran in an earlier session on basecd38a1d, against minimal stand-ins forvllm.envsandvllm.logger, because the full vLLM stack could not be installed in that sandbox. In this rebased version, the new module, the test and therdna_attn.pyhunk are byte-identical to what was tested (same blob hashes).rdna_extrasatbcdaadd. The only conflict was context invllm/envs.py(the rewrittenVLLM_RDNA_ARcomment), resolved by keeping both sides.envs.pyare clean.rdna_attn.pyshows the same two findings (I001import order,SIM103) and the sameruff formatdrift before and after this change.hippihx_v1.py,envs.pyand the test pass. The one error,supported_kv_cache_dtypestyping inrdna_attn.py, reproduces on the base branch.envs.pyevaluated standalone:VLLM_HIPPIHXdefaults off, only"1"enables it, and both path variables pass through.Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.🤖 Generated with Claude Code
https://claude.ai/code/session_0147zxyqwsKMmBLRn8xgBaHL
Generated by Claude Code