Repository navigation
Adjust RoPE dims for short vs. long context layers #150
Replies: 2 comments
|
I think you have a good approach. Some things to also consider:
I had a similar intuition to yourself a while back and tried some similar tests. At the time I didn't find an improvement on changing from half RoPE, but doing things like splitting out the long and short windows sounds smart. Something else I looked into here was if we could skip all RoPE calculations for the half of the dimensions that are zeroed out. However, I didn't find a formulation that actually ran faster on H100. Though maybe there is something there with the right shaping. I had written some of the RoPE things I looked into here. If you are looking for portions of the model that are undertuned, I would recommend areas that have been disrupted by recent PRs. One example is after the first layer got dropped. Currently the skip connections have an awkward setup and 1 of the 3 value embeds only gets used once. This is an artifact of dropping the first layer and not revisiting all the ways to clean up the architecture. |
|
Ah, fascinating! It's making me realize how shallow of an understanding I have of RoPE. Doing some reading, but not quite there yet. Thanks for the suggestion on the value embeddings. It's a very interesting technique--I'll dig into it / try adjusting if I get a chance. Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
I haven't done the formal run for this yet, but it seems to work and makes some intuitive sense, so I wanted to share what I've found so far and see what people think.
In the current baseline, the model applies RoPE to half the dimensions in a head. I modified it to allow for specifying a specific number of RoPE dimensions, and to specify a different number for the short context vs. long context layers.
A couple interesting things are emerging from my experiments so far. TL;DR - The short context attention layers like position information, and may benefit from more RoPE dims, and the long context layers don't like it and may benefit from fewer RoPE dims.
The below plot shows validation loss vs. training time (instead of steps) to capture both speed and accuracy. This is running on a GH200, and I cut theses runs short at 1,250 out of 2,330 steps.
Light blue is the baseline, which applies RoPE to half the head dims (64 out of 128) for all layers.
Here's what the others show. (Note - In the run names, I write, e.g., r128.32 to indicate 128 RoPE dims on short-context layers and 32-dims on long context)
Below are the baseline (light blue, r64.64) and the teal (r128.32) run to completion, and an additional example (red, r64.32).
Teal increases the step time very slightly, and finishes the 2330 steps slightly later, but still wins because it reaches the baseline's loss ahead of it.
Red decreases the step time by a hair, and also outperforms.
I'll keep playing with it. It seems fairly intuitive, I think, that attention would rely more on position information in a short context window, whereas it may only need some broad strokes in the long context layers.
I was also surprised by how little impact it had on the model to mess with these numbers. It barely registers these differences. (I also did a short run with r48.64, and it also registered as an improvement--inconsistent with my claims above). If the model doesn't care if we take some of this information away, then maybe the heads are too big?
Also, I suspect there may be other modifications we can make which we apply only to the long-context layers. I'm curious if, for example, those layers would prefer a larger number of smaller heads (allowing them to engage a larger number of tokens).
Interesting stuff. I'd welcome any thoughts and suggestions!
All reactions