Repository navigation
fix(rocm): key the HIP JIT cache by the gfx target (#4815) - #4826
Merged
Merged
Conversation
This was referenced Nov 17, 2026
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.
Fixes #4815.
TorchOpsJitExtension._cache_fingerprint()->_cuda_cache_fingerprint_payload()covered only CUDA inputs:
TORCH_CUDA_ARCH_LIST(hipcc ignores it),torch.cuda.get_device_capability()(coarse on ROCm: gfx1201/gfx1200 both(12,0), gfx90a/gfx908 both(9,0)), andresolved_cuda_arch_flags()(empty onROCm).
PYTORCH_ROCM_ARCHand the devicegcnArchName— the values that pickhipcc's code objects — were missing, so a HIP binary built for one gfx target was
reused on another and every launch failed with
invalid device function.Change
_cuda_cache_fingerprint_payload()branches ontorch.version.hipfirst andreturns
["cuda_ext=1", "hip=<version>", "rocm_arch_list=<targets>"]:PYTORCH_ROCM_ARCHwins; split the way torch does, trimmed/lowercased,deduped and sorted so ordering/spacing cannot fork the cache.
gcnArchNameof visible devices(
utils.arch.normalize_arch), mirroring torch's_get_rocm_arch_flags.get_device_capability()on ROCm;rocm_arch_list=nonewhen no target isavailable.
The CUDA path is untouched (only reached when
torch.version.hipis falsy), soexisting CUDA cache keys are byte-identical — pinned by golden tests.
Tests
New
tests/test_hip_jit_cache_target_4815.py(CPU-only, no ROCm hardware):env change -> different key (gfx1200 vs gfx1201); same value reordered/spaced/
uppercased -> same key; HIP version in the key;
TORCH_CUDA_ARCH_LISTdoes notmask the gfx target; unset env -> sorted suffix-stripped device
gcnArchName;two-machine NFS scenario differs; no GPU -> stable
rocm_arch_list=none;non-HIP payload goldens unchanged.
The failure (
test_exllamav3_import_does_not_set_arch_list_env) is pre-existingand environmental: its subprocess fakes 2 GPUs on a 1-GPU host, so torchao's
triton probe raises before reaching the changed code; it fails identically on
the parent commit.
Red on parent (source reverted, test kept): 7 failed, 2 passed — the env value
was ignored, HIP version was not in the key, and the payload had no ROCm target.
ruff: clean.