Repository navigation
[Bugfix] Drop arch env vars from the JIT cache key (fix AOT cache misses) - #624
Merged
Merged
Conversation
…ses) The hardened cache key (#597) folds whitelisted code-gen env vars into the key via _cache_invalidating_env_values(). Among them, ARCH / FLYDSL_GPU_ARCH / HSA_OVERRIDE_GFX_VERSION are pure arch selectors whose only effect is to pick the target arch -- which is already in the key via ("_target_", GPUTarget). Keeping them double-counts arch and, worse, makes the key depend on *how* arch was supplied: AOT pre-compilation on a GPU-less build host injects ARCH=<gfxNNN> via env, while at runtime those vars are unset and arch comes from the device. detect_target() normalizes both paths to the same GPUTarget, but the raw "_env_" segment diverges ("gfx950" vs ""), so an AOT-precompiled-then-shipped cache can never be hit at runtime -- surfacing downstream (e.g. aiter's strict check_aot_cache MoE tests) as "AOT cache miss" despite the cache being present. Drop the three arch selectors from _CACHE_INVALIDATING_ENV_VARS. No key precision is lost: any arch change still changes ("_target_", ...). Genuine code-gen knobs (opt level, backend, llvm dir, debug info, extra source dirs) stay in the key. Existing tests are unaffected: the arch-drift test asserts the change flows through ("_target_", ...) (it resets _sig and checks t.arch), and the env-drift tests use FLYDSL_COMPILE_OPT_LEVEL. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
coderfeli
added a commit
to ROCm/aiter
that referenced
this pull request
Jun 2, 2026
FlyDSL 0.2 (ROCm/FlyDSL#597) renamed JitFunction._make_cache_key to _build_full_cache_key. The AOT cache-miss reporter called the old name, which now raises (swallowed) and prints "looked-up cache_key: <unknown>". Use getattr with a fallback so the diagnostic works on both 0.1.x and 0.2.x. Diagnostic-only; the actual AOT cache hit/miss is fixed on the FlyDSL side (ROCm/FlyDSL#624). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 task done
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.
Motivation
After #597 hardened the JIT cache key to fold whitelisted code-gen env vars into the key, AOT-precompiled-then-shipped caches stopped being hit at runtime. This surfaces downstream in aiter as
RuntimeError: AOT cache missfor FlyDSL MoE kernels under its strictcheck_aot_cache=Truetests (the cache dir is present with the rightmanager_key, but the inner key never matches).Root cause
_cache_invalidating_env_values()folds these arch selectors into the key:ARCH,FLYDSL_GPU_ARCH,HSA_OVERRIDE_GFX_VERSION. Their only effect is to pick the target arch — which is already in the key via("_target_", GPUTarget).The arch can be supplied two ways, and
detect_target()normalizes both to the sameGPUTarget:ARCH=gfx950/FLYDSL_GPU_ARCH=gfx950via env.So the resolved
("_target_", GPUTarget(arch="gfx950", ...))is identical in both, but the raw("_env_", (... "ARCH"="gfx950"/"" ...))segment diverges ("gfx950"at build vs""at runtime) → cache key mismatch → guaranteed miss for any shipped AOT cache.Fix
Drop the three arch selectors from
_CACHE_INVALIDATING_ENV_VARS. No key precision is lost — any arch change still changes("_target_", ...). Genuine code-gen knobs (FLYDSL_COMPILE_OPT_LEVEL,FLYDSL_COMPILE_BACKEND,FLYDSL_COMPILE_LLVM_DIR,FLYDSL_DEBUG_ENABLE_DEBUG_INFO,FLYDSL_EXTRA_SOURCE_DIRS) stay in the key.Tests
Existing cache-key tests are unaffected:
test_compile_hints.py::test_different_arch_gives_different_keyasserts the change flows through("_target_", ...)(it resets_sigand checkst1.arch != t2.arch) — still holds, since ARCH still feedsdetect_target().test_jit_cache_key_completeness.pyenv-drift tests useFLYDSL_COMPILE_OPT_LEVEL(retained).Follow-up note
FLYDSL_COMPILE_LLVM_DIR/FLYDSL_EXTRA_SOURCE_DIRSare path-like and could similarly diverge build-vs-runtime for shipped AOT caches; they're kept here because their contents can affect codegen. A more robust long-term approach would key on their effect (e.g. resolved LLVM version / source content hash) rather than the raw path string. Out of scope for this fix.🤖 Generated with Claude Code