Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions explorations/all_activations_default_inf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# all_activations_default_inf.yaml
# Based on explorations/default_inf.yaml, but sweeps MLP activation variants.
---

named_static_groups:
# QK Norm
- named_group: "qk_norm"
use_qk_norm: [true]
use_qk_norm_scale: [true]

# Norm Type
- named_group: "peri_ln"
use_pre_ln: [true]
use_peri_ln: [true]
use_post_ln: [false]

# Position Embeddings
- named_group: "rotary"
use_rotary_embeddings: [true]
use_abs_pos_embeddings: [false]

# Attention Softmax
- named_group: "softmax"
softmax_variant_attn: ["softmax"]

# Infinite Attention
- named_group: "infinite"
attention_variant: ["infinite"]
use_concat_heads: [true]

# MQA
- named_group: "mqa"
n_kv_group: [1]

# Head Dimension
- named_group: "hd_100"
n_qk_head_dim: [100]
n_v_head_dim: [100]

common_group:
dataset: ["minipile"]
eval_interval: [2500]
max_iters: [10000]
never_save_checkpoint: [true]
compile: [true]
log_rankme: [true]
log_areq: [true]

# Parameters needed by activation implementations that read config fields directly.
relu_power: [2.0]
shifted_gelu_learnable_shift: [true]
shifted_gelu_initial_shift: [0.0]
softshrink_lambda: [0.5]
pla_num_points: [7]
pla_left_bound: [-2.0]
pla_right_bound: [2.0]
pfla_num_points: [50]
pfla_left_bound: [-10.0]
pfla_right_bound: [10.0]
lsa_num_knots: [30]

parameter_groups:
- named_group_static:
- "qk_norm"
- "peri_ln"
- "rotary"
- "softmax"
- "infinite"
- "mqa"
- "hd_100"
activation_variant:
- "celu"
- "elu"
- "gelu"
- "gelu_shifted"
- "glu"
- "leaky_relu"
- "learned_spline"
- "mish"
- "mish_custom"
- "piecewise"
- "pfla"
- "pfla_le"
- "prelu"
- "relu"
- "relu_power"
- "relu6"
- "rrelu"
- "disco"
- "selu"
- "sigmoid"
- "silu"
- "dsilu"
- "softplus"
- "softsign"
- "softshrink"
- "squared_relu"
- "squared_gelu"
- "tanh"
- "identity"
2 changes: 2 additions & 0 deletions train_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ def parse_args():
"leaky_relu",
"learned_spline",
"mish",
"mish_custom",
"piecewise",
"pfla",
"pfla_le",
Expand All @@ -827,6 +828,7 @@ def parse_args():
"selu",
"sigmoid",
"silu",
"dsilu",
"softplus",
"softsign",
"softshrink",
Expand Down
25 changes: 25 additions & 0 deletions variations/activation_variations.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ def forward(self, x):
# Apply the shifted GELU activation
return self.gelu(x - self.shift)

class dSiLU(nn.Module):
"""
Derivative of SiLU:
d/dx[x * sigmoid(x)] = sigmoid(x) * (1 + x * (1 - sigmoid(x)))
"""
def __init__(self, config):
super().__init__()

def forward(self, x):
sig = torch.sigmoid(x)
return sig * (1 + x * (1 - sig))

Comment on lines +54 to +65

Copilot AI Apr 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class name dSiLU starts with a lowercase letter, which is inconsistent with the other activation modules in this file (e.g., SquaredReLU, GELUShifted) and with typical CapWords class naming. Renaming to DSiLU would improve readability and consistency (the registry key can remain "dsilu").

Copilot uses AI. Check for mistakes.

class Mish(nn.Module):
"""
Mish activation: x * tanh(softplus(x)).
"""
def __init__(self, config):
super().__init__()

def forward(self, x):
return x * torch.tanh(torch.nn.functional.softplus(x))
Comment on lines +67 to +75

Copilot AI Apr 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new custom Mish implementation is introduced as a class named Mish, while the file already contains Mish_Config (wrapping nn.Mish) and PyTorch also exposes nn.Mish. This makes it easy to confuse the built-in Mish with the custom one when reading logs/stack traces. Consider renaming the custom module to something like MishCustom (or similar) and updating the registry entry accordingly.

Copilot uses AI. Check for mistakes.


class PiecewiseLearnableActivation(nn.Module):
def __init__(self, config):
Expand Down Expand Up @@ -349,6 +372,7 @@ def __init__(self, config=None):
"glu": GLU_Config,
"leaky_relu": LeakyReLU_Config,
"mish": Mish_Config,
"mish_custom": Mish,
"piecewise": PiecewiseLearnableActivation,
"pfla": PiecewiseFullyLearnableActivation,
"pfla_le": PiecewiseFullyLearnableActivationLearnedEnds,
Expand All @@ -361,6 +385,7 @@ def __init__(self, config=None):
"selu": SELU_Config,
"sigmoid": Sigmoid_Config,
"silu": SiLU_Config,
"dsilu": dSiLU,
"softplus": Softplus_Config,
Comment on lines 372 to 389

Copilot AI Apr 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New activation variants mish_custom and dsilu are added to the registry, but there doesn’t appear to be any test coverage exercising them. Since the repo has an activation-variant smoke test (tests/test_all_activation_variations_cpu.sh), consider extending test coverage to include these new variants (or adding a small unit/smoke test that instantiates each new activation and runs a forward pass).

Copilot uses AI. Check for mistakes.
"softsign": Softsign_Config,
"softshrink": Softshrink_Config,
Expand Down
Loading