Add sweep for relu2max capped hsnorm peri ln compat#838
Open
klei22 wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new exploration sweep for testing ReLU2Max + Infinite Attention in peri-LN mode using CappedHyperSphereNorm, and extends CappedHyperSphereNorm to optionally apply a learnable gain (to align better with existing HyperSphereNorm configuration patterns).
Changes:
- Add optional
hsnorm_gainsupport toCappedHyperSphereNormso it can apply a learnable per-channel gain. - Add a new YAML sweep (
relu2max_capped_hypersphere_peri_ln.yaml) to compare capped hypersphere norms vs RMSNorm under peri-LN and pre-LN settings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
variations/norm_variations.py |
Extends CappedHyperSphereNorm with optional gain, but currently misses other hsnorm_* behaviors used by the new sweep. |
explorations/relu2max_capped_hypersphere_peri_ln.yaml |
Introduces a new sweep configuration for peri-LN + ReLU2Max + capped hypersphere norms (with a couple of sweep-definition issues to fix). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+212
to
+224
| ndim = config.n_embd | ||
|
|
||
| self.radius = math.sqrt(ndim) | ||
|
|
||
| if config.hsnorm_gain: | ||
| self.gain = nn.Parameter(torch.ones(ndim)) | ||
| else: | ||
| self.gain = 1.0 | ||
|
|
||
| def forward(self, x): | ||
| norms = x.norm(2, dim=-1, keepdim=True) | ||
| scale = torch.where(norms > self.radius, self.radius / (norms + 1e-8), torch.ones_like(norms)) | ||
| return x * scale | ||
| return x * scale * self.gain |
Comment on lines
+67
to
+70
| named_variation_groups: | ||
| - named_group: "wte_norm_var" | ||
| named_group_alternates: ["capped_rmsnorm", "capped_pair", "rmsnorm"] | ||
|
|
Comment on lines
+92
to
+94
| named_group_variations: | ||
| - "wte_norm_var" | ||
| # Peri-LN WTE Norm |
Comment on lines
+107
to
+109
| hsnorm_radius_learning: [true] | ||
| named_group_variations: | ||
| - "wte_norm_var" |
Comment on lines
+120
to
+122
| hsnorm_radius_learning: [true] | ||
| named_group_variations: | ||
| - "wte_norm_var" |
Comment on lines
+83
to
+88
| - "qk_norm" | ||
| - "peri_ln" | ||
| - "rotary" | ||
| - "relu2max" | ||
| - "infinite" | ||
| - "hd_150" |
Comment on lines
+96
to
+101
| - "qk_norm" | ||
| - "peri_ln" | ||
| - "rotary" | ||
| - "relu2max" | ||
| - "infinite" | ||
| - "hd_150" |
Comment on lines
+112
to
+117
| - "qk_norm" | ||
| - "pre_ln" | ||
| - "rotary" | ||
| - "relu2max" | ||
| - "infinite" | ||
| - "hd_150" |
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.
No description provided.