Skip to content

kimi k3 for titanrl - #4680

Merged
liangel-02 merged 1 commit into
mainfrom
kda_titanrl
Oct 2, 2026
Merged

liangel-02 merged 1 commit into
mainfrom
kda_titanrl

Conversation

@liangel-02

@liangel-02 liangel-02 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

as title, add titanrl support for k3. for batch invariant mode, use chunked replay kernel (cudagraph friendly and paging aware) we match decode to prefill instead of prefill to decode since its faster

batch invariant bitwise parity passes
verified 0 logprob diffs
Screenshot 2026-09-14 at 3 12 41 PM

Screenshot 2026-09-18 at 5 50 52 PM

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 14, 2026
@liangel-02 liangel-02 changed the title [WIP] kda in torchtitan (vllm integration) kimi k3 for titanrl Sep 14, 2026
@liangel-02
liangel-02 marked this pull request as ready for review September 14, 2026 20:55
@liangel-02
liangel-02 marked this pull request as draft September 15, 2026 21:47
@liangel-02
liangel-02 force-pushed the kda_titanrl branch 5 times, most recently from 05f609e to 9e08af8 Compare September 21, 2026 21:07

with spmd.no_typecheck(), torch.no_grad():
if padding_mask_T is not None:
valid_mask_T = ~padding_mask_T

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this was breaking cudagraphs for k3

@liangel-02
liangel-02 force-pushed the kda_titanrl branch 3 times, most recently from ef0634e to 1ae229a Compare September 21, 2026 21:18
@liangel-02
liangel-02 marked this pull request as ready for review September 21, 2026 21:19
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Sep 21, 2026
@felipemello1

Copy link
Copy Markdown
Contributor

This is awesome! thank you! Can you please run it for DAPO math for at least 50 steps and show improvement in the rewards? i guess you cannot do it in single node, right? we have the mast launcher. I would recommend something around 2 or 3 generators for 1 trainer node ratio. If you can run for 150 steps, thats better. It should be straight forward for claude/codex to adapt the dapo math 8k config we have for qwen 3.5. I would prefer to have this as our default rather than alphabetsort, if you dont mind, and publish the reward curve in some .md.

Comment thread tests/integration_tests/rl.py Resolved
Comment thread tests/rl/integration_tests/rl.py Outdated
disabled=not (
torch.cuda.is_available()
and torch.version.hip is None
and torch.cuda.get_device_capability() in ((10, 0), (10, 3))

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 should run in B200 CI machine -- could you work with @wwwjn on that

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.

Also curious which part of this Kimi K3 RL requires Blackwell specifically?

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.

could you answer this?

Comment thread torchtitan/models/kimi_k3/kda.py Resolved
Comment thread torchtitan/models/kimi_k3/model.py Resolved
Comment thread torchtitan/models/kimi_k3/kda.py Resolved
Comment thread torchtitan/rl/model/vllm_wrapper.py Resolved
Comment thread torchtitan/rl/model/vllm_registry.py Resolved
Comment thread torchtitan/rl/model/vllm_registry.py Resolved
Comment thread torchtitan/rl/model/vllm_registry.py Resolved
Comment thread torchtitan/rl/model/kda_attention.py Outdated
MambaStateDtypeCalculator,
MambaStateShapeCalculator,
)
from vllm.v1.attention.backends.gdn_attn import GDNAttentionMetadata

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.

@acisseJZhong we can call ours xxxAttentionMetadata as well

