Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2ead102d1 | ||
|
|
c698bdeb2a | ||
|
|
6e33f3f82f | ||
|
|
c282262e6e |
Vendored
+1
-1
Submodule deps/research-environments updated: b10db7640b...ae5f051c25
Vendored
+1
-1
Submodule deps/verifiers updated: 29e3a0f7a3...a298bcfe4a
@@ -130,6 +130,7 @@ echo "MASTER_PORT=${MASTER_PORT}"
|
||||
# The ZMQ rollout transport binds in the orchestrator process, so both sides must
|
||||
# address the orchestrator's node.
|
||||
{% if num_infer_nodes > 0 and orchestrator_on_inference %}ORCH_PROCID=$((NUM_INFER_NODES - 1)){% else %}ORCH_PROCID=$NUM_INFER_NODES{% endif %}
|
||||
export ORCH_PROCID
|
||||
export ORCH_ADDR="${HOSTNAMES[$ORCH_PROCID]}"
|
||||
echo "ORCH_ADDR=${ORCH_ADDR}"
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ class LagunaConfig(PretrainedConfig):
|
||||
eos_token_id: int | list[int] | None = None,
|
||||
head_dim: int = 128,
|
||||
attention_bias: bool = False,
|
||||
gating: bool | str = True,
|
||||
partial_rotary_factor: float | None = None,
|
||||
num_attention_heads_per_layer: list[int] | None = None,
|
||||
mlp_layer_types: list[str] | None = None,
|
||||
@@ -98,6 +99,7 @@ class LagunaConfig(PretrainedConfig):
|
||||
self.layer_types = layer_types or ["full_attention"] * num_hidden_layers
|
||||
self.head_dim = head_dim
|
||||
self.attention_bias = attention_bias
|
||||
self.gating = gating
|
||||
self.partial_rotary_factor = partial_rotary_factor
|
||||
self.num_attention_heads_per_layer = num_attention_heads_per_layer or [num_attention_heads] * num_hidden_layers
|
||||
self.mlp_layer_types = mlp_layer_types or ["dense"] + ["sparse"] * (num_hidden_layers - 1)
|
||||
|
||||
@@ -106,7 +106,16 @@ class LagunaFlashAttention(FlashAttention):
|
||||
self.attention_dropout = config.attention_dropout
|
||||
self.is_local_attention = config.layer_types[layer_idx] == "sliding_attention"
|
||||
self.sliding_window = config.sliding_window if self.is_local_attention else None
|
||||
self.g_proj = nn.Linear(config.hidden_size, num_heads, bias=False)
|
||||
# Attention output gating, mirroring the upstream Laguna implementation:
|
||||
# True / "per-element" (Laguna M): one gate per (head, head_dim) channel
|
||||
# "per-head" (Laguna S): one gate per head, broadcast across head_dim
|
||||
# False: no gating
|
||||
gating = getattr(config, "gating", True)
|
||||
self.gating = bool(gating)
|
||||
self.gate_per_head = gating == "per-head"
|
||||
if self.gating:
|
||||
gate_size = num_heads if self.gate_per_head else num_heads * self.head_dim
|
||||
self.g_proj = nn.Linear(config.hidden_size, gate_size, bias=False)
|
||||
self.o_proj = nn.Linear(num_heads * self.head_dim, config.hidden_size, bias=config.attention_bias)
|
||||
|
||||
def forward(
|
||||
@@ -127,8 +136,13 @@ class LagunaFlashAttention(FlashAttention):
|
||||
)
|
||||
input_shape = hidden_states.shape[:-1]
|
||||
attn_output = attn_output.view(*input_shape, self.num_heads, self.head_dim)
|
||||
gate = F.softplus(self.g_proj(hidden_states).float()).to(attn_output.dtype)
|
||||
attn_output = (attn_output * gate.unsqueeze(-1)).view(*input_shape, -1)
|
||||
if self.gating:
|
||||
gate = F.softplus(self.g_proj(hidden_states).float()).to(attn_output.dtype)
|
||||
# per-head gates broadcast across head_dim; per-element gates are already
|
||||
# one-per-channel and line up with the [..., num_heads, head_dim] view.
|
||||
gate = gate.unsqueeze(-1) if self.gate_per_head else gate.view(*attn_output.shape)
|
||||
attn_output = attn_output * gate
|
||||
attn_output = attn_output.view(*input_shape, -1)
|
||||
return self.o_proj(attn_output), None
|
||||
|
||||
|
||||
|
||||
@@ -460,7 +460,7 @@ requires-dist = [
|
||||
{ name = "datasets" },
|
||||
{ name = "mcp", specifier = "<2" },
|
||||
{ name = "openai" },
|
||||
{ name = "verifiers", specifier = ">=0.2.2.dev65" },
|
||||
{ name = "verifiers", specifier = ">=0.3.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -584,7 +584,7 @@ dependencies = [
|
||||
requires-dist = [
|
||||
{ name = "bfcl-eval", git = "https://github.com/mikasenghaas/gorilla.git?subdirectory=berkeley-function-call-leaderboard&rev=898763a" },
|
||||
{ name = "soundfile", specifier = ">=0.13.0" },
|
||||
{ name = "verifiers", specifier = ">=0.2.2.dev65" },
|
||||
{ name = "verifiers", specifier = ">=0.3.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -694,7 +694,7 @@ requires-dist = [
|
||||
{ name = "openai" },
|
||||
{ name = "pystemmer" },
|
||||
{ name = "tokenizers" },
|
||||
{ name = "verifiers", specifier = ">=0.2.2.dev65" },
|
||||
{ name = "verifiers", specifier = ">=0.3.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1523,7 +1523,7 @@ dependencies = [
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "datasets", specifier = ">=4.0.0,<5" },
|
||||
{ name = "verifiers", specifier = ">=0.2.2.dev65" },
|
||||
{ name = "verifiers", specifier = ">=0.3.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1924,7 +1924,7 @@ dependencies = [
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "pydantic" },
|
||||
{ name = "verifiers", extras = ["harbor"], specifier = ">=0.2.2.dev65" },
|
||||
{ name = "verifiers", extras = ["harbor"], specifier = ">=0.3.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3348,7 +3348,7 @@ requires-dist = [
|
||||
{ name = "datasets", specifier = ">=4.0.0,<5" },
|
||||
{ name = "httpx" },
|
||||
{ name = "prime-sandboxes", specifier = ">=0.2.19" },
|
||||
{ name = "verifiers", specifier = ">=0.2.2.dev65" },
|
||||
{ name = "verifiers", specifier = ">=0.3.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
Reference in New Issue
Block a user