Repository navigation
RoPE: build grown caches on the GPU again, 32768 rows at a time - #14206
Merged
Merged
Conversation
The first lazily built cache was computed on CPU even when the first forward had already grown the size past 4 * 8192 rows (every 128K+ context model). That took 0.15-1.6 s on the first forward and rounded cos/sin differently from every earlier release. Grown sizes are computed on inv_freq's device again, as the eager extend_rope_embedding did, and the starting size stays on CPU. The build fills the output 32768 rows at a time, so the fp32 temporaries no longer scale with max_position_embeddings; rows are bit-identical to the one-shot build.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Summary
#13976 made the RoPE cache lazy and built the first cache on CPU, even when the first forward had already grown it past 4 * 8192 rows. That happens on every model with more than 32K positions (
max_position_embeddings), e.g. any 128K-context model. Two effects on the default path compared with the last release, which built grown caches on the GPU:Grown sizes are built on
inv_freq's device again, as the eagerextend_rope_embeddingdid; the starting size is still built on CPU, as the eager__init__did. The build now fills the output 32768 rows at a time, so its fp32 temporaries no longer scale with the cache size. Rows are bit-identical to the one-shot build.Measured on one B200 (last release / main / this PR):
position_ids)The larger cache when
position_idsare passed (generation prefill, packing) is the out-of-bounds fix from #13976 and is kept; its test still passes. The cache is still built only on the GPU that uses it.Tests
tests/test_rope_cache_current_device.py: the newtest_first_grown_cache_is_computed_on_inv_freq_devicefails on main and passes here; it replaces the test that asserted the CPU build. Six chunk-equality tests are added and pass on both. 24 passed.Not covered here