@liangel-02
liangel-02 force-pushed the kda_titanrl branch 4 times, most recently from 5dc37ef to 8db7f50 Compare September 23, 2026 21:13
@liangel-02
liangel-02 force-pushed the kda_titanrl branch 2 times, most recently from b8fc770 to 5849df5 Compare September 29, 2026 23:05
Comment thread tests/assets/losses/rl_grpo_cuda.txt Resolved
Comment thread tests/rl/integration_tests/rl.py Resolved
Comment thread torchtitan/rl/README.md Resolved
Comment thread tests/rl/integration_tests/rl.py Outdated
disabled=not (
torch.cuda.is_available()
and torch.version.hip is None
and torch.cuda.get_device_capability() in ((10, 0), (10, 3))

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.

could you answer this?

@liangel-02
liangel-02 force-pushed the kda_titanrl branch 7 times, most recently from 0c7f4f6 to 68ba177 Compare October 1, 2026 21:13
@liangel-02 liangel-02 added the ciflow/h100.8 Trigger H100.8 CI label Oct 1, 2026
Comment thread tests/assets/losses/rl_grpo_cuda.txt Resolved
_batch_invariant_extra_lib = torch.library.Library("aten", "IMPL")
_batch_invariant_extra_lib.impl(
"aten::sum.dim_IntList",
_sum_dim_batch_invariant,

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.

curious -- is this faster or slower than before, on the previously hit kernels

@liangel-02
liangel-02 force-pushed the kda_titanrl branch 6 times, most recently from f398d80 to a0cd77d Compare October 2, 2026 17:34
@liangel-02
liangel-02 merged commit 4b0aae7 into main Oct 2, 2026
wwwjn added a commit that referenced this pull request Nov 10, 2026
The Model support table in torchtitan/rl/README.md lags behind main and the
image RL stack:

- DeepSeek V3 ("Not supported") and Kimi K3 ("Support coming soon") have run
  RL end to end in CI since #5556 and #4680: `rl_grpo_deepseek_v3_debug` and
  `rl_grpo_kimi_k3_debug_batch_invariant` in the RL H100 Integration Tests
  (3 steps, debug model, trainer FSDP=2, two generators at TP=1, no EP). Their
  MLA decode and KDA kernels need SM90+, so both rows say "SM90+", and the
  intro says how they were tested.
- Muse Spark and Qwen 3.5/3.6/3.8 ("text only") run image prompts end to end:
  `rl_grpo_qwen3_5_0_8b_geometry3k` (Qwen3.5-0.8B, Geometry3K, #5825) and
  `rl_muse_spark_816b_a42b_slake_lora_gb300` (Muse Spark 816B-A42B, SLAKE).
  Qwen 3.6 and 3.8 build `Qwen35Model` and share Qwen3.5's vision processor
  config, so they take the same image path.
- The CI table gets the RL H100 Integration Tests badge, the workflow that
  runs the DeepSeek V3 and Kimi K3 tests.

Unchanged: GPT-OSS (supported), DeepSeek V4 (no RL code yet), FLUX (diffusion,
no generator path), Kimi K2.7 (no RL recipe or test).
wwwjn added a commit that referenced this pull request Nov 10, 2026
The Model support table in torchtitan/rl/README.md lags behind main and the
image RL stack:

- DeepSeek V3 ("Not supported") and Kimi K3 ("Support coming soon") have run
  RL end to end in CI since #5556 and #4680: `rl_grpo_deepseek_v3_debug` and
  `rl_grpo_kimi_k3_debug_batch_invariant` in the RL H100 Integration Tests
  (3 steps, debug model, trainer FSDP=2, two generators at TP=1, no EP). Their
  MLA decode and KDA kernels need SM90+, so both rows say "SM90+", and the
  intro says how they were tested.
- Muse Spark and Qwen 3.5/3.6/3.8 ("text only") run image prompts end to end:
  `rl_grpo_qwen3_5_0_8b_geometry3k` (Qwen3.5-0.8B, Geometry3K, #5825) and
  `rl_muse_spark_816b_a42b_slake_lora_gb300` (Muse Spark 816B-A42B, SLAKE).
  Qwen 3.6 and 3.8 build `Qwen35Model` and share Qwen3.5's vision processor
  config, so they take the same image path.
- The CI table gets the RL H100 Integration Tests badge, the workflow that
  runs the DeepSeek V3 and Kimi K3 tests.

Unchanged: GPT-OSS (supported), DeepSeek V4 (no RL code yet), FLUX (diffusion,
no generator path), Kimi K2.7 (no RL recipe or test).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/b200 Trigger B200 CI ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/h100.8 Trigger H100.8 CI 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.

5 participants