Skip to content

switch GDN to use attn-gym kernels for titanRL - #4363

Open
liangel-02 wants to merge 1 commit into
mainfrom
gdn_attn_gym
Open

switch GDN to use attn-gym kernels for titanRL#4363
liangel-02 wants to merge 1 commit into
mainfrom
gdn_attn_gym

Conversation

@liangel-02

@liangel-02 liangel-02 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor
Screenshot 2026-08-27 at 11 43 26 PM Screenshot 2026-08-28 at 12 44 59 AM

performance improvements:
Screenshot 2026-08-28 at 6 19 52 PM
Screenshot 2026-08-28 at 6 20 03 PM

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 28, 2026
Comment thread .ci/docker/requirements.txt Outdated
Comment thread torchtitan/experiments/rl/models/gdn.py Outdated
@shuhuayu

Copy link
Copy Markdown
Contributor

question: does this also work on gb gpus only?

@liangel-02

Copy link
Copy Markdown
Contributor Author

@shuhuayu only blackwell

@liangel-02 liangel-02 changed the title [WIP] switch GDN to use attn-gym kernels for titanRL switch GDN to use attn-gym kernels for titanRL Aug 28, 2026
@liangel-02
liangel-02 marked this pull request as ready for review August 28, 2026 16:46
@drisspg

drisspg commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

B200 and B300 to be grace or non grace

Comment thread torchtitan/experiments/rl/models/gdn.py Outdated
Comment thread torchtitan/experiments/rl/models/gdn.py Outdated
@liangel-02
liangel-02 requested a review from drisspg August 28, 2026 21:02
@liangel-02
liangel-02 force-pushed the gdn_attn_gym branch 2 times, most recently from ed38e0d to 15912af Compare August 28, 2026 21:20
Comment thread .ci/docker/requirements.txt Outdated
Comment thread pyproject.toml
Comment thread tests/unit_tests/gpu/test_qwen3_5_deltanet.py Outdated
Comment thread tests/unit_tests/gpu/test_qwen3_5_deltanet.py Outdated
Comment thread tests/unit_tests/gpu/test_qwen3_5_deltanet.py Outdated
Comment thread tests/unit_tests/gpu/test_qwen3_5_deltanet.py Outdated
Comment thread tests/unit_tests/gpu/test_qwen3_5_deltanet.py Outdated
Comment thread torchtitan/experiments/rl/models/gdn.py
Comment thread torchtitan/experiments/rl/models/gdn.py Outdated
Comment thread torchtitan/models/qwen3_5/gdn.py Outdated
@liangel-02
liangel-02 force-pushed the gdn_attn_gym branch 3 times, most recently from 9c2b1d8 to ed345f4 Compare August 28, 2026 22:27
@liangel-02
liangel-02 requested a review from drisspg August 28, 2026 22:38
Comment thread torchtitan/models/qwen3_5/gdn.py Outdated
Comment thread torchtitan/models/qwen3_5/gdn.py Outdated
Comment thread torchtitan/models/qwen3_5/gdn.py Outdated
x=x_TD.unsqueeze(0),
weight=weight.squeeze(1),
bias=None,
del cu_seqlens_cpu

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with attn-gym, do we no longer need this any more? If so let's delete the code that generates it in get_attention_masks

Comment on lines +18 to +22
from attn_gym.linear import (
causal_conv1d as _attn_gym_causal_conv1d,
l2norm as _attn_gym_l2norm,
recurrent_gdn as _attn_gym_recurrent_gdn,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy with removing _attn_gym_ prefix

"the paged convolution history has contiguous channels."
)

self.cache_config.mamba_ssm_cache_dtype = "float32"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be fp32 regardless of batch invariant mode?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without looking into details, I had expected that with attn-gym we can make the code shorter (e.g. we don't need to copy the state cache out -> computation -> put the result back in cache), but it doesn't look like so?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is because we are stilll supporting prefill(chunked) through fla for gdn now; im working on fixing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants