Skip to content

test: add block-level GPT-OSS attention test (real OAIAttention) - #1402

Open
carlushuang wants to merge 3 commits into
mainfrom
carhuang/gptoss-attn-block-test
Open

carlushuang wants to merge 3 commits into
mainfrom
carhuang/gptoss-attn-block-test

Conversation

@carlushuang

Copy link
Copy Markdown
Collaborator

Adds tests/block/test_attention_block_gptoss.py: a block-level test that drives the real OAIAttention module end to end (qkv_proj → RoPE + paged KV write → attention with per-head sinks + alternating sliding window + GQA → o_proj), checked against a pure-torch reference.

Unlike a per-kernel op test, this exercises ATOM's actual attention module and its arch dispatch (PagedAttentionImpl). It runs without a ModelRunner: it inits TP=1, sets a minimal current atom config, instantiates OAIAttention, allocates the paged KV cache, builds the ForwardContext (attn metadata + kv_cache_data + Context) by hand, then calls forward.

Coverage: prefill + decode, sliding-window (even) and causal (odd) layers, bf16 and fp8 KV, and both arch backends via --backend {auto,asm,triton} — asm (flash_attn_varlen + pa_decode_gluon, gfx942/gfx950) and triton (unified_attention, portable). auto selects triton on gfx1250, else asm.

Test

Standalone runner (not pytest; it needs the real atom.* modules and a GPU, which the unit-test conftest stubs out):

python3 tests/block/test_attention_block_gptoss.py --phase both --layer both
python3 tests/block/test_attention_block_gptoss.py --backend triton --kv-cache-dtype fp8

Validated on MI355X (gfx950), asm + triton backends, bf16 + fp8 KV — all prefill/decode × sliding-window/causal configs pass; black + ruff clean.

Add tests/block/test_attention_block_gptoss.py: a standalone block-level test
that drives the real OAIAttention module end to end (qkv_proj -> RoPE + paged KV
write -> attention with per-head sinks + alternating sliding window + GQA ->
o_proj), validated against a pure-torch reference.

Runs without a ModelRunner: inits TP=1, sets a minimal current atom config,
instantiates OAIAttention, allocates the paged KV cache, builds the
ForwardContext (attn metadata + kv_cache_data + Context) by hand, and calls
forward. Covers prefill + decode, sliding-window (even) and causal (odd) layers,
bf16 and fp8 KV, and both arch backends: asm (flash_attn_varlen + pa_decode_gluon,
gfx942/gfx950) and triton (unified_attention, portable). --backend auto picks
triton on gfx1250, else asm.

Validated on gfx950 (asm + triton, bf16 + fp8).
Add a --sweep mode to the GPT-OSS attention block test: prefill (batch 1,
latency + correctness) plus a real per-step decode at each --conc (default
1,16,64,128,256,512) over a pre-filled ctx=input+output cache (latency only),
at --sweep-io input/output (default 8192/1024). Drives the real OAIAttention
module; works for both --backend {asm,triton} and bf16/fp8 KV.

This branch has not been deployed

No deployments
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