Skip to content

[FIX] Fix atom_set_value signature mismatch and ROCDL compat - #381

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

[FIX] Fix atom_set_value signature mismatch and ROCDL compat#381
coderfeli wants to merge 2 commits into
mainfrom
fix/atom-set-value-and-rocdl-compat

Conversation

@coderfeli

Copy link
Copy Markdown
Collaborator

Summary

Two fixes for issues discovered while integrating FlyDSL fused RoPE kernel into AITER:

1. atom_set_value signature mismatch (primitive.py)

Commit #377 changed atom_set_value to call fly.atom_set_value(atom, field, value), but the ODS-generated binding still expects (result, atom, field, value). Additionally, the field string must be wrapped in ir.StringAttr for the MLIR op to accept it.

This breaks any kernel using copy_atom.set_value("soffset", ...), including the fused RoPE+KV cache kernel.

2. Missing ROCDL ops (rocdl/__init__.py)

cluster_workgroup_id_{x,y,z} are referenced at module level but not present in the current LLVM ROCDL dialect, causing NameError on import. Changed to globals().get() to make them optional, matching the pattern used for wmma_scale_f32_*.

Test

PYTHONPATH=./ pytest tests/kernels/test_fused_rope_cache.py -v -s

🤖 Generated with Claude Code

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>
coderfeli added a commit to ROCm/aiter that referenced this pull request Apr 11, 2026
Add FlyDSL-based `fused_qk_rope_reshape_and_cache` as a drop-in replacement
for the Triton version, with automatic Triton fallback for unsupported features
(GPT-J rotation, offsets, KV scaling, zeros output, full-dim cos/sin).

## Performance

**1.45x average speedup** over Triton across LLM model configs:
- Llama-3.1-8B/70B/405B (TP1, TP8) decode + prefill
- Qwen3-72B (TP8) decode

## Validation

Tests aligned with Triton `test_fused_qk_rope_reshape_and_cache`:
- Same input generation (`generate_rope_inputs`) and reference (`ref_rope_sbhd_fwd`)
- Same tolerance (atol=0.1, rtol=0.1)
- Same KV cache validation (slots + full tensor)
- 66 test cases: Category A (direct kernel) + Category B (wrapper fallback)

## Changes (5 files, +1141 lines)
- `aiter/ops/flydsl/rope_kernels.py` — wrapper with auto Triton fallback
- `aiter/ops/flydsl/kernels/fused_rope_cache_kernel.py` — vendored FlyDSL kernel
- `aiter/ops/flydsl/__init__.py` — export
- `op_tests/flydsl_tests/test_flydsl_rope.py` — tests
- `pyproject.toml` — flydsl >= 0.1.3

## Dependencies
- FlyDSL >= 0.1.3 with ROCm/FlyDSL#381 fix

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderfeli
coderfeli force-pushed the fix/atom-set-value-and-rocdl-compat branch from abd1ef0 to efe49c2 Compare April 11, 2026 02:39
@coderfeli coderfeli closed this Apr 11, 2026
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