Repository navigation
add olmo3 models - #3966
Closed
ruisizhang123 wants to merge 3 commits into
Closed
add olmo3 models#3966ruisizhang123 wants to merge 3 commits into
ruisizhang123 wants to merge 3 commits into
Conversation
ruisizhang123
requested review from
fegin,
tianyu-l,
wconstab and
wwwjn
as code owners
July 22, 2026 00:32
This was referenced Jul 22, 2026
Closed
ruisizhang123
marked this pull request as draft
July 22, 2026 00:40
fegin
pushed a commit
that referenced
this pull request
Jul 24, 2026
Context parallelism's PTRR load balancer previously rejected any model whose attention masks are provided as a dict of named masks, since the balancer can only be built from a single mask. Models like GPT-OSS or Olmo3 (#3966) with flex attention legitimately produce multiple masks (e.g. a full-causal mask plus a sliding-window mask), so PTRR was unusable for them. This adds a configuration option letting the user name which mask in the dict PTRR should build its balancer from. The resulting balancer is then used to shard every mask in the dict as well as the inputs. When the masks are a dict but no key is specified (or the key is invalid), we fail loudly and list the available keys instead of silently guessing. For example, ``` --parallelism.context-parallel-load-balancer ptrr --parallelism.context-parallel-ptrr-mask-key basic_mask ``` would allow the user to choose `attention_masks["basic_mask"]` to use as load balancing decision in PTRR. ## Justification: Consider the models like GPT-OSS or Olmo3, that alternates between sliding window and global causal mask. For example, say the input sequence consists of documents of length [4, 8] and sliding window size is 3. ``` global causal mask work per row relative order (decreasing) [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] -> 1 11 [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] -> 2 9 [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] -> 3 7 [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0] -> 4 5 [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] -> 1 11 [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0] -> 2 9 [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0] -> 3 7 [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0] -> 4 5 [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0] -> 5 4 [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0] -> 6 3 [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0] -> 7 2 [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1] -> 8 1 ``` ``` sliding window mask work per row [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] -> 1 [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] -> 2 [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] -> 2 [0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0] -> 2 [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] -> 1 [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0] -> 2 [0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0] -> 2 [0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0] -> 2 [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0] -> 2 [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0] -> 2 [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0] -> 2 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] -> 2 ``` Suppose we apply the global causal mask after every $k$ application of the sliding window mask. Then, a reasonable cost model for work for a row $r$ is $c_r := k c_r^s + c_r^g$ where $c_r^s$ is the cost for row $r$ for sliding window mask and $c_r^g$ is the cost for row $r$ for global causal mask. For a concrete example, let $k = 3$ as in the case of Olmo 3. ``` combined cost work per row relative order (decreasing) [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] -> 1 + 3 = 4 11 [4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] -> 2 + 6 = 8 9 [1, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0] -> 3 + 6 = 9 7 [1, 1, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0] -> 4 + 6 = 10 5 [0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0] -> 1 + 3 = 4 11 [0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0] -> 2 + 6 = 8 9 [0, 0, 0, 0, 1, 4, 4, 0, 0, 0, 0, 0] -> 3 + 6 = 9 7 [0, 0, 0, 0, 1, 1, 4, 4, 0, 0, 0, 0] -> 4 + 6 = 10 5 [0, 0, 0, 0, 1, 1, 1, 4, 4, 0, 0, 0] -> 5 + 6 = 11 4 [0, 0, 0, 0, 1, 1, 1, 1, 4, 4, 0, 0] -> 6 + 6 = 12 3 [0, 0, 0, 0, 1, 1, 1, 1, 1, 4, 4, 0] -> 7 + 6 = 13 2 [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 4, 4] -> 8 + 6 = 14 1 ``` Note that the relative order of $(c_r)$ is same as the relative order of $(c_r^g)$. One can show this holds true in general when we take a weighted combination of a global causal mask and a sliding window mask. This means that if we use a sorting based load balancing algorithm such as PTRR on the costs $(c_r^g)$ or $(c_r)$, we get the same output. Therefore, it may be reasonable to give the user a choice to still use PTRR when there are multiple masks present in the model. Test Plan: Loss decreases in a similarly, though not identically, in running ``` MODULE=gpt_oss CONFIG=gpt_oss_debugmodel_flex ./run_train.sh --parallelism.context-parallel-degree 2 ``` and ``` MODULE=gpt_oss CONFIG=gpt_oss_debugmodel_flex ./run_train.sh --parallelism.context-parallel-degree 2 --parallelism.context-parallel-load-balancer ptrr --parallelism.context-parallel-ptrr-mask-key basic_mask ``` Also, tested in `tests/integration_tests/model.py`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):