Repository navigation
[rl] Fix model-specific attention scaling in vLLM - #5347
Conversation
|
|
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
thanks for the pr @haydn-jones! We will review it. If you are using GPT-OSS, there a few things you have to be aware:
Sorry that those are not merged yet. We have been mostly focused on qwen 35B MoE. This model is more optimized and tested if you are interested. Feel free to shoot an email if you want to chat at some point and share more about the work you are doing / features you are looking for [email protected] |
wwwjn
left a comment
There was a problem hiding this comment.
Nice catch, please address nit comments. And maybe add a note
| rope: RoPE.Config | ||
|
|
||
| @property | ||
| def softmax_scale(self) -> float: |
There was a problem hiding this comment.
So if we don't set vllm parameter scale=attention_cfg.softmax_scale,, vllm will use the default property scale that we set here?
There was a problem hiding this comment.
No, the explicit scale=attention_cfg.softmax_scale forwarding is necessary, otherwise the wrapper uses head_dim**-0.5.
| @@ -85,6 +85,7 @@ def _replace_vllm_layer_configs(model_config): | |||
| num_kv_heads=num_kv_heads, | |||
| head_dim=head_dim, | |||
| value_head_dim=value_head_dim, | |||
| scale=attention_cfg.softmax_scale, | |||
There was a problem hiding this comment.
Would this line raise error if a model doesn't have softmax_scale property?
There was a problem hiding this comment.
It's set to return None by default so models without their own override inherit it.
torchtitan/torchtitan/models/common/attention/attention.py
Lines 100 to 111 in b4beb43
1807b70 to
b4beb43
Compare
The vLLM attention replacement does not include model specific softmax scales which makes GPT-OSS and DeepSeek lose their YaRN-adjusted scaling.
I just exposed the scale as a property on the attention config and threaded it through to vLLM. Not sure if this is how you’d want it done.
KL mismatch went from 0.055 before to 0.0006 with GPT-OSS-20b. I didn't test deepseek.