Repository navigation
fix sdpa-varlen attention mismatch in qwen3 - #2229
Conversation
liangel-02
left a comment
There was a problem hiding this comment.
thanks for fixing this :)) do you mind:
- adding the same fix for the llama 3 model https://github.com/pytorch/torchtitan/blob/main/torchtitan/models/llama3/model/model.py#L299-L301
- can you verify that loss is on par for both models with flex (ss of graphs in the PR summary)? you can run smth like
CONFIG_FILE="./torchtitan/models/qwen3/train_configs/qwen3_1.7b.toml" ./run_train.shand setenable_tensorboard = Truehere
|
@liangel-02 no problem at all. Thank you for your work on this repo. I should be able to commit something tomorrow. |
|
Hello @liangel-02, I’ve applied the same fix to the LLaMA-3 model. I also added a test to verify that the forward pass of LLaMA-3 attention behaves identically for the flex and varlen backends. Additionally, I ran ablation experiments using sub-1B models for 300 steps. The results appear to be close to the expected behavior, as shown below: |
tianyu-l
left a comment
There was a problem hiding this comment.
Loss difference seems too large. Could you try fixing the seed across runs? https://github.com/pytorch/torchtitan/blob/main/docs/debugging.md#seed-configuration
| hidden_dim = 512, | ||
| attn_type = "sdpa" | ||
| ), | ||
| ).to(device="cuda:0", dtype=dtype) |
There was a problem hiding this comment.
btw: our CI cannot run unit test on GPU, it's CPU only right now.
There was a problem hiding this comment.
Should I remove those tests? I can also do something like if no gpu available: return
There was a problem hiding this comment.
If it's not guarded by CI, it's better to remove them. In the future we should make torchtitan test more flexible, but for now showing results before vs. after the change in PR summary should be good.
@francesco-bertolotti
cc @drisspg |
|
Hi @liangel-02,
|







Fix for #2223