Skip to content

[FIX] Support AOT cross-compilation with COMPILE_ONLY cache save - #382

Closed
coderfeli wants to merge 3 commits into
mainfrom
fix/atom-set-value-and-rocdl-compat
Closed

[FIX] Support AOT cross-compilation with COMPILE_ONLY cache save#382
coderfeli wants to merge 3 commits into
mainfrom
fix/atom-set-value-and-rocdl-compat

Conversation

@coderfeli

Copy link
Copy Markdown
Collaborator

Summary

  • COMPILE_ONLY cache save: Move COMPILE_ONLY return after cache_manager.set() so pkl is actually persisted to disk. Previously COMPILE_ONLY=1 returned before saving, making AOT pre-compilation useless.
  • Cross-arch compilation: Remove address space check in DLTensorAdaptor.buildMemRefDesc() to allow CPU tensor tracing. This enables COMPILE_ONLY=1 ARCH=gfx950 on a gfx942 host (or any machine with LLVM AMDGPU backend).

Usage

# AOT compile for gfx942 and gfx950 (CPU tensors, no kernel execution)
COMPILE_ONLY=1 ARCH=gfx942 python aot_compile.py
COMPILE_ONLY=1 ARCH=gfx950 python aot_compile.py

# Deploy: copy ~/.flydsl/cache/ to target machine, kernels load from cache (~28ms vs ~1000ms compile)

Test plan

  • COMPILE_ONLY=1 + CPU tensors → pkl produced (232KB)
  • Load pkl on GPU → correct results (max_diff=0.25)
  • Normal GPU JIT (no cache) → no regression
  • Cross-arch: compile gfx942 + gfx950 → separate cache dirs
  • Normal mode + CPU tensor → still rejected at runtime (hipModuleLaunchKernel will fault)

🤖 Generated with Claude Code

coderfeli and others added 3 commits April 11, 2026 00:58
Two fixes:

1. primitive.py: atom_set_value() was calling fly.atom_set_value(atom, field, value)
   but the ODS-generated binding expects (result, atom, field, value). Also, the
   field string must be wrapped in StringAttr for the MLIR op to accept it.
   This broke any kernel using copy_atom.set_value("soffset", ...) — including
   the fused RoPE+KV cache kernel introduced in #377.

2. rocdl/__init__.py: cluster_workgroup_id_{x,y,z} are not present in the
   current LLVM ROCDL dialect, causing NameError on import. Use globals().get()
   to make them optional, matching the pattern used for other optional ops.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move COMPILE_ONLY return after cache save so pkl is persisted
- Remove address space check in DLTensorAdaptor to allow CPU tensor
  tracing for cross-arch compilation (e.g. ARCH=gfx950 on gfx942 host)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderfeli coderfeli closed this Apr 11, 2026
@coderfeli
coderfeli deleted the fix/atom-set-value-and-rocdl-compat branch April 11, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant