Auto upload 2026-08-06T20:45:13.807790
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +4 -0
- README.md +1 -0
- __pycache__/exp.cpython-311.pyc +0 -0
- exp.py +1060 -0
- h.py +25 -0
- llm_analyzer_wandb.py +570 -0
- out/glu-gelu-9L_run/README.md +65 -0
- out/glu-gelu-9L_run/checkpoint-1000/config.json +35 -0
- out/glu-gelu-9L_run/checkpoint-1000/model.safetensors +3 -0
- out/glu-gelu-9L_run/checkpoint-1000/optimizer.pt +3 -0
- out/glu-gelu-9L_run/checkpoint-1000/rng_state.pth +3 -0
- out/glu-gelu-9L_run/checkpoint-1000/scheduler.pt +3 -0
- out/glu-gelu-9L_run/checkpoint-1000/tokenizer.json +0 -0
- out/glu-gelu-9L_run/checkpoint-1000/tokenizer_config.json +13 -0
- out/glu-gelu-9L_run/checkpoint-1000/trainer_state.json +424 -0
- out/glu-gelu-9L_run/checkpoint-1000/training_args.bin +3 -0
- out/glu-gelu-9L_run/checkpoint-1500/config.json +35 -0
- out/glu-gelu-9L_run/checkpoint-1500/model.safetensors +3 -0
- out/glu-gelu-9L_run/checkpoint-1500/optimizer.pt +3 -0
- out/glu-gelu-9L_run/checkpoint-1500/rng_state.pth +3 -0
- out/glu-gelu-9L_run/checkpoint-1500/scheduler.pt +3 -0
- out/glu-gelu-9L_run/checkpoint-1500/tokenizer.json +0 -0
- out/glu-gelu-9L_run/checkpoint-1500/tokenizer_config.json +13 -0
- out/glu-gelu-9L_run/checkpoint-1500/trainer_state.json +615 -0
- out/glu-gelu-9L_run/checkpoint-1500/training_args.bin +3 -0
- out/glu-gelu-9L_run/checkpoint-2000/config.json +35 -0
- out/glu-gelu-9L_run/checkpoint-2000/model.safetensors +3 -0
- out/glu-gelu-9L_run/checkpoint-2000/optimizer.pt +3 -0
- out/glu-gelu-9L_run/checkpoint-2000/rng_state.pth +3 -0
- out/glu-gelu-9L_run/checkpoint-2000/scheduler.pt +3 -0
- out/glu-gelu-9L_run/checkpoint-2000/tokenizer.json +0 -0
- out/glu-gelu-9L_run/checkpoint-2000/tokenizer_config.json +13 -0
- out/glu-gelu-9L_run/checkpoint-2000/trainer_state.json +814 -0
- out/glu-gelu-9L_run/checkpoint-2000/training_args.bin +3 -0
- out/glu-gelu-9L_run/checkpoint-500/config.json +35 -0
- out/glu-gelu-9L_run/checkpoint-500/model.safetensors +3 -0
- out/glu-gelu-9L_run/checkpoint-500/optimizer.pt +3 -0
- out/glu-gelu-9L_run/checkpoint-500/rng_state.pth +3 -0
- out/glu-gelu-9L_run/checkpoint-500/scheduler.pt +3 -0
- out/glu-gelu-9L_run/checkpoint-500/tokenizer.json +0 -0
- out/glu-gelu-9L_run/checkpoint-500/tokenizer_config.json +13 -0
- out/glu-gelu-9L_run/checkpoint-500/trainer_state.json +225 -0
- out/glu-gelu-9L_run/checkpoint-500/training_args.bin +3 -0
- out/glu-gelu-9L_run/config.json +35 -0
- out/glu-gelu-9L_run/model.safetensors +3 -0
- out/glu-gelu-9L_run/tokenizer.json +0 -0
- out/glu-gelu-9L_run/tokenizer_config.json +13 -0
- out/glu-gelu-9L_run/training_args.bin +3 -0
- out/glu-gelu-9L_run/training_log.jsonl +0 -0
- out/glu-linear-9L_run/checkpoint-1000/config.json +35 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
wandb/run-20260806_202910-50qq810b/run-50qq810b.wandb filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
wandb/run-20260806_203335-6n8s22c0/run-6n8s22c0.wandb filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
wandb/run-20260806_203759-m4g42ash/run-m4g42ash.wandb filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
wandb/run-20260806_204221-wp360ttn/run-wp360ttn.wandb filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# Activation
|
__pycache__/exp.cpython-311.pyc
ADDED
|
Binary file (58 kB). View file
|
|
|
exp.py
ADDED
|
@@ -0,0 +1,1060 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Tiny Llama GLU Lab — Consolidated training library.
|
| 3 |
+
One file: model definition, activation registry, stability monitoring,
|
| 4 |
+
time tracking, dataset builder, and Trainer factory.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import math
|
| 8 |
+
import os
|
| 9 |
+
import time
|
| 10 |
+
import json
|
| 11 |
+
import re
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
from itertools import chain
|
| 14 |
+
from typing import Dict, Callable, Optional, List, Any, Tuple
|
| 15 |
+
|
| 16 |
+
import torch
|
| 17 |
+
import torch.nn as nn
|
| 18 |
+
from transformers import (
|
| 19 |
+
LlamaConfig,
|
| 20 |
+
LlamaPreTrainedModel,
|
| 21 |
+
Trainer,
|
| 22 |
+
TrainerCallback,
|
| 23 |
+
TrainingArguments,
|
| 24 |
+
DataCollatorForLanguageModeling,
|
| 25 |
+
AutoTokenizer,
|
| 26 |
+
set_seed,
|
| 27 |
+
)
|
| 28 |
+
# CHANGE 1: LlamaSdpaAttention/LlamaFlashAttention2 no longer exist as separate
|
| 29 |
+
# classes in modern transformers — there is a single LlamaAttention that
|
| 30 |
+
# dispatches to eager/sdpa/flash_attention_2 based on config._attn_implementation.
|
| 31 |
+
from transformers.models.llama.modeling_llama import (
|
| 32 |
+
LlamaAttention,
|
| 33 |
+
LlamaRMSNorm,
|
| 34 |
+
LlamaRotaryEmbedding,
|
| 35 |
+
)
|
| 36 |
+
from transformers.modeling_outputs import CausalLMOutputWithPast
|
| 37 |
+
from datasets import load_dataset
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
# =============================================================================
|
| 41 |
+
# 1. ACTIVATION REGISTRY
|
| 42 |
+
# =============================================================================
|
| 43 |
+
|
| 44 |
+
class GLUActivationRegistry:
|
| 45 |
+
"""Own every gating activation you test. Add new variants in one line."""
|
| 46 |
+
_registry: Dict[str, Callable[[torch.Tensor], torch.Tensor]] = {}
|
| 47 |
+
|
| 48 |
+
@classmethod
|
| 49 |
+
def register(cls, name: str, fn: Callable[[torch.Tensor], torch.Tensor]) -> None:
|
| 50 |
+
cls._registry[name] = fn
|
| 51 |
+
|
| 52 |
+
@classmethod
|
| 53 |
+
def get(cls, name: str) -> Callable[[torch.Tensor], torch.Tensor]:
|
| 54 |
+
if name not in cls._registry:
|
| 55 |
+
raise KeyError(
|
| 56 |
+
f"Activation '{name}' not found. Available: {list(cls._registry.keys())}"
|
| 57 |
+
)
|
| 58 |
+
return cls._registry[name]
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
# Built-ins
|
| 62 |
+
GLUActivationRegistry.register("silu", nn.functional.silu)
|
| 63 |
+
GLUActivationRegistry.register("swish", nn.functional.silu)
|
| 64 |
+
GLUActivationRegistry.register("relu", nn.functional.relu)
|
| 65 |
+
GLUActivationRegistry.register("gelu", nn.functional.gelu)
|
| 66 |
+
GLUActivationRegistry.register("mish", nn.functional.mish)
|
| 67 |
+
GLUActivationRegistry.register("sigmoid", torch.sigmoid)
|
| 68 |
+
GLUActivationRegistry.register("tanh", torch.tanh)
|
| 69 |
+
GLUActivationRegistry.register("elu", nn.functional.elu)
|
| 70 |
+
GLUActivationRegistry.register("softplus", nn.functional.softplus)
|
| 71 |
+
|
| 72 |
+
# Identity activation – used for "linear" baseline
|
| 73 |
+
GLUActivationRegistry.register("linear", lambda x: x)
|
| 74 |
+
# For backward compatibility, keep "bilinear" as alias to "linear"
|
| 75 |
+
GLUActivationRegistry.register("bilinear", lambda x: x)
|
| 76 |
+
|
| 77 |
+
# NEW: s10 = x^2 * sigmoid(x)
|
| 78 |
+
GLUActivationRegistry.register("s10", lambda x: x * x * torch.sigmoid(x))
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
# =============================================================================
|
| 82 |
+
# 2. CONFIG
|
| 83 |
+
# =============================================================================
|
| 84 |
+
|
| 85 |
+
class TinyLlamaConfig(LlamaConfig):
|
| 86 |
+
"""
|
| 87 |
+
Exact Llama config plus two fields:
|
| 88 |
+
- mlp_type: "glu" or "mlp" (standard Transformer MLP)
|
| 89 |
+
- activation: name of the activation function to use inside the MLP block.
|
| 90 |
+
Enforces pure MHA by requiring num_key_value_heads == num_attention_heads.
|
| 91 |
+
"""
|
| 92 |
+
model_type = "tiny_llama"
|
| 93 |
+
|
| 94 |
+
def __init__(
|
| 95 |
+
self,
|
| 96 |
+
mlp_type: str = "glu", # default for backward compatibility, but config must override
|
| 97 |
+
activation: str = "silu", # default for backward compatibility
|
| 98 |
+
**kwargs
|
| 99 |
+
):
|
| 100 |
+
super().__init__(**kwargs)
|
| 101 |
+
self.mlp_type = mlp_type
|
| 102 |
+
self.activation = activation
|
| 103 |
+
if self.num_key_value_heads != self.num_attention_heads:
|
| 104 |
+
raise ValueError(
|
| 105 |
+
f"Pure MHA required: num_key_value_heads ({self.num_key_value_heads}) "
|
| 106 |
+
f"must equal num_attention_heads ({self.num_attention_heads})."
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
# =============================================================================
|
| 111 |
+
# 3. MODEL
|
| 112 |
+
# =============================================================================
|
| 113 |
+
|
| 114 |
+
class SiTUGLU(nn.Module):
|
| 115 |
+
def __init__(
|
| 116 |
+
self,
|
| 117 |
+
input_dim: int,
|
| 118 |
+
hidden_dim: int,
|
| 119 |
+
beta1: float = 4.0,
|
| 120 |
+
beta2: float = 25.0,
|
| 121 |
+
):
|
| 122 |
+
super().__init__()
|
| 123 |
+
self.beta1 = beta1
|
| 124 |
+
self.beta2 = beta2
|
| 125 |
+
self.W_g = nn.Linear(input_dim, hidden_dim, bias=False)
|
| 126 |
+
self.W_u = nn.Linear(input_dim, hidden_dim, bias=False)
|
| 127 |
+
|
| 128 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 129 |
+
g = self.W_g(x)
|
| 130 |
+
gate = self.beta1 * torch.tanh(g / self.beta1) * torch.sigmoid(g)
|
| 131 |
+
up = self.beta2 * torch.tanh(self.W_u(x) / self.beta2)
|
| 132 |
+
return gate * up
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
class TinyLlamaMLP(nn.Module):
|
| 136 |
+
"""
|
| 137 |
+
MLP block supporting both:
|
| 138 |
+
- GLU: down_proj( act(gate_proj(x)) * up_proj(x) )
|
| 139 |
+
- Standard MLP: down_proj( act(up_proj(x)) )
|
| 140 |
+
For MLP, intermediate_size is auto‑scaled by 1.5× to match GLU parameter count.
|
| 141 |
+
"""
|
| 142 |
+
def __init__(self, config: TinyLlamaConfig):
|
| 143 |
+
super().__init__()
|
| 144 |
+
self.hidden_size = config.hidden_size
|
| 145 |
+
self.intermediate_size = config.intermediate_size # base value
|
| 146 |
+
self.mlp_type = config.mlp_type
|
| 147 |
+
self.activation_name = config.activation
|
| 148 |
+
|
| 149 |
+
# Determine effective dimensions
|
| 150 |
+
if self.mlp_type == "glu":
|
| 151 |
+
# GLU: keep original intermediate_size
|
| 152 |
+
effective_intermediate = self.intermediate_size
|
| 153 |
+
elif self.mlp_type == "mlp":
|
| 154 |
+
# Standard MLP: scale by 1.5 to keep parameter count equal
|
| 155 |
+
effective_intermediate = int(self.intermediate_size * 1.5)
|
| 156 |
+
print(f"[MLP] Auto‑scaled intermediate_size from {self.intermediate_size} to {effective_intermediate} for parameter parity.")
|
| 157 |
+
else:
|
| 158 |
+
raise ValueError(f"Unknown mlp_type: {self.mlp_type}")
|
| 159 |
+
|
| 160 |
+
# Store effective size for use in forward
|
| 161 |
+
self.effective_intermediate = effective_intermediate
|
| 162 |
+
|
| 163 |
+
# Handle special activations first
|
| 164 |
+
if self.mlp_type == "glu" and self.activation_name == "situglu":
|
| 165 |
+
# SiTUGLU is a complete GLU block (has its own gate & up)
|
| 166 |
+
self.situglu = SiTUGLU(self.hidden_size, effective_intermediate)
|
| 167 |
+
self.gate_proj = None
|
| 168 |
+
self.up_proj = None
|
| 169 |
+
self.act_fn = None
|
| 170 |
+
else:
|
| 171 |
+
self.situglu = None
|
| 172 |
+
# For both GLU and MLP we need an activation function (except for situglu)
|
| 173 |
+
if self.activation_name == "situglu":
|
| 174 |
+
raise ValueError(
|
| 175 |
+
f"Activation 'situglu' is only allowed with mlp_type='glu'. "
|
| 176 |
+
f"Received mlp_type='{self.mlp_type}'."
|
| 177 |
+
)
|
| 178 |
+
self.act_fn = GLUActivationRegistry.get(self.activation_name)
|
| 179 |
+
|
| 180 |
+
if self.mlp_type == "glu":
|
| 181 |
+
# GLU: two parallel projections
|
| 182 |
+
self.gate_proj = nn.Linear(self.hidden_size, effective_intermediate, bias=False)
|
| 183 |
+
self.up_proj = nn.Linear(self.hidden_size, effective_intermediate, bias=False)
|
| 184 |
+
else: # mlp
|
| 185 |
+
# Standard MLP: only one projection before activation
|
| 186 |
+
self.gate_proj = None
|
| 187 |
+
self.up_proj = nn.Linear(self.hidden_size, effective_intermediate, bias=False)
|
| 188 |
+
|
| 189 |
+
# Down projection is always present, using the effective intermediate size
|
| 190 |
+
self.down_proj = nn.Linear(effective_intermediate, self.hidden_size, bias=False)
|
| 191 |
+
|
| 192 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 193 |
+
if self.situglu is not None:
|
| 194 |
+
# SiTUGLU handles its own gate and up
|
| 195 |
+
return self.down_proj(self.situglu(x))
|
| 196 |
+
|
| 197 |
+
if self.mlp_type == "glu":
|
| 198 |
+
# GLU: act(gate) * up
|
| 199 |
+
gate = self.gate_proj(x)
|
| 200 |
+
up = self.up_proj(x)
|
| 201 |
+
hidden = self.act_fn(gate) * up
|
| 202 |
+
else: # mlp
|
| 203 |
+
# Standard MLP: act(up)
|
| 204 |
+
hidden = self.act_fn(self.up_proj(x))
|
| 205 |
+
|
| 206 |
+
return self.down_proj(hidden)
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
class TinyLlamaDecoderLayer(nn.Module):
|
| 210 |
+
def __init__(self, config: TinyLlamaConfig, layer_idx: int):
|
| 211 |
+
super().__init__()
|
| 212 |
+
self.hidden_size = config.hidden_size
|
| 213 |
+
# CHANGE 2: LlamaAttention picks its backend (eager/sdpa/flash_attention_2)
|
| 214 |
+
# from config._attn_implementation internally.
|
| 215 |
+
self.self_attn = LlamaAttention(config=config, layer_idx=layer_idx)
|
| 216 |
+
self.mlp = TinyLlamaMLP(config)
|
| 217 |
+
self.input_layernorm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 218 |
+
self.post_attention_layernorm = LlamaRMSNorm(
|
| 219 |
+
config.hidden_size, eps=config.rms_norm_eps
|
| 220 |
+
)
|
| 221 |
+
|
| 222 |
+
def forward(
|
| 223 |
+
self,
|
| 224 |
+
hidden_states: torch.Tensor,
|
| 225 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 226 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 227 |
+
position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
|
| 228 |
+
**kwargs,
|
| 229 |
+
):
|
| 230 |
+
residual = hidden_states
|
| 231 |
+
hidden_states = self.input_layernorm(hidden_states)
|
| 232 |
+
attn_out = self.self_attn(
|
| 233 |
+
hidden_states=hidden_states,
|
| 234 |
+
attention_mask=attention_mask,
|
| 235 |
+
position_ids=position_ids,
|
| 236 |
+
position_embeddings=position_embeddings,
|
| 237 |
+
)[0]
|
| 238 |
+
hidden_states = residual + attn_out
|
| 239 |
+
|
| 240 |
+
residual = hidden_states
|
| 241 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 242 |
+
hidden_states = self.mlp(hidden_states)
|
| 243 |
+
hidden_states = residual + hidden_states
|
| 244 |
+
return (hidden_states,)
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
# CHANGE 3: Replace float mask with Boolean mask (required for Flash Attention)
|
| 248 |
+
def _build_causal_mask(
|
| 249 |
+
attention_mask: Optional[torch.Tensor],
|
| 250 |
+
seq_len: int,
|
| 251 |
+
dtype: torch.dtype,
|
| 252 |
+
device: torch.device,
|
| 253 |
+
) -> torch.Tensor:
|
| 254 |
+
"""
|
| 255 |
+
Build a 4D Boolean causal + padding mask for SDPA.
|
| 256 |
+
- True -> masked out (do NOT attend)
|
| 257 |
+
- False -> allowed to attend
|
| 258 |
+
This is the format expected by torch.nn.functional.scaled_dot_product_attention
|
| 259 |
+
when using Flash Attention kernels.
|
| 260 |
+
"""
|
| 261 |
+
# Causal mask: upper triangular (future tokens) = True
|
| 262 |
+
causal = torch.triu(
|
| 263 |
+
torch.ones((seq_len, seq_len), dtype=torch.bool, device=device),
|
| 264 |
+
diagonal=1
|
| 265 |
+
)
|
| 266 |
+
causal = causal[None, None, :, :] # (1, 1, seq_len, seq_len)
|
| 267 |
+
|
| 268 |
+
if attention_mask is None:
|
| 269 |
+
return causal
|
| 270 |
+
|
| 271 |
+
batch_size = attention_mask.shape[0]
|
| 272 |
+
causal = causal.expand(batch_size, 1, seq_len, seq_len).clone()
|
| 273 |
+
|
| 274 |
+
# Padding: where attention_mask == 0 -> masked out (True)
|
| 275 |
+
padding_mask = attention_mask[:, None, None, :].to(device) == 0
|
| 276 |
+
causal = causal | padding_mask # OR combines both masks
|
| 277 |
+
|
| 278 |
+
return causal
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
class TinyLlamaModel(LlamaPreTrainedModel):
|
| 282 |
+
config_class = TinyLlamaConfig
|
| 283 |
+
|
| 284 |
+
def __init__(self, config: TinyLlamaConfig):
|
| 285 |
+
super().__init__(config)
|
| 286 |
+
self.padding_idx = config.pad_token_id
|
| 287 |
+
self.vocab_size = config.vocab_size
|
| 288 |
+
self.embed_tokens = nn.Embedding(
|
| 289 |
+
config.vocab_size, config.hidden_size, self.padding_idx
|
| 290 |
+
)
|
| 291 |
+
self.layers = nn.ModuleList(
|
| 292 |
+
[TinyLlamaDecoderLayer(config, i) for i in range(config.num_hidden_layers)]
|
| 293 |
+
)
|
| 294 |
+
self.norm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 295 |
+
# RoPE: computed once per forward pass and threaded into every
|
| 296 |
+
# decoder layer's attention. Without this, LlamaAttention receives
|
| 297 |
+
# position_embeddings=None and crashes on `cos, sin = position_embeddings`.
|
| 298 |
+
self.rotary_emb = LlamaRotaryEmbedding(config=config)
|
| 299 |
+
self.post_init()
|
| 300 |
+
|
| 301 |
+
def forward(
|
| 302 |
+
self,
|
| 303 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 304 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 305 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 306 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 307 |
+
return_dict: Optional[bool] = None,
|
| 308 |
+
**kwargs,
|
| 309 |
+
):
|
| 310 |
+
return_dict = (
|
| 311 |
+
return_dict if return_dict is not None else self.config.use_return_dict
|
| 312 |
+
)
|
| 313 |
+
if inputs_embeds is None:
|
| 314 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
| 315 |
+
|
| 316 |
+
if position_ids is None:
|
| 317 |
+
seq_len = inputs_embeds.shape[1]
|
| 318 |
+
position_ids = torch.arange(
|
| 319 |
+
seq_len, device=inputs_embeds.device
|
| 320 |
+
).unsqueeze(0).expand(inputs_embeds.shape[0], -1)
|
| 321 |
+
|
| 322 |
+
hidden_states = inputs_embeds
|
| 323 |
+
# (cos, sin) tuple, shared across all layers this forward pass
|
| 324 |
+
position_embeddings = self.rotary_emb(hidden_states, position_ids)
|
| 325 |
+
|
| 326 |
+
# CHANGE 3: flash_attention_2's kernel does not accept a dense 4D
|
| 327 |
+
# bool/float mask — it wants None (pure causal) or the raw 2D padding
|
| 328 |
+
# mask, and handles causality internally. Only build the dense 4D
|
| 329 |
+
# mask for eager/sdpa backends.
|
| 330 |
+
if self.config._attn_implementation == "flash_attention_2":
|
| 331 |
+
causal_mask = attention_mask
|
| 332 |
+
else:
|
| 333 |
+
seq_len = hidden_states.shape[1]
|
| 334 |
+
causal_mask = _build_causal_mask(
|
| 335 |
+
attention_mask, seq_len, hidden_states.dtype, hidden_states.device
|
| 336 |
+
)
|
| 337 |
+
|
| 338 |
+
for decoder_layer in self.layers:
|
| 339 |
+
layer_outputs = decoder_layer(
|
| 340 |
+
hidden_states,
|
| 341 |
+
attention_mask=causal_mask,
|
| 342 |
+
position_ids=position_ids,
|
| 343 |
+
position_embeddings=position_embeddings,
|
| 344 |
+
)
|
| 345 |
+
hidden_states = layer_outputs[0]
|
| 346 |
+
|
| 347 |
+
hidden_states = self.norm(hidden_states)
|
| 348 |
+
if not return_dict:
|
| 349 |
+
return (hidden_states,)
|
| 350 |
+
return {"last_hidden_state": hidden_states, "hidden_states": None, "attentions": None}
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
class TinyLlamaForCausalLM(LlamaPreTrainedModel):
|
| 354 |
+
config_class = TinyLlamaConfig
|
| 355 |
+
# Tells save_pretrained() that lm_head.weight and model.embed_tokens.weight
|
| 356 |
+
# are the SAME tensor on purpose (see tie_word_embeddings below), so it
|
| 357 |
+
# doesn't error out when it finds two names pointing at shared memory.
|
| 358 |
+
# NOTE: must be a dict (maps tied key -> source key), not a list —
|
| 359 |
+
# transformers' _get_tied_weight_keys() calls .keys() on this.
|
| 360 |
+
_tied_weights_keys = {"lm_head.weight": "model.embed_tokens.weight"}
|
| 361 |
+
|
| 362 |
+
def __init__(self, config: TinyLlamaConfig):
|
| 363 |
+
super().__init__(config)
|
| 364 |
+
self.model = TinyLlamaModel(config)
|
| 365 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 366 |
+
if config.tie_word_embeddings:
|
| 367 |
+
self.lm_head.weight = self.model.embed_tokens.weight
|
| 368 |
+
self.post_init()
|
| 369 |
+
|
| 370 |
+
def get_input_embeddings(self):
|
| 371 |
+
return self.model.embed_tokens
|
| 372 |
+
|
| 373 |
+
def set_input_embeddings(self, value):
|
| 374 |
+
self.model.embed_tokens = value
|
| 375 |
+
|
| 376 |
+
def get_output_embeddings(self):
|
| 377 |
+
return self.lm_head
|
| 378 |
+
|
| 379 |
+
def forward(
|
| 380 |
+
self,
|
| 381 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 382 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 383 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 384 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 385 |
+
labels: Optional[torch.LongTensor] = None,
|
| 386 |
+
return_dict: Optional[bool] = None,
|
| 387 |
+
**kwargs,
|
| 388 |
+
):
|
| 389 |
+
return_dict = (
|
| 390 |
+
return_dict if return_dict is not None else self.config.use_return_dict
|
| 391 |
+
)
|
| 392 |
+
outputs = self.model(
|
| 393 |
+
input_ids=input_ids,
|
| 394 |
+
attention_mask=attention_mask,
|
| 395 |
+
position_ids=position_ids,
|
| 396 |
+
inputs_embeds=inputs_embeds,
|
| 397 |
+
return_dict=return_dict,
|
| 398 |
+
)
|
| 399 |
+
hidden_states = outputs["last_hidden_state"] if return_dict else outputs[0]
|
| 400 |
+
logits = self.lm_head(hidden_states)
|
| 401 |
+
|
| 402 |
+
loss = None
|
| 403 |
+
if labels is not None:
|
| 404 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
| 405 |
+
shift_labels = labels[..., 1:].contiguous()
|
| 406 |
+
loss_fct = nn.CrossEntropyLoss()
|
| 407 |
+
loss = loss_fct(
|
| 408 |
+
shift_logits.view(-1, self.config.vocab_size), shift_labels.view(-1)
|
| 409 |
+
)
|
| 410 |
+
|
| 411 |
+
if not return_dict:
|
| 412 |
+
output = (logits,) + outputs[1:]
|
| 413 |
+
return (loss,) + output if loss is not None else output
|
| 414 |
+
return CausalLMOutputWithPast(
|
| 415 |
+
loss=loss,
|
| 416 |
+
logits=logits,
|
| 417 |
+
past_key_values=None,
|
| 418 |
+
hidden_states=None,
|
| 419 |
+
attentions=None,
|
| 420 |
+
)
|
| 421 |
+
|
| 422 |
+
def prepare_inputs_for_generation(
|
| 423 |
+
self, input_ids, past_key_values=None, attention_mask=None, **kwargs
|
| 424 |
+
):
|
| 425 |
+
if past_key_values:
|
| 426 |
+
input_ids = input_ids[:, -1:]
|
| 427 |
+
position_ids = kwargs.get("position_ids")
|
| 428 |
+
if attention_mask is not None and position_ids is None:
|
| 429 |
+
position_ids = attention_mask.long().cumsum(-1) - 1
|
| 430 |
+
position_ids.masked_fill_(attention_mask == 0, 1)
|
| 431 |
+
if past_key_values:
|
| 432 |
+
position_ids = position_ids[:, -1].unsqueeze(-1)
|
| 433 |
+
return {
|
| 434 |
+
"input_ids": input_ids,
|
| 435 |
+
"position_ids": position_ids,
|
| 436 |
+
"past_key_values": past_key_values,
|
| 437 |
+
"attention_mask": attention_mask,
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
# =============================================================================
|
| 442 |
+
# 4. MONITORING ENGINE
|
| 443 |
+
# =============================================================================
|
| 444 |
+
|
| 445 |
+
class StatsEngine:
|
| 446 |
+
"""Compute the unified 6-scalar signature for any tensor."""
|
| 447 |
+
|
| 448 |
+
@staticmethod
|
| 449 |
+
def compute(
|
| 450 |
+
tensor: torch.Tensor, user_limit: float, dtype_ratio: float
|
| 451 |
+
) -> Dict[str, float]:
|
| 452 |
+
with torch.no_grad():
|
| 453 |
+
abs_t = tensor.abs()
|
| 454 |
+
dtype_info = torch.finfo(tensor.dtype)
|
| 455 |
+
dtype_limit = (
|
| 456 |
+
dtype_ratio * dtype_info.max
|
| 457 |
+
if not torch.isinf(torch.tensor(dtype_info.max))
|
| 458 |
+
else float("inf")
|
| 459 |
+
)
|
| 460 |
+
|
| 461 |
+
return {
|
| 462 |
+
"norm": tensor.norm(2).item(),
|
| 463 |
+
"mean": tensor.mean().item(),
|
| 464 |
+
"std": tensor.std().item(),
|
| 465 |
+
"max_abs": abs_t.max().item(),
|
| 466 |
+
"frac_near_dtype_limit": (
|
| 467 |
+
(abs_t > dtype_limit).float().mean().item()
|
| 468 |
+
if not math.isinf(dtype_limit)
|
| 469 |
+
else 0.0
|
| 470 |
+
),
|
| 471 |
+
"frac_near_user_limit": (abs_t > user_limit).float().mean().item(),
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
|
| 475 |
+
class StepAccumulator:
|
| 476 |
+
"""
|
| 477 |
+
Stores per-tensor entries, then aggregates to layer-scope or global-scope
|
| 478 |
+
using exact population formulas (no tensor retention).
|
| 479 |
+
"""
|
| 480 |
+
|
| 481 |
+
def __init__(self):
|
| 482 |
+
# name -> {numel, norm, mean, std, max_abs, frac_near_dtype_limit, frac_near_user_limit}
|
| 483 |
+
self.tensors: Dict[str, Dict[str, float]] = {}
|
| 484 |
+
|
| 485 |
+
def add(self, name: str, numel: int, stats: Dict[str, float]):
|
| 486 |
+
# With gradient_accumulation_steps > 1, a single optimizer "step"
|
| 487 |
+
# runs several forward/backward micro-batches, so the same hook
|
| 488 |
+
# (e.g. a given layer's activation, or a given param's grad) fires
|
| 489 |
+
# more than once before clear() is next called. Previously this
|
| 490 |
+
# method did a plain overwrite, silently discarding every
|
| 491 |
+
# micro-batch but the last. Merge instead, using the same exact
|
| 492 |
+
# population formulas _aggregate() uses to combine tensors.
|
| 493 |
+
new_entry = {"numel": numel, **stats}
|
| 494 |
+
existing = self.tensors.get(name)
|
| 495 |
+
self.tensors[name] = (
|
| 496 |
+
new_entry if existing is None else self._merge_entry(existing, new_entry)
|
| 497 |
+
)
|
| 498 |
+
|
| 499 |
+
@staticmethod
|
| 500 |
+
def _merge_entry(a: Dict[str, float], b: Dict[str, float]) -> Dict[str, float]:
|
| 501 |
+
total_n = a["numel"] + b["numel"]
|
| 502 |
+
if total_n == 0:
|
| 503 |
+
return a
|
| 504 |
+
norm = math.sqrt(a["norm"] ** 2 + b["norm"] ** 2)
|
| 505 |
+
max_abs = max(a["max_abs"], b["max_abs"])
|
| 506 |
+
mean = (a["mean"] * a["numel"] + b["mean"] * b["numel"]) / total_n
|
| 507 |
+
ex2 = (
|
| 508 |
+
a["numel"] * (a["std"] ** 2 + a["mean"] ** 2)
|
| 509 |
+
+ b["numel"] * (b["std"] ** 2 + b["mean"] ** 2)
|
| 510 |
+
) / total_n
|
| 511 |
+
std = math.sqrt(max(0.0, ex2 - mean ** 2))
|
| 512 |
+
frac_dtype = (
|
| 513 |
+
a["frac_near_dtype_limit"] * a["numel"] + b["frac_near_dtype_limit"] * b["numel"]
|
| 514 |
+
) / total_n
|
| 515 |
+
frac_user = (
|
| 516 |
+
a["frac_near_user_limit"] * a["numel"] + b["frac_near_user_limit"] * b["numel"]
|
| 517 |
+
) / total_n
|
| 518 |
+
return {
|
| 519 |
+
"numel": total_n,
|
| 520 |
+
"norm": norm,
|
| 521 |
+
"mean": mean,
|
| 522 |
+
"std": std,
|
| 523 |
+
"max_abs": max_abs,
|
| 524 |
+
"frac_near_dtype_limit": frac_dtype,
|
| 525 |
+
"frac_near_user_limit": frac_user,
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
def clear(self):
|
| 529 |
+
self.tensors.clear()
|
| 530 |
+
|
| 531 |
+
def _aggregate(self, entries: Dict[str, Dict[str, float]]) -> Dict[str, float]:
|
| 532 |
+
if not entries:
|
| 533 |
+
return {}
|
| 534 |
+
numels = [e["numel"] for e in entries.values()]
|
| 535 |
+
total_n = sum(numels)
|
| 536 |
+
|
| 537 |
+
# L2 norm
|
| 538 |
+
norm = math.sqrt(sum(e["norm"] ** 2 for e in entries.values()))
|
| 539 |
+
# Max abs
|
| 540 |
+
max_abs = max(e["max_abs"] for e in entries.values())
|
| 541 |
+
# Weighted mean
|
| 542 |
+
mean = sum(e["mean"] * e["numel"] for e in entries.values()) / total_n
|
| 543 |
+
# Pooled std: sqrt( E[σ² + μ²] - μ_global² )
|
| 544 |
+
ex2 = (
|
| 545 |
+
sum(e["numel"] * (e["std"] ** 2 + e["mean"] ** 2) for e in entries.values())
|
| 546 |
+
/ total_n
|
| 547 |
+
)
|
| 548 |
+
std = math.sqrt(max(0.0, ex2 - mean ** 2))
|
| 549 |
+
# Weighted fractions
|
| 550 |
+
frac_dtype = (
|
| 551 |
+
sum(e["frac_near_dtype_limit"] * e["numel"] for e in entries.values())
|
| 552 |
+
/ total_n
|
| 553 |
+
)
|
| 554 |
+
frac_user = (
|
| 555 |
+
sum(e["frac_near_user_limit"] * e["numel"] for e in entries.values())
|
| 556 |
+
/ total_n
|
| 557 |
+
)
|
| 558 |
+
|
| 559 |
+
return {
|
| 560 |
+
"norm": norm,
|
| 561 |
+
"mean": mean,
|
| 562 |
+
"std": std,
|
| 563 |
+
"max_abs": max_abs,
|
| 564 |
+
"frac_near_dtype_limit": frac_dtype,
|
| 565 |
+
"frac_near_user_limit": frac_user,
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
def get_global_stats(self) -> Dict[str, float]:
|
| 569 |
+
return self._aggregate(self.tensors)
|
| 570 |
+
|
| 571 |
+
def get_layer_stats(self, layer_prefix: str) -> Dict[str, float]:
|
| 572 |
+
entries = {
|
| 573 |
+
k: v for k, v in self.tensors.items() if k.startswith(layer_prefix + ".")
|
| 574 |
+
}
|
| 575 |
+
return self._aggregate(entries)
|
| 576 |
+
|
| 577 |
+
|
| 578 |
+
class HookRegistry:
|
| 579 |
+
"""Attach and throttle forward/backward hooks."""
|
| 580 |
+
|
| 581 |
+
def __init__(self, model: nn.Module):
|
| 582 |
+
self.model = model
|
| 583 |
+
self.handles: List[torch.utils.hooks.RemovableHandle] = []
|
| 584 |
+
self.active = False
|
| 585 |
+
|
| 586 |
+
def attach_forward(
|
| 587 |
+
self,
|
| 588 |
+
module_patterns: List[str],
|
| 589 |
+
accumulator: StepAccumulator,
|
| 590 |
+
user_limit: float,
|
| 591 |
+
dtype_ratio: float,
|
| 592 |
+
):
|
| 593 |
+
for name, module in self.model.named_modules():
|
| 594 |
+
if any(re.search(p, name) for p in module_patterns):
|
| 595 |
+
h = module.register_forward_hook(
|
| 596 |
+
self._make_forward_hook(name, accumulator, user_limit, dtype_ratio)
|
| 597 |
+
)
|
| 598 |
+
self.handles.append(h)
|
| 599 |
+
|
| 600 |
+
def attach_backward(
|
| 601 |
+
self, accumulator: StepAccumulator, user_limit: float, dtype_ratio: float
|
| 602 |
+
):
|
| 603 |
+
for name, param in self.model.named_parameters():
|
| 604 |
+
if param.requires_grad:
|
| 605 |
+
h = param.register_hook(
|
| 606 |
+
self._make_backward_hook(
|
| 607 |
+
f"grad.{name}", accumulator, user_limit, dtype_ratio
|
| 608 |
+
)
|
| 609 |
+
)
|
| 610 |
+
self.handles.append(h)
|
| 611 |
+
|
| 612 |
+
def _make_forward_hook(
|
| 613 |
+
self, module_name: str, accumulator: StepAccumulator, user_limit: float, dtype_ratio: float
|
| 614 |
+
):
|
| 615 |
+
def hook(module, inp, out):
|
| 616 |
+
if not self.active:
|
| 617 |
+
return
|
| 618 |
+
|
| 619 |
+
# Modules can return a tensor, a tuple (take first item), or a
|
| 620 |
+
# dict (e.g. TinyLlamaModel returns {"last_hidden_state": ...}).
|
| 621 |
+
# Pull out the first real tensor we find; skip cleanly if none.
|
| 622 |
+
if isinstance(out, dict):
|
| 623 |
+
out_dict = out
|
| 624 |
+
out = out_dict.get("last_hidden_state")
|
| 625 |
+
if out is None:
|
| 626 |
+
out = next(
|
| 627 |
+
(v for v in out_dict.values() if torch.is_tensor(v)), None
|
| 628 |
+
)
|
| 629 |
+
elif isinstance(out, (tuple, list)):
|
| 630 |
+
out = out[0] if len(out) > 0 else None
|
| 631 |
+
|
| 632 |
+
if not torch.is_tensor(out):
|
| 633 |
+
return
|
| 634 |
+
|
| 635 |
+
stats = StatsEngine.compute(out.detach(), user_limit, dtype_ratio)
|
| 636 |
+
accumulator.add(f"act.{module_name}", out.numel(), stats)
|
| 637 |
+
|
| 638 |
+
return hook
|
| 639 |
+
|
| 640 |
+
def _make_backward_hook(
|
| 641 |
+
self, param_name: str, accumulator: StepAccumulator, user_limit: float, dtype_ratio: float
|
| 642 |
+
):
|
| 643 |
+
def hook(grad):
|
| 644 |
+
if not self.active:
|
| 645 |
+
return
|
| 646 |
+
stats = StatsEngine.compute(grad.detach(), user_limit, dtype_ratio)
|
| 647 |
+
accumulator.add(param_name, grad.numel(), stats)
|
| 648 |
+
|
| 649 |
+
return hook
|
| 650 |
+
|
| 651 |
+
def set_active(self, active: bool):
|
| 652 |
+
self.active = active
|
| 653 |
+
|
| 654 |
+
def clear(self):
|
| 655 |
+
for h in self.handles:
|
| 656 |
+
h.remove()
|
| 657 |
+
self.handles.clear()
|
| 658 |
+
|
| 659 |
+
|
| 660 |
+
class StabilityMonitorCallback(TrainerCallback):
|
| 661 |
+
"""
|
| 662 |
+
Full stability instrumentation: grad / param / act statistics
|
| 663 |
+
at global, per-layer, and per-tensor scope.
|
| 664 |
+
"""
|
| 665 |
+
|
| 666 |
+
def __init__(
|
| 667 |
+
self,
|
| 668 |
+
model: nn.Module,
|
| 669 |
+
monitor_every_n_steps: int = 10,
|
| 670 |
+
module_patterns: Optional[List[str]] = None,
|
| 671 |
+
user_limits: Optional[Dict[str, float]] = None,
|
| 672 |
+
dtype_proximity_ratio: float = 0.9,
|
| 673 |
+
log_scope: Optional[Dict[str, bool]] = None,
|
| 674 |
+
monitor_during_eval: bool = False,
|
| 675 |
+
):
|
| 676 |
+
self.model = model
|
| 677 |
+
self.monitor_every_n_steps = monitor_every_n_steps
|
| 678 |
+
self.module_patterns = module_patterns or [".*mlp.*", ".*self_attn.*"]
|
| 679 |
+
self.user_limits = user_limits or {"grad": 1.0, "param": 100.0, "act": 50.0}
|
| 680 |
+
self.dtype_ratio = dtype_proximity_ratio
|
| 681 |
+
self.log_scope = log_scope or {
|
| 682 |
+
"global": True,
|
| 683 |
+
"per_layer": True,
|
| 684 |
+
"per_tensor": False,
|
| 685 |
+
}
|
| 686 |
+
self.monitor_during_eval = monitor_during_eval
|
| 687 |
+
|
| 688 |
+
self.accumulator = StepAccumulator()
|
| 689 |
+
self.hooks = HookRegistry(model)
|
| 690 |
+
self.hooks.attach_forward(
|
| 691 |
+
self.module_patterns,
|
| 692 |
+
self.accumulator,
|
| 693 |
+
self.user_limits["act"],
|
| 694 |
+
self.dtype_ratio,
|
| 695 |
+
)
|
| 696 |
+
self.hooks.attach_backward(
|
| 697 |
+
self.accumulator, self.user_limits["grad"], self.dtype_ratio
|
| 698 |
+
)
|
| 699 |
+
|
| 700 |
+
self.pending_metrics: Optional[Dict[str, float]] = None
|
| 701 |
+
|
| 702 |
+
def _should_monitor(self, state) -> bool:
|
| 703 |
+
return state.global_step % self.monitor_every_n_steps == 0
|
| 704 |
+
|
| 705 |
+
def on_step_begin(self, args, state, control, **kwargs):
|
| 706 |
+
if self._should_monitor(state):
|
| 707 |
+
self.accumulator.clear()
|
| 708 |
+
self.hooks.set_active(True)
|
| 709 |
+
|
| 710 |
+
def on_step_end(self, args, state, control, **kwargs):
|
| 711 |
+
if not self.hooks.active:
|
| 712 |
+
return
|
| 713 |
+
|
| 714 |
+
# Parameter stats (post-optimizer step)
|
| 715 |
+
for name, param in self.model.named_parameters():
|
| 716 |
+
stats = StatsEngine.compute(
|
| 717 |
+
param.data, self.user_limits["param"], self.dtype_ratio
|
| 718 |
+
)
|
| 719 |
+
self.accumulator.add(f"param.{name}", param.numel(), stats)
|
| 720 |
+
|
| 721 |
+
self.hooks.set_active(False)
|
| 722 |
+
self.pending_metrics = self._build_metrics()
|
| 723 |
+
|
| 724 |
+
@staticmethod
|
| 725 |
+
def _kind_of(name: str) -> str:
|
| 726 |
+
"""Classify a tensor key by its source: activation, gradient, or parameter."""
|
| 727 |
+
if name.startswith("act."):
|
| 728 |
+
return "act"
|
| 729 |
+
if name.startswith("grad."):
|
| 730 |
+
return "grad"
|
| 731 |
+
if name.startswith("param."):
|
| 732 |
+
return "param"
|
| 733 |
+
return "other"
|
| 734 |
+
|
| 735 |
+
@staticmethod
|
| 736 |
+
def _strip_kind(name: str) -> str:
|
| 737 |
+
if name.startswith("act."):
|
| 738 |
+
return name[4:]
|
| 739 |
+
if name.startswith(("grad.", "param.")):
|
| 740 |
+
return name[5:]
|
| 741 |
+
return name
|
| 742 |
+
|
| 743 |
+
def _build_metrics(self, scope: str = "train") -> Dict[str, float]:
|
| 744 |
+
metrics: Dict[str, float] = {}
|
| 745 |
+
|
| 746 |
+
# --- Global (split by kind: act / grad / param — never pooled together) ---
|
| 747 |
+
if self.log_scope.get("global", True):
|
| 748 |
+
by_kind: Dict[str, Dict[str, Dict[str, float]]] = {}
|
| 749 |
+
for k, v in self.accumulator.tensors.items():
|
| 750 |
+
by_kind.setdefault(self._kind_of(k), {})[k] = v
|
| 751 |
+
|
| 752 |
+
for kind, entries in by_kind.items():
|
| 753 |
+
stats = self.accumulator._aggregate(entries)
|
| 754 |
+
for kk, vv in stats.items():
|
| 755 |
+
metrics[f"{scope}/global/{kind}/{kk}"] = vv
|
| 756 |
+
|
| 757 |
+
# --- Per-layer (group by model.layers.{i}, split by kind) ---
|
| 758 |
+
if self.log_scope.get("per_layer", True):
|
| 759 |
+
layer_prefixes = set()
|
| 760 |
+
for name in self.accumulator.tensors:
|
| 761 |
+
clean = self._strip_kind(name)
|
| 762 |
+
parts = clean.split(".")
|
| 763 |
+
for i, p in enumerate(parts):
|
| 764 |
+
if p == "layers" and i + 1 < len(parts):
|
| 765 |
+
prefix = ".".join(parts[: i + 2])
|
| 766 |
+
layer_prefixes.add(prefix)
|
| 767 |
+
|
| 768 |
+
for prefix in layer_prefixes:
|
| 769 |
+
by_kind: Dict[str, Dict[str, Dict[str, float]]] = {}
|
| 770 |
+
for k, v in self.accumulator.tensors.items():
|
| 771 |
+
clean = self._strip_kind(k)
|
| 772 |
+
if clean.startswith(prefix + ".") or clean == prefix:
|
| 773 |
+
by_kind.setdefault(self._kind_of(k), {})[k] = v
|
| 774 |
+
|
| 775 |
+
safe = prefix.replace(".", "_")
|
| 776 |
+
for kind, entries in by_kind.items():
|
| 777 |
+
if not entries:
|
| 778 |
+
continue
|
| 779 |
+
stats = self.accumulator._aggregate(entries)
|
| 780 |
+
for kk, vv in stats.items():
|
| 781 |
+
metrics[f"{scope}/layer_{safe}/{kind}/{kk}"] = vv
|
| 782 |
+
|
| 783 |
+
# --- Per-tensor ---
|
| 784 |
+
if self.log_scope.get("per_tensor", False):
|
| 785 |
+
for name, stats in self.accumulator.tensors.items():
|
| 786 |
+
safe = name.replace(".", "_")
|
| 787 |
+
for kk, vv in stats.items():
|
| 788 |
+
if kk == "numel":
|
| 789 |
+
continue
|
| 790 |
+
metrics[f"{scope}/tensor_{safe}/{kk}"] = vv
|
| 791 |
+
|
| 792 |
+
return metrics
|
| 793 |
+
|
| 794 |
+
def on_log(self, args, state, control, logs=None, **kwargs):
|
| 795 |
+
if logs is not None and self.pending_metrics is not None:
|
| 796 |
+
logs.update(self.pending_metrics)
|
| 797 |
+
self.pending_metrics = None
|
| 798 |
+
|
| 799 |
+
def on_prediction_step(self, args, state, control, **kwargs):
|
| 800 |
+
"""Fires once per eval/predict batch. Trainer.evaluate() calls this
|
| 801 |
+
for every batch in the eval loop, then calls self.log(output.metrics)
|
| 802 |
+
(which dispatches on_log to every callback, including the wandb/
|
| 803 |
+
tensorboard reporting callbacks) BEFORE on_evaluate() runs. So to get
|
| 804 |
+
eval-time stats into that same on_log dispatch, we have to build
|
| 805 |
+
pending_metrics here, not in on_evaluate — by the time on_evaluate
|
| 806 |
+
fires, self.log() has already happened and it's too late.
|
| 807 |
+
"""
|
| 808 |
+
if not self.monitor_during_eval:
|
| 809 |
+
return
|
| 810 |
+
if not self.hooks.active:
|
| 811 |
+
# First batch of this eval pass: start a fresh accumulation and
|
| 812 |
+
# snapshot parameter stats once (they don't change during eval).
|
| 813 |
+
self.accumulator.clear()
|
| 814 |
+
self.hooks.set_active(True)
|
| 815 |
+
for name, param in self.model.named_parameters():
|
| 816 |
+
stats = StatsEngine.compute(
|
| 817 |
+
param.data, self.user_limits["param"], self.dtype_ratio
|
| 818 |
+
)
|
| 819 |
+
self.accumulator.add(f"param.{name}", param.numel(), stats)
|
| 820 |
+
self.pending_metrics = self._build_metrics(scope="eval")
|
| 821 |
+
|
| 822 |
+
def on_evaluate(self, args, state, control, metrics=None, **kwargs):
|
| 823 |
+
self.hooks.set_active(False)
|
| 824 |
+
self.accumulator.clear()
|
| 825 |
+
|
| 826 |
+
|
| 827 |
+
class TimeTrackerCallback(TrainerCallback):
|
| 828 |
+
"""Precise training & eval timing with remaining-time estimates."""
|
| 829 |
+
|
| 830 |
+
def __init__(self):
|
| 831 |
+
self.step_start: Optional[float] = None
|
| 832 |
+
self.epoch_start: Optional[float] = None
|
| 833 |
+
self.total_train_time = 0.0
|
| 834 |
+
self.step_times: List[float] = []
|
| 835 |
+
|
| 836 |
+
def on_epoch_begin(self, args, state, control, **kwargs):
|
| 837 |
+
self.epoch_start = time.perf_counter()
|
| 838 |
+
|
| 839 |
+
def on_step_begin(self, args, state, control, **kwargs):
|
| 840 |
+
self.step_start = time.perf_counter()
|
| 841 |
+
|
| 842 |
+
def on_step_end(self, args, state, control, **kwargs):
|
| 843 |
+
if self.step_start is not None:
|
| 844 |
+
dt = time.perf_counter() - self.step_start
|
| 845 |
+
self.step_times.append(dt)
|
| 846 |
+
self.total_train_time += dt
|
| 847 |
+
self.step_start = None
|
| 848 |
+
|
| 849 |
+
def on_log(self, args, state, control, logs=None, **kwargs):
|
| 850 |
+
if logs is None:
|
| 851 |
+
return
|
| 852 |
+
|
| 853 |
+
logs["train/total_time_seconds"] = self.total_train_time
|
| 854 |
+
|
| 855 |
+
if self.step_times:
|
| 856 |
+
recent = self.step_times[-100:]
|
| 857 |
+
logs["train/time_per_step_avg"] = sum(recent) / len(recent)
|
| 858 |
+
|
| 859 |
+
if self.epoch_start is not None:
|
| 860 |
+
logs["train/epoch_time_elapsed"] = time.perf_counter() - self.epoch_start
|
| 861 |
+
|
| 862 |
+
if state.max_steps and state.global_step > 0:
|
| 863 |
+
avg = self.total_train_time / state.global_step
|
| 864 |
+
remaining = (state.max_steps - state.global_step) * avg
|
| 865 |
+
logs["train/estimated_remaining_minutes"] = remaining / 60.0
|
| 866 |
+
|
| 867 |
+
def on_evaluate(self, args, state, control, metrics=None, **kwargs):
|
| 868 |
+
pass
|
| 869 |
+
|
| 870 |
+
|
| 871 |
+
class MetricsLoggerCallback(TrainerCallback):
|
| 872 |
+
"""Persist every logged dict as JSONL in the output dir."""
|
| 873 |
+
|
| 874 |
+
def __init__(self, output_dir: str):
|
| 875 |
+
self.output_dir = Path(output_dir)
|
| 876 |
+
self.output_dir.mkdir(parents=True, exist_ok=True)
|
| 877 |
+
self.log_file = self.output_dir / "training_log.jsonl"
|
| 878 |
+
|
| 879 |
+
def on_log(self, args, state, control, logs=None, **kwargs):
|
| 880 |
+
if logs is None:
|
| 881 |
+
return
|
| 882 |
+
entry = {
|
| 883 |
+
"step": state.global_step,
|
| 884 |
+
"epoch": state.epoch,
|
| 885 |
+
"timestamp": time.time(),
|
| 886 |
+
**logs,
|
| 887 |
+
}
|
| 888 |
+
with open(self.log_file, "a") as f:
|
| 889 |
+
f.write(json.dumps(entry, default=str) + "\n")
|
| 890 |
+
|
| 891 |
+
|
| 892 |
+
# =============================================================================
|
| 893 |
+
# 5. DATA & TRAINER FACTORY
|
| 894 |
+
# =============================================================================
|
| 895 |
+
|
| 896 |
+
def build_dataset(
|
| 897 |
+
tokenizer,
|
| 898 |
+
max_seq_len: int = 512,
|
| 899 |
+
split: str = "train",
|
| 900 |
+
dataset_name: str = "roneneldan/TinyStories",
|
| 901 |
+
):
|
| 902 |
+
"""Concatenate and chunk TinyStories for causal LM. Fast path with multiprocessing."""
|
| 903 |
+
ds = load_dataset(dataset_name, split=split)
|
| 904 |
+
|
| 905 |
+
def tokenize(examples):
|
| 906 |
+
# add_special_tokens=False so we control separators ourselves.
|
| 907 |
+
# Without an explicit boundary token, group_texts() below would
|
| 908 |
+
# concatenate unrelated stories back-to-back with nothing marking
|
| 909 |
+
# where one ends and the next begins, teaching the model spurious
|
| 910 |
+
# cross-document continuations. Append EOS to each example so every
|
| 911 |
+
# packed chunk still carries a clear "new document" signal.
|
| 912 |
+
out = tokenizer(examples["text"], add_special_tokens=False)
|
| 913 |
+
eos_id = tokenizer.eos_token_id
|
| 914 |
+
out["input_ids"] = [ids + [eos_id] for ids in out["input_ids"]]
|
| 915 |
+
if "attention_mask" in out:
|
| 916 |
+
out["attention_mask"] = [mask + [1] for mask in out["attention_mask"]]
|
| 917 |
+
return out
|
| 918 |
+
|
| 919 |
+
tokenized = ds.map(
|
| 920 |
+
tokenize,
|
| 921 |
+
batched=True,
|
| 922 |
+
num_proc=4,
|
| 923 |
+
remove_columns=ds.column_names,
|
| 924 |
+
desc=f"Tokenizing {split}",
|
| 925 |
+
)
|
| 926 |
+
|
| 927 |
+
def group_texts(examples):
|
| 928 |
+
# chain.from_iterable is O(total) instead of O(n²)
|
| 929 |
+
concatenated = {
|
| 930 |
+
k: list(chain.from_iterable(examples[k])) for k in examples.keys()
|
| 931 |
+
}
|
| 932 |
+
total_length = len(concatenated[list(examples.keys())[0]])
|
| 933 |
+
total_length = (total_length // max_seq_len) * max_seq_len
|
| 934 |
+
result = {
|
| 935 |
+
k: [t[i : i + max_seq_len] for i in range(0, total_length, max_seq_len)]
|
| 936 |
+
for k, t in concatenated.items()
|
| 937 |
+
}
|
| 938 |
+
result["labels"] = result["input_ids"].copy()
|
| 939 |
+
return result
|
| 940 |
+
|
| 941 |
+
return tokenized.map(
|
| 942 |
+
group_texts,
|
| 943 |
+
batched=True,
|
| 944 |
+
batch_size=10000,
|
| 945 |
+
num_proc=4,
|
| 946 |
+
desc=f"Chunking {split}",
|
| 947 |
+
)
|
| 948 |
+
|
| 949 |
+
|
| 950 |
+
def create_trainer(
|
| 951 |
+
model,
|
| 952 |
+
tokenizer,
|
| 953 |
+
config: Dict[str, Any],
|
| 954 |
+
train_dataset,
|
| 955 |
+
eval_dataset=None,
|
| 956 |
+
):
|
| 957 |
+
"""Assemble HF Trainer with all custom callbacks."""
|
| 958 |
+
tc = config.get("training", {})
|
| 959 |
+
mc = config.get("monitor", {})
|
| 960 |
+
|
| 961 |
+
# Allow override of run_name via config (used by sweep)
|
| 962 |
+
run_name = tc.get("run_name", None)
|
| 963 |
+
|
| 964 |
+
args = TrainingArguments(
|
| 965 |
+
output_dir=tc.get("output_dir", "./out"),
|
| 966 |
+
run_name=run_name, # explicit run name for WandB
|
| 967 |
+
num_train_epochs=tc.get("num_train_epochs", 3),
|
| 968 |
+
per_device_train_batch_size=tc.get("per_device_train_batch_size", 16),
|
| 969 |
+
per_device_eval_batch_size=tc.get("per_device_eval_batch_size", 16),
|
| 970 |
+
gradient_accumulation_steps=tc.get("gradient_accumulation_steps", 4),
|
| 971 |
+
learning_rate=tc.get("learning_rate", 3e-4),
|
| 972 |
+
weight_decay=tc.get("weight_decay", 0.0),
|
| 973 |
+
max_grad_norm=tc.get("max_grad_norm", 1.0),
|
| 974 |
+
optim=tc.get("optim", "adamw_torch"),
|
| 975 |
+
warmup_steps=tc.get("warmup_steps", 0),
|
| 976 |
+
lr_scheduler_type=tc.get("lr_scheduler_type", "cosine"),
|
| 977 |
+
bf16=tc.get("bf16", True),
|
| 978 |
+
logging_steps=tc.get("logging_steps", 10),
|
| 979 |
+
eval_strategy=tc.get("eval_strategy", "steps"),
|
| 980 |
+
eval_steps=tc.get("eval_steps", 500),
|
| 981 |
+
save_strategy=tc.get("save_strategy", "steps"),
|
| 982 |
+
save_steps=tc.get("save_steps", 1000),
|
| 983 |
+
load_best_model_at_end=tc.get("load_best_model_at_end", False),
|
| 984 |
+
report_to=tc.get("report_to", "tensorboard"),
|
| 985 |
+
push_to_hub=tc.get("push_to_hub", False),
|
| 986 |
+
hub_model_id=tc.get("hub_model_id", None),
|
| 987 |
+
# Never commit real tokens to config files. Prefer an explicit value
|
| 988 |
+
# in the config only if someone deliberately put one there; normal
|
| 989 |
+
# case is HF_TOKEN in the environment.
|
| 990 |
+
hub_token=tc.get("hub_token") or os.environ.get("HF_TOKEN"),
|
| 991 |
+
max_steps=tc.get("max_steps", -1),
|
| 992 |
+
seed=tc.get("seed", 42),
|
| 993 |
+
data_seed=tc.get("data_seed", 42),
|
| 994 |
+
remove_unused_columns=False,
|
| 995 |
+
)
|
| 996 |
+
|
| 997 |
+
callbacks = [
|
| 998 |
+
TimeTrackerCallback(),
|
| 999 |
+
]
|
| 1000 |
+
|
| 1001 |
+
if mc.get("enabled", True):
|
| 1002 |
+
callbacks.append(
|
| 1003 |
+
StabilityMonitorCallback(
|
| 1004 |
+
model=model,
|
| 1005 |
+
monitor_every_n_steps=mc.get("monitor_every_n_steps", 10),
|
| 1006 |
+
module_patterns=mc.get("module_patterns", [".*mlp.*", ".*self_attn.*"]),
|
| 1007 |
+
user_limits=mc.get(
|
| 1008 |
+
"user_limits", {"grad": 1.0, "param": 100.0, "act": 50.0}
|
| 1009 |
+
),
|
| 1010 |
+
dtype_proximity_ratio=mc.get("dtype_proximity_ratio", 0.9),
|
| 1011 |
+
log_scope=mc.get(
|
| 1012 |
+
"log_scope",
|
| 1013 |
+
{"global": True, "per_layer": True, "per_tensor": False},
|
| 1014 |
+
),
|
| 1015 |
+
monitor_during_eval=mc.get("monitor_during_eval", False),
|
| 1016 |
+
)
|
| 1017 |
+
)
|
| 1018 |
+
|
| 1019 |
+
# Must be added LAST: on_log() writes the shared `logs` dict to disk, so
|
| 1020 |
+
# every callback that injects keys into that dict (e.g. StabilityMonitor's
|
| 1021 |
+
# max_abs/norm/std stats) needs to run BEFORE this one, not after.
|
| 1022 |
+
callbacks.append(MetricsLoggerCallback(args.output_dir))
|
| 1023 |
+
|
| 1024 |
+
collator = DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm=False)
|
| 1025 |
+
|
| 1026 |
+
trainer = Trainer(
|
| 1027 |
+
model=model,
|
| 1028 |
+
args=args,
|
| 1029 |
+
train_dataset=train_dataset,
|
| 1030 |
+
eval_dataset=eval_dataset,
|
| 1031 |
+
data_collator=collator,
|
| 1032 |
+
callbacks=callbacks,
|
| 1033 |
+
)
|
| 1034 |
+
|
| 1035 |
+
# Trainer.__init__ builds its callback list as:
|
| 1036 |
+
# [DEFAULT_CALLBACKS..., <report_to integrations, e.g. WandbCallback>,
|
| 1037 |
+
# *our callbacks (TimeTracker, StabilityMonitor, MetricsLogger)]
|
| 1038 |
+
# All callbacks share the *same* `logs` dict object on on_log(), and are
|
| 1039 |
+
# invoked in that list order. That means WandbCallback.on_log() was
|
| 1040 |
+
# reading `logs` and shipping it off BEFORE TimeTrackerCallback /
|
| 1041 |
+
# StabilityMonitorCallback ever mutated it with their train/global/*,
|
| 1042 |
+
# train/layer_*, eval/* keys — so those metrics only ever reached the
|
| 1043 |
+
# local training_log.jsonl (written by our MetricsLoggerCallback, which
|
| 1044 |
+
# happens to run after within our own sublist) and never wandb.
|
| 1045 |
+
# Move every reporting-integration callback to the very end so all of
|
| 1046 |
+
# our metric-producing callbacks mutate `logs` first.
|
| 1047 |
+
try:
|
| 1048 |
+
from transformers.integrations import get_reporting_integration_callbacks
|
| 1049 |
+
|
| 1050 |
+
reporting_types = tuple(get_reporting_integration_callbacks(args.report_to))
|
| 1051 |
+
except Exception:
|
| 1052 |
+
reporting_types = ()
|
| 1053 |
+
|
| 1054 |
+
if reporting_types:
|
| 1055 |
+
handler = trainer.callback_handler
|
| 1056 |
+
reporting_cbs = [cb for cb in handler.callbacks if isinstance(cb, reporting_types)]
|
| 1057 |
+
other_cbs = [cb for cb in handler.callbacks if not isinstance(cb, reporting_types)]
|
| 1058 |
+
handler.callbacks = other_cbs + reporting_cbs
|
| 1059 |
+
|
| 1060 |
+
return trainer
|
h.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Re-occupy GPU3: relaunch the JSL-Med-9B-v3.2 vLLM server (port 8010).
|
| 3 |
+
set -uo pipefail
|
| 4 |
+
SERVE_SCRIPT=/mnt/data/zainulabideen/aws/serve_jsl_9b_v3_2.sh
|
| 5 |
+
LOG=/mnt/data/zainulabideen/Data/RV3/fine_tune/logs/serve_jsl_9b_v3_2_resume.log
|
| 6 |
+
echo ">> checking GPU3 is free before starting..."
|
| 7 |
+
USED=$(nvidia-smi -i 3 --query-gpu=memory.used --format=csv,noheader,nounits)
|
| 8 |
+
if [ "$USED" -gt 5000 ]; then
|
| 9 |
+
echo ">> GPU3 has ${USED} MiB in use — someone else may be using it. Run free-gpu3.sh first if that's stale."
|
| 10 |
+
exit 1
|
| 11 |
+
fi
|
| 12 |
+
echo ">> launching JSL-Med-9B-v3.2 on GPU3, port 8010..."
|
| 13 |
+
nohup bash "$SERVE_SCRIPT" > "$LOG" 2>&1 &
|
| 14 |
+
disown
|
| 15 |
+
echo ">> launched, PID $!"
|
| 16 |
+
echo ">> waiting for health check..."
|
| 17 |
+
for i in $(seq 1 40); do
|
| 18 |
+
r=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8010/v1/models -H "Authorization: Bearer jsl-1" 2>/dev/null)
|
| 19 |
+
if [ "$r" == "200" ]; then
|
| 20 |
+
echo ">>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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Multi-LLM Activation & Loss Analyzer with WandB Logging
|
| 3 |
+
|
| 4 |
+
Evaluates multiple language models on WikiText dataset,
|
| 5 |
+
computing per-tensor and global activation statistics (mean, max_abs, std, norm)
|
| 6 |
+
and logging to Weights & Biases with separate runs per model.
|
| 7 |
+
|
| 8 |
+
Requirements:
|
| 9 |
+
pip install transformers torch datasets wandb tqdm
|
| 10 |
+
|
| 11 |
+
Usage:
|
| 12 |
+
export WANDB_PROJECT="llm-activation-analysis"
|
| 13 |
+
export WANDB_API_KEY="your-key"
|
| 14 |
+
python llm_analyzer_wandb.py
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
import math
|
| 18 |
+
import torch
|
| 19 |
+
import torch.nn.functional as F
|
| 20 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, AutoConfig
|
| 21 |
+
from datasets import load_dataset
|
| 22 |
+
from typing import List, Dict, Optional, Union, Tuple
|
| 23 |
+
from dataclasses import dataclass, asdict
|
| 24 |
+
from collections import defaultdict
|
| 25 |
+
import json
|
| 26 |
+
import warnings
|
| 27 |
+
import os
|
| 28 |
+
from tqdm import tqdm
|
| 29 |
+
|
| 30 |
+
import wandb
|
| 31 |
+
|
| 32 |
+
warnings.filterwarnings("ignore")
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
@dataclass
|
| 36 |
+
class TensorStats:
|
| 37 |
+
mean: float
|
| 38 |
+
max_abs: float
|
| 39 |
+
std: float
|
| 40 |
+
norm: float
|
| 41 |
+
numel: int
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
@dataclass
|
| 45 |
+
class ModelResult:
|
| 46 |
+
model_name: str
|
| 47 |
+
loss: float
|
| 48 |
+
perplexity: float
|
| 49 |
+
global_act: TensorStats
|
| 50 |
+
layer_acts: Dict[str, TensorStats]
|
| 51 |
+
num_tokens: int
|
| 52 |
+
num_layers: int
|
| 53 |
+
hidden_size: int
|
| 54 |
+
num_params: int
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class ActivationHookManager:
|
| 58 |
+
"""Manages forward hooks to capture activations from every tensor."""
|
| 59 |
+
|
| 60 |
+
def __init__(self):
|
| 61 |
+
self.activations = {}
|
| 62 |
+
self.hooks = []
|
| 63 |
+
# Set once per batch via set_attention_mask(); used to exclude
|
| 64 |
+
# padding-token positions from activation statistics.
|
| 65 |
+
self._attention_mask: Optional[torch.Tensor] = None
|
| 66 |
+
|
| 67 |
+
def set_attention_mask(self, attention_mask: Optional[torch.Tensor]):
|
| 68 |
+
"""Call once per batch before the forward pass so hooks can mask
|
| 69 |
+
out padding positions when computing stats."""
|
| 70 |
+
self._attention_mask = (
|
| 71 |
+
attention_mask.detach().cpu() if attention_mask is not None else None
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
def _make_hook(self, name: str):
|
| 75 |
+
def hook(module, input, output):
|
| 76 |
+
# Handle different output types
|
| 77 |
+
if isinstance(output, torch.Tensor):
|
| 78 |
+
tensor = output
|
| 79 |
+
elif isinstance(output, tuple) and isinstance(output[0], torch.Tensor):
|
| 80 |
+
tensor = output[0]
|
| 81 |
+
else:
|
| 82 |
+
return
|
| 83 |
+
|
| 84 |
+
# Detach and move to CPU to avoid GPU memory blowup
|
| 85 |
+
self.activations[name] = tensor.detach().cpu().float()
|
| 86 |
+
return hook
|
| 87 |
+
|
| 88 |
+
def register_hooks(self, model: torch.nn.Module):
|
| 89 |
+
"""Register hooks on all modules that produce activations."""
|
| 90 |
+
for name, module in model.named_modules():
|
| 91 |
+
# Skip trivial containers
|
| 92 |
+
if len(list(module.children())) == 0 and hasattr(module, 'forward'):
|
| 93 |
+
hook = module.register_forward_hook(self._make_hook(name))
|
| 94 |
+
self.hooks.append(hook)
|
| 95 |
+
|
| 96 |
+
def clear(self):
|
| 97 |
+
self.activations.clear()
|
| 98 |
+
|
| 99 |
+
def remove_hooks(self):
|
| 100 |
+
for hook in self.hooks:
|
| 101 |
+
hook.remove()
|
| 102 |
+
self.hooks.clear()
|
| 103 |
+
|
| 104 |
+
def _select_real_tokens(self, tensor: torch.Tensor) -> torch.Tensor:
|
| 105 |
+
"""
|
| 106 |
+
BUG FIX: previously every captured tensor (including activations at
|
| 107 |
+
padding-token positions) was flattened and used as-is. With
|
| 108 |
+
padding_side="left" and a small batch_size, the padding fraction
|
| 109 |
+
varies a lot batch-to-batch, so padding-token activations (which
|
| 110 |
+
are real, non-zero values — not zeros) were silently mixed into
|
| 111 |
+
mean/std/max_abs/norm, biasing exactly the saturation signal this
|
| 112 |
+
script exists to measure.
|
| 113 |
+
|
| 114 |
+
Here we mask out padding positions whenever a tensor's shape is
|
| 115 |
+
consistent with (batch, seq_len, ...) against the stored
|
| 116 |
+
attention_mask (batch, seq_len). Tensors that don't match that
|
| 117 |
+
shape (e.g. a module operating on the pooled/final dimension only)
|
| 118 |
+
are left as-is rather than guessing.
|
| 119 |
+
"""
|
| 120 |
+
mask = self._attention_mask
|
| 121 |
+
if mask is None or tensor.dim() < 2:
|
| 122 |
+
return tensor.reshape(-1)
|
| 123 |
+
if tensor.shape[0] != mask.shape[0] or tensor.shape[1] != mask.shape[1]:
|
| 124 |
+
return tensor.reshape(-1)
|
| 125 |
+
|
| 126 |
+
bool_mask = mask.bool()
|
| 127 |
+
# Expand mask across any trailing dims (e.g. hidden_size) and select.
|
| 128 |
+
expand_shape = bool_mask.shape + (1,) * (tensor.dim() - 2)
|
| 129 |
+
bool_mask = bool_mask.view(expand_shape).expand_as(tensor)
|
| 130 |
+
return tensor[bool_mask].reshape(-1)
|
| 131 |
+
|
| 132 |
+
def compute_stats(self) -> Dict[str, TensorStats]:
|
| 133 |
+
"""Compute statistics for all captured activations, excluding
|
| 134 |
+
padding-token positions where identifiable."""
|
| 135 |
+
stats = {}
|
| 136 |
+
for name, tensor in self.activations.items():
|
| 137 |
+
if tensor.numel() == 0:
|
| 138 |
+
continue
|
| 139 |
+
flat = self._select_real_tokens(tensor)
|
| 140 |
+
if flat.numel() == 0:
|
| 141 |
+
continue
|
| 142 |
+
stats[name] = TensorStats(
|
| 143 |
+
mean=flat.mean().item(),
|
| 144 |
+
max_abs=flat.abs().max().item(),
|
| 145 |
+
std=flat.std().item(),
|
| 146 |
+
norm=flat.norm().item(),
|
| 147 |
+
numel=flat.numel()
|
| 148 |
+
)
|
| 149 |
+
return stats
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
class LLMAnalyzer:
|
| 153 |
+
def __init__(
|
| 154 |
+
self,
|
| 155 |
+
device: Optional[str] = None,
|
| 156 |
+
max_length: int = 512,
|
| 157 |
+
max_samples: int = 1000, # number of wikitext samples to eval
|
| 158 |
+
batch_size: int = 4,
|
| 159 |
+
dtype: torch.dtype = torch.float16,
|
| 160 |
+
wandb_project: Optional[str] = None,
|
| 161 |
+
):
|
| 162 |
+
self.device = device or ("cuda" if torch.cuda.is_available() else "cpu")
|
| 163 |
+
self.max_length = max_length
|
| 164 |
+
self.max_samples = max_samples
|
| 165 |
+
self.batch_size = batch_size
|
| 166 |
+
self.dtype = dtype if self.device == "cuda" else torch.float32
|
| 167 |
+
self.wandb_project = wandb_project or os.environ.get("WANDB_PROJECT", "llm-activation-analysis")
|
| 168 |
+
self._cache = {}
|
| 169 |
+
|
| 170 |
+
def load_dataset(self, split: str = "test"):
|
| 171 |
+
"""Load Salesforce/wikitext dataset."""
|
| 172 |
+
print(f"[Dataset] Loading Salesforce/wikitext ({split}) ...")
|
| 173 |
+
ds = load_dataset("Salesforce/wikitext", "wikitext-2-raw-v1", split=split)
|
| 174 |
+
# Filter out empty lines
|
| 175 |
+
texts = [t for t in ds["text"] if len(t.strip()) > 50]
|
| 176 |
+
print(f"[Dataset] Loaded {len(texts)} non-empty samples")
|
| 177 |
+
return texts[:self.max_samples]
|
| 178 |
+
|
| 179 |
+
def load_model(self, model_name: str):
|
| 180 |
+
"""Load model and tokenizer with caching."""
|
| 181 |
+
if model_name in self._cache:
|
| 182 |
+
return self._cache[model_name]
|
| 183 |
+
|
| 184 |
+
print(f"[Loading] {model_name} ...")
|
| 185 |
+
|
| 186 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 187 |
+
model_name,
|
| 188 |
+
trust_remote_code=True,
|
| 189 |
+
padding_side="left"
|
| 190 |
+
)
|
| 191 |
+
if tokenizer.pad_token is None:
|
| 192 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 193 |
+
|
| 194 |
+
config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)
|
| 195 |
+
|
| 196 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 197 |
+
model_name,
|
| 198 |
+
config=config,
|
| 199 |
+
torch_dtype=self.dtype,
|
| 200 |
+
device_map="auto" if self.device == "cuda" else None,
|
| 201 |
+
trust_remote_code=True,
|
| 202 |
+
)
|
| 203 |
+
|
| 204 |
+
if self.device == "cpu":
|
| 205 |
+
model = model.to(self.device)
|
| 206 |
+
|
| 207 |
+
model.eval()
|
| 208 |
+
|
| 209 |
+
num_params = sum(p.numel() for p in model.parameters())
|
| 210 |
+
|
| 211 |
+
self._cache[model_name] = (tokenizer, model, config, num_params)
|
| 212 |
+
print(f"[Loaded] {model_name} | Params: {num_params/1e6:.1f}M | Layers: {config.num_hidden_layers} | Hidden: {config.hidden_size}")
|
| 213 |
+
return tokenizer, model, config, num_params
|
| 214 |
+
|
| 215 |
+
def compute(
|
| 216 |
+
self,
|
| 217 |
+
model_names: List[str],
|
| 218 |
+
) -> List[ModelResult]:
|
| 219 |
+
"""
|
| 220 |
+
Compute loss and per-tensor activation statistics for multiple models.
|
| 221 |
+
Logs each model as a separate WandB run.
|
| 222 |
+
"""
|
| 223 |
+
texts = self.load_dataset()
|
| 224 |
+
results = []
|
| 225 |
+
|
| 226 |
+
for model_name in model_names:
|
| 227 |
+
try:
|
| 228 |
+
result = self._evaluate_model(model_name, texts)
|
| 229 |
+
results.append(result)
|
| 230 |
+
except Exception as e:
|
| 231 |
+
print(f"[Error] {model_name}: {e}")
|
| 232 |
+
import traceback
|
| 233 |
+
traceback.print_exc()
|
| 234 |
+
continue
|
| 235 |
+
|
| 236 |
+
return results
|
| 237 |
+
|
| 238 |
+
def _evaluate_model(
|
| 239 |
+
self,
|
| 240 |
+
model_name: str,
|
| 241 |
+
texts: List[str],
|
| 242 |
+
) -> ModelResult:
|
| 243 |
+
tokenizer, model, config, num_params = self.load_model(model_name)
|
| 244 |
+
|
| 245 |
+
# Initialize WandB run for this model
|
| 246 |
+
run_name = model_name.replace("/", "-")
|
| 247 |
+
wandb.init(
|
| 248 |
+
project=self.wandb_project,
|
| 249 |
+
name=run_name,
|
| 250 |
+
config={
|
| 251 |
+
"model": model_name,
|
| 252 |
+
"max_length": self.max_length,
|
| 253 |
+
"max_samples": self.max_samples,
|
| 254 |
+
"batch_size": self.batch_size,
|
| 255 |
+
"dtype": str(self.dtype),
|
| 256 |
+
"num_params": num_params,
|
| 257 |
+
"num_layers": config.num_hidden_layers,
|
| 258 |
+
"hidden_size": config.hidden_size,
|
| 259 |
+
},
|
| 260 |
+
reinit=True
|
| 261 |
+
)
|
| 262 |
+
|
| 263 |
+
hook_mgr = ActivationHookManager()
|
| 264 |
+
hook_mgr.register_hooks(model)
|
| 265 |
+
|
| 266 |
+
total_loss = 0.0
|
| 267 |
+
total_tokens = 0
|
| 268 |
+
|
| 269 |
+
# Global activation accumulator
|
| 270 |
+
global_acts = []
|
| 271 |
+
|
| 272 |
+
# Per-layer activation accumulators
|
| 273 |
+
# We'll aggregate stats across batches, then compute final stats
|
| 274 |
+
layer_act_values = defaultdict(list)
|
| 275 |
+
|
| 276 |
+
num_batches = (len(texts) + self.batch_size - 1) // self.batch_size
|
| 277 |
+
|
| 278 |
+
for i in tqdm(range(0, len(texts), self.batch_size), desc=f"Eval {run_name}", total=num_batches):
|
| 279 |
+
batch_texts = texts[i:i + self.batch_size]
|
| 280 |
+
|
| 281 |
+
# Tokenize
|
| 282 |
+
inputs = tokenizer(
|
| 283 |
+
batch_texts,
|
| 284 |
+
return_tensors="pt",
|
| 285 |
+
truncation=True,
|
| 286 |
+
max_length=self.max_length,
|
| 287 |
+
padding=True
|
| 288 |
+
)
|
| 289 |
+
|
| 290 |
+
# Move to device
|
| 291 |
+
if self.device == "cuda" and hasattr(model, "device"):
|
| 292 |
+
# model is on auto device map
|
| 293 |
+
input_ids = inputs["input_ids"]
|
| 294 |
+
if hasattr(model, "device") and model.device != torch.device("meta"):
|
| 295 |
+
input_ids = input_ids.to(model.device)
|
| 296 |
+
attention_mask = inputs.get("attention_mask")
|
| 297 |
+
if attention_mask is not None:
|
| 298 |
+
attention_mask = attention_mask.to(input_ids.device)
|
| 299 |
+
else:
|
| 300 |
+
input_ids = inputs["input_ids"].to(self.device)
|
| 301 |
+
attention_mask = inputs.get("attention_mask")
|
| 302 |
+
if attention_mask is not None:
|
| 303 |
+
attention_mask = attention_mask.to(self.device)
|
| 304 |
+
|
| 305 |
+
labels = input_ids.clone()
|
| 306 |
+
|
| 307 |
+
# BUG FIX: with padding_side="left" and no explicit position_ids,
|
| 308 |
+
# HF's default `position_ids = arange(seq_len)` is applied
|
| 309 |
+
# identically to every row in the batch, regardless of how much
|
| 310 |
+
# left-padding precedes the real tokens in that row (verified
|
| 311 |
+
# against transformers' LlamaModel.forward / GPT2Model.forward
|
| 312 |
+
# source — neither adjusts for padding when position_ids=None).
|
| 313 |
+
# That means a real token's absolute position (and therefore its
|
| 314 |
+
# RoPE rotation / absolute position embedding) depends on how
|
| 315 |
+
# much padding happened to precede it in this particular batch,
|
| 316 |
+
# not on its logical position within its own sequence. This
|
| 317 |
+
# silently corrupts logits -> loss -> perplexity, with the
|
| 318 |
+
# amount of corruption varying batch-to-batch. Fix: derive
|
| 319 |
+
# position_ids from attention_mask so they restart at 0 for the
|
| 320 |
+
# first real token of every row, and are stable (0) on padding.
|
| 321 |
+
if attention_mask is not None:
|
| 322 |
+
position_ids = attention_mask.long().cumsum(-1) - 1
|
| 323 |
+
position_ids.masked_fill_(attention_mask == 0, 0)
|
| 324 |
+
else:
|
| 325 |
+
position_ids = None
|
| 326 |
+
|
| 327 |
+
hook_mgr.set_attention_mask(attention_mask)
|
| 328 |
+
|
| 329 |
+
with torch.no_grad():
|
| 330 |
+
outputs = model(
|
| 331 |
+
input_ids=input_ids,
|
| 332 |
+
attention_mask=attention_mask,
|
| 333 |
+
position_ids=position_ids,
|
| 334 |
+
labels=labels,
|
| 335 |
+
)
|
| 336 |
+
|
| 337 |
+
# --- Loss Computation ---
|
| 338 |
+
logits = outputs.logits
|
| 339 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
| 340 |
+
shift_labels = labels[..., 1:].contiguous()
|
| 341 |
+
shift_mask = attention_mask[..., 1:].contiguous() if attention_mask is not None else None
|
| 342 |
+
|
| 343 |
+
loss_fct = torch.nn.CrossEntropyLoss(reduction="none")
|
| 344 |
+
token_losses = loss_fct(
|
| 345 |
+
shift_logits.view(-1, shift_logits.size(-1)),
|
| 346 |
+
shift_labels.view(-1)
|
| 347 |
+
)
|
| 348 |
+
|
| 349 |
+
if shift_mask is not None:
|
| 350 |
+
token_losses = token_losses * shift_mask.view(-1)
|
| 351 |
+
num_valid_tokens = shift_mask.sum().item()
|
| 352 |
+
else:
|
| 353 |
+
num_valid_tokens = token_losses.numel()
|
| 354 |
+
|
| 355 |
+
batch_loss = token_losses.sum().item()
|
| 356 |
+
total_loss += batch_loss
|
| 357 |
+
total_tokens += num_valid_tokens
|
| 358 |
+
|
| 359 |
+
# --- Activation Statistics ---
|
| 360 |
+
# Get activations captured by hooks
|
| 361 |
+
act_stats = hook_mgr.compute_stats()
|
| 362 |
+
|
| 363 |
+
for name, stats in act_stats.items():
|
| 364 |
+
# Skip dtype-limit fraction metrics entirely
|
| 365 |
+
# We only log mean, max_abs, std, norm
|
| 366 |
+
|
| 367 |
+
# For global: aggregate raw values
|
| 368 |
+
# We can't store all raw values due to memory, so we store running sums
|
| 369 |
+
# But for accurate std across all batches, we need a streaming algorithm
|
| 370 |
+
# For simplicity and correctness, we'll store per-batch stats and weight them
|
| 371 |
+
layer_act_values[name].append(asdict(stats))
|
| 372 |
+
|
| 373 |
+
hook_mgr.clear()
|
| 374 |
+
|
| 375 |
+
# Log per-batch metrics to wandb
|
| 376 |
+
if num_valid_tokens > 0:
|
| 377 |
+
batch_avg_loss = batch_loss / num_valid_tokens
|
| 378 |
+
wandb.log({
|
| 379 |
+
"batch_loss": batch_avg_loss,
|
| 380 |
+
"batch_perplexity": torch.exp(torch.tensor(batch_avg_loss)).item(),
|
| 381 |
+
"batch_tokens": num_valid_tokens,
|
| 382 |
+
"progress": i / len(texts)
|
| 383 |
+
}, step=i)
|
| 384 |
+
|
| 385 |
+
hook_mgr.remove_hooks()
|
| 386 |
+
|
| 387 |
+
# --- Final Aggregation ---
|
| 388 |
+
avg_loss = total_loss / max(total_tokens, 1)
|
| 389 |
+
perplexity = torch.exp(torch.tensor(avg_loss)).item()
|
| 390 |
+
|
| 391 |
+
# Aggregate per-tensor stats across all batches
|
| 392 |
+
# Weighted by numel for mean, max for max_abs, pooled std, pooled norm
|
| 393 |
+
final_layer_stats = {}
|
| 394 |
+
|
| 395 |
+
for name, batch_stats_list in layer_act_values.items():
|
| 396 |
+
total_numel = sum(s["numel"] for s in batch_stats_list)
|
| 397 |
+
if total_numel == 0:
|
| 398 |
+
continue
|
| 399 |
+
|
| 400 |
+
# Weighted mean
|
| 401 |
+
weighted_mean = sum(s["mean"] * s["numel"] for s in batch_stats_list) / total_numel
|
| 402 |
+
|
| 403 |
+
# Max abs across all batches
|
| 404 |
+
max_abs = max(s["max_abs"] for s in batch_stats_list)
|
| 405 |
+
|
| 406 |
+
# BUG FIX: the previous formula (weighted average of per-batch
|
| 407 |
+
# variances only) drops the between-batch term that accounts for
|
| 408 |
+
# per-batch means differing from the global mean. Whenever batch
|
| 409 |
+
# means differ (they will — different texts, different lengths),
|
| 410 |
+
# this systematically UNDERESTIMATES the true global std — in a
|
| 411 |
+
# quick numeric test with two batches of different means this was
|
| 412 |
+
# off by ~2.8x. Correct pooled-variance formula (population form,
|
| 413 |
+
# matches exp.py's StepAccumulator._merge_entry):
|
| 414 |
+
# E[X^2] = weighted_avg(var_i + mean_i^2)
|
| 415 |
+
# Var(X) = E[X^2] - mean_global^2
|
| 416 |
+
ex2 = sum(
|
| 417 |
+
s["numel"] * (s["std"] ** 2 + s["mean"] ** 2) for s in batch_stats_list
|
| 418 |
+
) / total_numel
|
| 419 |
+
pooled_std = math.sqrt(max(0.0, ex2 - weighted_mean ** 2))
|
| 420 |
+
|
| 421 |
+
# Norm: sqrt(sum of squared norms / total_numel) * sqrt(total_numel)
|
| 422 |
+
# Actually norm^2 = sum(x_i^2), so pooled_norm = sqrt(sum(norm_i^2))
|
| 423 |
+
pooled_norm = (sum(s["norm"] ** 2 for s in batch_stats_list)) ** 0.5
|
| 424 |
+
|
| 425 |
+
final_layer_stats[name] = TensorStats(
|
| 426 |
+
mean=weighted_mean,
|
| 427 |
+
max_abs=max_abs,
|
| 428 |
+
std=pooled_std,
|
| 429 |
+
norm=pooled_norm,
|
| 430 |
+
numel=total_numel
|
| 431 |
+
)
|
| 432 |
+
|
| 433 |
+
# Compute global stats across all layers
|
| 434 |
+
if final_layer_stats:
|
| 435 |
+
all_numel = sum(s.numel for s in final_layer_stats.values())
|
| 436 |
+
global_mean = sum(s.mean * s.numel for s in final_layer_stats.values()) / all_numel
|
| 437 |
+
global_max_abs = max(s.max_abs for s in final_layer_stats.values())
|
| 438 |
+
# Same pooled-std correction as above — same bug was present here.
|
| 439 |
+
global_ex2 = sum(
|
| 440 |
+
s.numel * (s.std ** 2 + s.mean ** 2) for s in final_layer_stats.values()
|
| 441 |
+
) / all_numel
|
| 442 |
+
global_std = math.sqrt(max(0.0, global_ex2 - global_mean ** 2))
|
| 443 |
+
global_norm = (sum(s.norm ** 2 for s in final_layer_stats.values())) ** 0.5
|
| 444 |
+
|
| 445 |
+
global_stats = TensorStats(
|
| 446 |
+
mean=global_mean,
|
| 447 |
+
max_abs=global_max_abs,
|
| 448 |
+
std=global_std,
|
| 449 |
+
norm=global_norm,
|
| 450 |
+
numel=all_numel
|
| 451 |
+
)
|
| 452 |
+
else:
|
| 453 |
+
global_stats = TensorStats(0.0, 0.0, 0.0, 0.0, 0)
|
| 454 |
+
|
| 455 |
+
result = ModelResult(
|
| 456 |
+
model_name=model_name,
|
| 457 |
+
loss=avg_loss,
|
| 458 |
+
perplexity=perplexity,
|
| 459 |
+
global_act=global_stats,
|
| 460 |
+
layer_acts=final_layer_stats,
|
| 461 |
+
num_tokens=total_tokens,
|
| 462 |
+
num_layers=config.num_hidden_layers,
|
| 463 |
+
hidden_size=config.hidden_size,
|
| 464 |
+
num_params=num_params
|
| 465 |
+
)
|
| 466 |
+
|
| 467 |
+
# --- WandB Logging ---
|
| 468 |
+
self._log_to_wandb(result)
|
| 469 |
+
wandb.finish()
|
| 470 |
+
|
| 471 |
+
return result
|
| 472 |
+
|
| 473 |
+
def _log_to_wandb(self, result: ModelResult):
|
| 474 |
+
"""Log final metrics to WandB. No frac_near_dtype_limit."""
|
| 475 |
+
|
| 476 |
+
# Global metrics
|
| 477 |
+
wandb.log({
|
| 478 |
+
"final/loss": result.loss,
|
| 479 |
+
"final/perplexity": result.perplexity,
|
| 480 |
+
"final/num_tokens": result.num_tokens,
|
| 481 |
+
|
| 482 |
+
"train/global/act/mean": result.global_act.mean,
|
| 483 |
+
"train/global/act/max_abs": result.global_act.max_abs,
|
| 484 |
+
"train/global/act/std": result.global_act.std,
|
| 485 |
+
"train/global/act/norm": result.global_act.norm,
|
| 486 |
+
# Intentionally NOT logging frac_near_dtype_limit or frac_near_user_limit
|
| 487 |
+
})
|
| 488 |
+
|
| 489 |
+
# Per-tensor (per-layer) metrics
|
| 490 |
+
# Organize by layer for cleaner WandB UI
|
| 491 |
+
for tensor_name, stats in result.layer_acts.items():
|
| 492 |
+
# Clean name for wandb: replace dots with slashes
|
| 493 |
+
clean_name = tensor_name.replace(".", "/")
|
| 494 |
+
|
| 495 |
+
wandb.log({
|
| 496 |
+
f"train/{clean_name}/act/mean": stats.mean,
|
| 497 |
+
f"train/{clean_name}/act/max_abs": stats.max_abs,
|
| 498 |
+
f"train/{clean_name}/act/std": stats.std,
|
| 499 |
+
f"train/{clean_name}/act/norm": stats.norm,
|
| 500 |
+
# No frac_near_dtype_limit
|
| 501 |
+
})
|
| 502 |
+
|
| 503 |
+
# Also log as a wandb.Table for easy comparison
|
| 504 |
+
table_data = []
|
| 505 |
+
for tensor_name, stats in sorted(result.layer_acts.items()):
|
| 506 |
+
table_data.append([
|
| 507 |
+
tensor_name,
|
| 508 |
+
stats.mean,
|
| 509 |
+
stats.max_abs,
|
| 510 |
+
stats.std,
|
| 511 |
+
stats.norm,
|
| 512 |
+
stats.numel
|
| 513 |
+
])
|
| 514 |
+
|
| 515 |
+
if table_data:
|
| 516 |
+
table = wandb.Table(
|
| 517 |
+
columns=["tensor_name", "mean", "max_abs", "std", "norm", "numel"],
|
| 518 |
+
data=table_data
|
| 519 |
+
)
|
| 520 |
+
wandb.log({"activation_table": table})
|
| 521 |
+
|
| 522 |
+
def print_report(self, results: List[ModelResult]):
|
| 523 |
+
"""Pretty-print comparison report."""
|
| 524 |
+
print("\n" + "=" * 110)
|
| 525 |
+
print(f"{'Model':<35} {'Loss':>10} {'PPL':>10} {'ActMean':>12} {'ActMaxAbs':>12} {'ActStd':>12} {'Tokens':>8}")
|
| 526 |
+
print("-" * 110)
|
| 527 |
+
|
| 528 |
+
for r in results:
|
| 529 |
+
name = r.model_name.split("/")[-1][:33]
|
| 530 |
+
print(
|
| 531 |
+
f"{name:<35} "
|
| 532 |
+
f"{r.loss:>10.4f} "
|
| 533 |
+
f"{r.perplexity:>10.2f} "
|
| 534 |
+
f"{r.global_act.mean:>12.6f} "
|
| 535 |
+
f"{r.global_act.max_abs:>12.6f} "
|
| 536 |
+
f"{r.global_act.std:>12.6f} "
|
| 537 |
+
f"{r.num_tokens:>8}"
|
| 538 |
+
)
|
| 539 |
+
|
| 540 |
+
print("=" * 110)
|
| 541 |
+
|
| 542 |
+
# Print top 5 layers by max_abs for each model
|
| 543 |
+
print("\n[Per-Tensor Max Abs Top 5]")
|
| 544 |
+
for r in results:
|
| 545 |
+
name = r.model_name.split("/")[-1]
|
| 546 |
+
sorted_layers = sorted(r.layer_acts.items(), key=lambda x: x[1].max_abs, reverse=True)[:5]
|
| 547 |
+
print(f"\n {name}:")
|
| 548 |
+
for tensor_name, stats in sorted_layers:
|
| 549 |
+
print(f" {tensor_name:<50} max_abs={stats.max_abs:>10.4f} mean={stats.mean:>10.6f} std={stats.std:>10.4f}")
|
| 550 |
+
|
| 551 |
+
def export_json(self, results: List[ModelResult], path: str):
|
| 552 |
+
"""Export results to JSON."""
|
| 553 |
+
data = []
|
| 554 |
+
for r in results:
|
| 555 |
+
entry = {
|
| 556 |
+
"model": r.model_name,
|
| 557 |
+
"loss": r.loss,
|
| 558 |
+
"perplexity": r.perplexity,
|
| 559 |
+
"num_tokens": r.num_tokens,
|
| 560 |
+
"num_layers": r.num_layers,
|
| 561 |
+
"hidden_size": r.hidden_size,
|
| 562 |
+
"num_params": r.num_params,
|
| 563 |
+
"global_act": asdict(r.global_act),
|
| 564 |
+
"layer_acts": {k: asdict(v) for k, v in r.layer_acts.items()}
|
| 565 |
+
}
|
| 566 |
+
data.append(entry)
|
| 567 |
+
|
| 568 |
+
with open(path, "w") as f:
|
| 569 |
+
json.dump(data, f, indent=2)
|
| 570 |
+
print(f"[Exported] Results saved to {path}")
|
out/glu-gelu-9L_run/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
tags:
|
| 4 |
+
- generated_from_trainer
|
| 5 |
+
model-index:
|
| 6 |
+
- name: ACTio-glu-gelu-9L
|
| 7 |
+
results: []
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
| 11 |
+
should probably proofread and complete it, then remove this comment. -->
|
| 12 |
+
|
| 13 |
+
# ACTio-glu-gelu-9L
|
| 14 |
+
|
| 15 |
+
This model is a fine-tuned version of [](https://huggingface.co/) on an unknown dataset.
|
| 16 |
+
It achieves the following results on the evaluation set:
|
| 17 |
+
- Loss: 0.2151
|
| 18 |
+
|
| 19 |
+
## Model description
|
| 20 |
+
|
| 21 |
+
More information needed
|
| 22 |
+
|
| 23 |
+
## Intended uses & limitations
|
| 24 |
+
|
| 25 |
+
More information needed
|
| 26 |
+
|
| 27 |
+
## Training and evaluation data
|
| 28 |
+
|
| 29 |
+
More information needed
|
| 30 |
+
|
| 31 |
+
## Training procedure
|
| 32 |
+
|
| 33 |
+
### Training hyperparameters
|
| 34 |
+
|
| 35 |
+
The following hyperparameters were used during training:
|
| 36 |
+
- learning_rate: 0.0003
|
| 37 |
+
- train_batch_size: 64
|
| 38 |
+
- eval_batch_size: 64
|
| 39 |
+
- seed: 42
|
| 40 |
+
- optimizer: Use OptimizerNames.ADAMW_TORCH with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
|
| 41 |
+
- lr_scheduler_type: constant
|
| 42 |
+
- training_steps: 2000
|
| 43 |
+
|
| 44 |
+
### Training results
|
| 45 |
+
|
| 46 |
+
| Training Loss | Epoch | Step | Validation Loss |
|
| 47 |
+
|:-------------:|:------:|:----:|:---------------:|
|
| 48 |
+
| 3.3152 | 0.0135 | 200 | 3.1407 |
|
| 49 |
+
| 0.8976 | 0.0270 | 400 | 0.8561 |
|
| 50 |
+
| 0.4081 | 0.0404 | 600 | 0.4029 |
|
| 51 |
+
| 0.3257 | 0.0539 | 800 | 0.3262 |
|
| 52 |
+
| 0.2851 | 0.0674 | 1000 | 0.2846 |
|
| 53 |
+
| 0.2629 | 0.0809 | 1200 | 0.2618 |
|
| 54 |
+
| 0.2410 | 0.0944 | 1400 | 0.2429 |
|
| 55 |
+
| 0.2452 | 0.1079 | 1600 | 0.2447 |
|
| 56 |
+
| 0.2224 | 0.1213 | 1800 | 0.2213 |
|
| 57 |
+
| 0.2135 | 0.1348 | 2000 | 0.2151 |
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
### Framework versions
|
| 61 |
+
|
| 62 |
+
- Transformers 5.15.0.dev0
|
| 63 |
+
- Pytorch 2.6.0+cu124
|
| 64 |
+
- Datasets 5.0.1
|
| 65 |
+
- Tokenizers 0.22.2
|
out/glu-gelu-9L_run/checkpoint-1000/config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"TinyLlamaForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_bias": false,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"bos_token_id": 1,
|
| 9 |
+
"dtype": "bfloat16",
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
+
"head_dim": 32,
|
| 12 |
+
"hidden_act": "silu",
|
| 13 |
+
"hidden_size": 128,
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 256,
|
| 16 |
+
"max_position_embeddings": 512,
|
| 17 |
+
"mlp_bias": false,
|
| 18 |
+
"mlp_type": "glu",
|
| 19 |
+
"model_type": "tiny_llama",
|
| 20 |
+
"num_attention_heads": 4,
|
| 21 |
+
"num_hidden_layers": 9,
|
| 22 |
+
"num_key_value_heads": 4,
|
| 23 |
+
"pad_token_id": 0,
|
| 24 |
+
"pretraining_tp": 1,
|
| 25 |
+
"rms_norm_eps": 1e-06,
|
| 26 |
+
"rope_parameters": {
|
| 27 |
+
"rope_theta": 10000.0,
|
| 28 |
+
"rope_type": "default"
|
| 29 |
+
},
|
| 30 |
+
"tie_word_embeddings": true,
|
| 31 |
+
"tokenizer_name": "w-ahmad/tiny-stories-tokenizer",
|
| 32 |
+
"transformers_version": "5.15.0.dev0",
|
| 33 |
+
"use_cache": false,
|
| 34 |
+
"vocab_size": 4096
|
| 35 |
+
}
|
out/glu-gelu-9L_run/checkpoint-1000/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2e35b0e11a46d87fbedb0dbd610a7d8df1fe3ebbc9c047856d41f4791f8532b2
|
| 3 |
+
size 4011496
|
out/glu-gelu-9L_run/checkpoint-1000/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:10ec2f99857c3ef4d84564c7d553e90d3577d6f590e656cb57f71830f27ecc07
|
| 3 |
+
size 8074746
|
out/glu-gelu-9L_run/checkpoint-1000/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:95b6047bd8cc6f4cdf7c46dea47edb8e542435510070c6cd1e0a7d9ccf5fd7da
|
| 3 |
+
size 14244
|
out/glu-gelu-9L_run/checkpoint-1000/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d5f71c5fa69d56807b14256b78700be6088fcb1bda0ff8e0ea6f8709a7df2fde
|
| 3 |
+
size 1064
|
out/glu-gelu-9L_run/checkpoint-1000/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out/glu-gelu-9L_run/checkpoint-1000/tokenizer_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<|endoftext|>",
|
| 5 |
+
"eos_token": "<|endoftext|>",
|
| 6 |
+
"errors": "replace",
|
| 7 |
+
"is_local": false,
|
| 8 |
+
"local_files_only": false,
|
| 9 |
+
"model_max_length": 1024,
|
| 10 |
+
"pad_token": "<|endoftext|>",
|
| 11 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 12 |
+
"unk_token": "<|endoftext|>"
|
| 13 |
+
}
|
out/glu-gelu-9L_run/checkpoint-1000/trainer_state.json
ADDED
|
@@ -0,0 +1,424 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": null,
|
| 3 |
+
"best_metric": null,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 0.06740815638692282,
|
| 6 |
+
"eval_steps": 200,
|
| 7 |
+
"global_step": 1000,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"epoch": 0.0013481631277384564,
|
| 14 |
+
"grad_norm": 1.2578125,
|
| 15 |
+
"learning_rate": 0.0003,
|
| 16 |
+
"loss": 7.793476104736328,
|
| 17 |
+
"step": 20
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"epoch": 0.002696326255476913,
|
| 21 |
+
"grad_norm": 1.171875,
|
| 22 |
+
"learning_rate": 0.0003,
|
| 23 |
+
"loss": 7.021186828613281,
|
| 24 |
+
"step": 40
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"epoch": 0.004044489383215369,
|
| 28 |
+
"grad_norm": 1.0,
|
| 29 |
+
"learning_rate": 0.0003,
|
| 30 |
+
"loss": 6.446919250488281,
|
| 31 |
+
"step": 60
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"epoch": 0.005392652510953826,
|
| 35 |
+
"grad_norm": 1.4609375,
|
| 36 |
+
"learning_rate": 0.0003,
|
| 37 |
+
"loss": 5.989651489257812,
|
| 38 |
+
"step": 80
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"epoch": 0.006740815638692282,
|
| 42 |
+
"grad_norm": 2.328125,
|
| 43 |
+
"learning_rate": 0.0003,
|
| 44 |
+
"loss": 5.436912536621094,
|
| 45 |
+
"step": 100
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"epoch": 0.008088978766430738,
|
| 49 |
+
"grad_norm": 2.671875,
|
| 50 |
+
"learning_rate": 0.0003,
|
| 51 |
+
"loss": 4.910789871215821,
|
| 52 |
+
"step": 120
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"epoch": 0.009437141894169195,
|
| 56 |
+
"grad_norm": 3.28125,
|
| 57 |
+
"learning_rate": 0.0003,
|
| 58 |
+
"loss": 4.441200637817383,
|
| 59 |
+
"step": 140
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"epoch": 0.010785305021907651,
|
| 63 |
+
"grad_norm": 2.625,
|
| 64 |
+
"learning_rate": 0.0003,
|
| 65 |
+
"loss": 4.035322952270508,
|
| 66 |
+
"step": 160
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"epoch": 0.012133468149646108,
|
| 70 |
+
"grad_norm": 3.765625,
|
| 71 |
+
"learning_rate": 0.0003,
|
| 72 |
+
"loss": 3.6691635131835936,
|
| 73 |
+
"step": 180
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"epoch": 0.013481631277384564,
|
| 77 |
+
"grad_norm": 2.296875,
|
| 78 |
+
"learning_rate": 0.0003,
|
| 79 |
+
"loss": 3.315158462524414,
|
| 80 |
+
"step": 200
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"epoch": 0.013481631277384564,
|
| 84 |
+
"eval_loss": 3.140667200088501,
|
| 85 |
+
"eval_runtime": 8.3121,
|
| 86 |
+
"eval_samples_per_second": 1146.166,
|
| 87 |
+
"eval_steps_per_second": 17.926,
|
| 88 |
+
"step": 200
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"epoch": 0.01482979440512302,
|
| 92 |
+
"grad_norm": 2.453125,
|
| 93 |
+
"learning_rate": 0.0003,
|
| 94 |
+
"loss": 2.9744741439819338,
|
| 95 |
+
"step": 220
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"epoch": 0.016177957532861477,
|
| 99 |
+
"grad_norm": 2.359375,
|
| 100 |
+
"learning_rate": 0.0003,
|
| 101 |
+
"loss": 2.6262161254882814,
|
| 102 |
+
"step": 240
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"epoch": 0.01752612066059993,
|
| 106 |
+
"grad_norm": 2.234375,
|
| 107 |
+
"learning_rate": 0.0003,
|
| 108 |
+
"loss": 2.3146018981933594,
|
| 109 |
+
"step": 260
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"epoch": 0.01887428378833839,
|
| 113 |
+
"grad_norm": 2.015625,
|
| 114 |
+
"learning_rate": 0.0003,
|
| 115 |
+
"loss": 1.9927532196044921,
|
| 116 |
+
"step": 280
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"epoch": 0.020222446916076844,
|
| 120 |
+
"grad_norm": 1.609375,
|
| 121 |
+
"learning_rate": 0.0003,
|
| 122 |
+
"loss": 1.6939159393310548,
|
| 123 |
+
"step": 300
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"epoch": 0.021570610043815303,
|
| 127 |
+
"grad_norm": 1.734375,
|
| 128 |
+
"learning_rate": 0.0003,
|
| 129 |
+
"loss": 1.4503639221191407,
|
| 130 |
+
"step": 320
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"epoch": 0.022918773171553757,
|
| 134 |
+
"grad_norm": 1.828125,
|
| 135 |
+
"learning_rate": 0.0003,
|
| 136 |
+
"loss": 1.2639431953430176,
|
| 137 |
+
"step": 340
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"epoch": 0.024266936299292215,
|
| 141 |
+
"grad_norm": 1.984375,
|
| 142 |
+
"learning_rate": 0.0003,
|
| 143 |
+
"loss": 1.1161455154418944,
|
| 144 |
+
"step": 360
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"epoch": 0.02561509942703067,
|
| 148 |
+
"grad_norm": 1.546875,
|
| 149 |
+
"learning_rate": 0.0003,
|
| 150 |
+
"loss": 0.9919822692871094,
|
| 151 |
+
"step": 380
|
| 152 |
+
},
|
| 153 |
+
{
|
| 154 |
+
"epoch": 0.026963262554769128,
|
| 155 |
+
"grad_norm": 1.1484375,
|
| 156 |
+
"learning_rate": 0.0003,
|
| 157 |
+
"loss": 0.8975520133972168,
|
| 158 |
+
"step": 400
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"epoch": 0.026963262554769128,
|
| 162 |
+
"eval_loss": 0.8561499714851379,
|
| 163 |
+
"eval_runtime": 8.3662,
|
| 164 |
+
"eval_samples_per_second": 1138.75,
|
| 165 |
+
"eval_steps_per_second": 17.81,
|
| 166 |
+
"step": 400
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
"epoch": 0.028311425682507583,
|
| 170 |
+
"grad_norm": 0.67578125,
|
| 171 |
+
"learning_rate": 0.0003,
|
| 172 |
+
"loss": 0.7963034629821777,
|
| 173 |
+
"step": 420
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"epoch": 0.02965958881024604,
|
| 177 |
+
"grad_norm": 0.51171875,
|
| 178 |
+
"learning_rate": 0.0003,
|
| 179 |
+
"loss": 0.7076507568359375,
|
| 180 |
+
"step": 440
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"epoch": 0.031007751937984496,
|
| 184 |
+
"grad_norm": 0.439453125,
|
| 185 |
+
"learning_rate": 0.0003,
|
| 186 |
+
"loss": 0.6221071720123291,
|
| 187 |
+
"step": 460
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"epoch": 0.032355915065722954,
|
| 191 |
+
"grad_norm": 0.423828125,
|
| 192 |
+
"learning_rate": 0.0003,
|
| 193 |
+
"loss": 0.5685368537902832,
|
| 194 |
+
"step": 480
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"epoch": 0.03370407819346141,
|
| 198 |
+
"grad_norm": 0.3671875,
|
| 199 |
+
"learning_rate": 0.0003,
|
| 200 |
+
"loss": 0.5213922977447509,
|
| 201 |
+
"step": 500
|
| 202 |
+
},
|
| 203 |
+
{
|
| 204 |
+
"epoch": 0.03505224132119986,
|
| 205 |
+
"grad_norm": 0.380859375,
|
| 206 |
+
"learning_rate": 0.0003,
|
| 207 |
+
"loss": 0.4871851444244385,
|
| 208 |
+
"step": 520
|
| 209 |
+
},
|
| 210 |
+
{
|
| 211 |
+
"epoch": 0.03640040444893832,
|
| 212 |
+
"grad_norm": 0.36328125,
|
| 213 |
+
"learning_rate": 0.0003,
|
| 214 |
+
"loss": 0.4552904605865479,
|
| 215 |
+
"step": 540
|
| 216 |
+
},
|
| 217 |
+
{
|
| 218 |
+
"epoch": 0.03774856757667678,
|
| 219 |
+
"grad_norm": 0.388671875,
|
| 220 |
+
"learning_rate": 0.0003,
|
| 221 |
+
"loss": 0.4377324104309082,
|
| 222 |
+
"step": 560
|
| 223 |
+
},
|
| 224 |
+
{
|
| 225 |
+
"epoch": 0.03909673070441524,
|
| 226 |
+
"grad_norm": 0.400390625,
|
| 227 |
+
"learning_rate": 0.0003,
|
| 228 |
+
"loss": 0.4190248966217041,
|
| 229 |
+
"step": 580
|
| 230 |
+
},
|
| 231 |
+
{
|
| 232 |
+
"epoch": 0.04044489383215369,
|
| 233 |
+
"grad_norm": 0.392578125,
|
| 234 |
+
"learning_rate": 0.0003,
|
| 235 |
+
"loss": 0.40812134742736816,
|
| 236 |
+
"step": 600
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"epoch": 0.04044489383215369,
|
| 240 |
+
"eval_loss": 0.40287962555885315,
|
| 241 |
+
"eval_runtime": 8.3848,
|
| 242 |
+
"eval_samples_per_second": 1136.228,
|
| 243 |
+
"eval_steps_per_second": 17.77,
|
| 244 |
+
"step": 600
|
| 245 |
+
},
|
| 246 |
+
{
|
| 247 |
+
"epoch": 0.04179305695989215,
|
| 248 |
+
"grad_norm": 0.40234375,
|
| 249 |
+
"learning_rate": 0.0003,
|
| 250 |
+
"loss": 0.39397249221801756,
|
| 251 |
+
"step": 620
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"epoch": 0.043141220087630605,
|
| 255 |
+
"grad_norm": 0.4140625,
|
| 256 |
+
"learning_rate": 0.0003,
|
| 257 |
+
"loss": 0.38487560749053956,
|
| 258 |
+
"step": 640
|
| 259 |
+
},
|
| 260 |
+
{
|
| 261 |
+
"epoch": 0.044489383215369056,
|
| 262 |
+
"grad_norm": 0.376953125,
|
| 263 |
+
"learning_rate": 0.0003,
|
| 264 |
+
"loss": 0.37073094844818116,
|
| 265 |
+
"step": 660
|
| 266 |
+
},
|
| 267 |
+
{
|
| 268 |
+
"epoch": 0.045837546343107514,
|
| 269 |
+
"grad_norm": 2.453125,
|
| 270 |
+
"learning_rate": 0.0003,
|
| 271 |
+
"loss": 0.36380269527435305,
|
| 272 |
+
"step": 680
|
| 273 |
+
},
|
| 274 |
+
{
|
| 275 |
+
"epoch": 0.04718570947084597,
|
| 276 |
+
"grad_norm": 1.171875,
|
| 277 |
+
"learning_rate": 0.0003,
|
| 278 |
+
"loss": 0.3727259159088135,
|
| 279 |
+
"step": 700
|
| 280 |
+
},
|
| 281 |
+
{
|
| 282 |
+
"epoch": 0.04853387259858443,
|
| 283 |
+
"grad_norm": 0.44921875,
|
| 284 |
+
"learning_rate": 0.0003,
|
| 285 |
+
"loss": 0.36068120002746584,
|
| 286 |
+
"step": 720
|
| 287 |
+
},
|
| 288 |
+
{
|
| 289 |
+
"epoch": 0.04988203572632288,
|
| 290 |
+
"grad_norm": 0.3359375,
|
| 291 |
+
"learning_rate": 0.0003,
|
| 292 |
+
"loss": 0.345484185218811,
|
| 293 |
+
"step": 740
|
| 294 |
+
},
|
| 295 |
+
{
|
| 296 |
+
"epoch": 0.05123019885406134,
|
| 297 |
+
"grad_norm": 0.271484375,
|
| 298 |
+
"learning_rate": 0.0003,
|
| 299 |
+
"loss": 0.3413747549057007,
|
| 300 |
+
"step": 760
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
"epoch": 0.0525783619817998,
|
| 304 |
+
"grad_norm": 0.279296875,
|
| 305 |
+
"learning_rate": 0.0003,
|
| 306 |
+
"loss": 0.3339890956878662,
|
| 307 |
+
"step": 780
|
| 308 |
+
},
|
| 309 |
+
{
|
| 310 |
+
"epoch": 0.053926525109538256,
|
| 311 |
+
"grad_norm": 0.27734375,
|
| 312 |
+
"learning_rate": 0.0003,
|
| 313 |
+
"loss": 0.32567362785339354,
|
| 314 |
+
"step": 800
|
| 315 |
+
},
|
| 316 |
+
{
|
| 317 |
+
"epoch": 0.053926525109538256,
|
| 318 |
+
"eval_loss": 0.32622790336608887,
|
| 319 |
+
"eval_runtime": 8.4003,
|
| 320 |
+
"eval_samples_per_second": 1134.122,
|
| 321 |
+
"eval_steps_per_second": 17.737,
|
| 322 |
+
"step": 800
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"epoch": 0.05527468823727671,
|
| 326 |
+
"grad_norm": 0.275390625,
|
| 327 |
+
"learning_rate": 0.0003,
|
| 328 |
+
"loss": 0.3216629266738892,
|
| 329 |
+
"step": 820
|
| 330 |
+
},
|
| 331 |
+
{
|
| 332 |
+
"epoch": 0.056622851365015166,
|
| 333 |
+
"grad_norm": 0.291015625,
|
| 334 |
+
"learning_rate": 0.0003,
|
| 335 |
+
"loss": 0.3161738157272339,
|
| 336 |
+
"step": 840
|
| 337 |
+
},
|
| 338 |
+
{
|
| 339 |
+
"epoch": 0.057971014492753624,
|
| 340 |
+
"grad_norm": 0.26171875,
|
| 341 |
+
"learning_rate": 0.0003,
|
| 342 |
+
"loss": 0.30926101207733153,
|
| 343 |
+
"step": 860
|
| 344 |
+
},
|
| 345 |
+
{
|
| 346 |
+
"epoch": 0.05931917762049208,
|
| 347 |
+
"grad_norm": 0.27734375,
|
| 348 |
+
"learning_rate": 0.0003,
|
| 349 |
+
"loss": 0.30281963348388674,
|
| 350 |
+
"step": 880
|
| 351 |
+
},
|
| 352 |
+
{
|
| 353 |
+
"epoch": 0.06066734074823053,
|
| 354 |
+
"grad_norm": 0.287109375,
|
| 355 |
+
"learning_rate": 0.0003,
|
| 356 |
+
"loss": 0.301728343963623,
|
| 357 |
+
"step": 900
|
| 358 |
+
},
|
| 359 |
+
{
|
| 360 |
+
"epoch": 0.06201550387596899,
|
| 361 |
+
"grad_norm": 0.29296875,
|
| 362 |
+
"learning_rate": 0.0003,
|
| 363 |
+
"loss": 0.2986367464065552,
|
| 364 |
+
"step": 920
|
| 365 |
+
},
|
| 366 |
+
{
|
| 367 |
+
"epoch": 0.06336366700370745,
|
| 368 |
+
"grad_norm": 0.306640625,
|
| 369 |
+
"learning_rate": 0.0003,
|
| 370 |
+
"loss": 0.294226336479187,
|
| 371 |
+
"step": 940
|
| 372 |
+
},
|
| 373 |
+
{
|
| 374 |
+
"epoch": 0.06471183013144591,
|
| 375 |
+
"grad_norm": 0.33984375,
|
| 376 |
+
"learning_rate": 0.0003,
|
| 377 |
+
"loss": 0.28919248580932616,
|
| 378 |
+
"step": 960
|
| 379 |
+
},
|
| 380 |
+
{
|
| 381 |
+
"epoch": 0.06605999325918437,
|
| 382 |
+
"grad_norm": 0.296875,
|
| 383 |
+
"learning_rate": 0.0003,
|
| 384 |
+
"loss": 0.2873764276504517,
|
| 385 |
+
"step": 980
|
| 386 |
+
},
|
| 387 |
+
{
|
| 388 |
+
"epoch": 0.06740815638692282,
|
| 389 |
+
"grad_norm": 0.322265625,
|
| 390 |
+
"learning_rate": 0.0003,
|
| 391 |
+
"loss": 0.2850848436355591,
|
| 392 |
+
"step": 1000
|
| 393 |
+
},
|
| 394 |
+
{
|
| 395 |
+
"epoch": 0.06740815638692282,
|
| 396 |
+
"eval_loss": 0.284612774848938,
|
| 397 |
+
"eval_runtime": 8.55,
|
| 398 |
+
"eval_samples_per_second": 1114.271,
|
| 399 |
+
"eval_steps_per_second": 17.427,
|
| 400 |
+
"step": 1000
|
| 401 |
+
}
|
| 402 |
+
],
|
| 403 |
+
"logging_steps": 20,
|
| 404 |
+
"max_steps": 2000,
|
| 405 |
+
"num_input_tokens_seen": 0,
|
| 406 |
+
"num_train_epochs": 1,
|
| 407 |
+
"save_steps": 500,
|
| 408 |
+
"stateful_callbacks": {
|
| 409 |
+
"TrainerControl": {
|
| 410 |
+
"args": {
|
| 411 |
+
"should_epoch_stop": false,
|
| 412 |
+
"should_evaluate": false,
|
| 413 |
+
"should_log": false,
|
| 414 |
+
"should_save": true,
|
| 415 |
+
"should_training_stop": false
|
| 416 |
+
},
|
| 417 |
+
"attributes": {}
|
| 418 |
+
}
|
| 419 |
+
},
|
| 420 |
+
"total_flos": 290388443136000.0,
|
| 421 |
+
"train_batch_size": 64,
|
| 422 |
+
"trial_name": null,
|
| 423 |
+
"trial_params": null
|
| 424 |
+
}
|
out/glu-gelu-9L_run/checkpoint-1000/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a5bc9b69db12445b4a7919b29e76d261b3c2acbea92402190b4ca5d146c69daa
|
| 3 |
+
size 4920
|
out/glu-gelu-9L_run/checkpoint-1500/config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"TinyLlamaForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_bias": false,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"bos_token_id": 1,
|
| 9 |
+
"dtype": "bfloat16",
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
+
"head_dim": 32,
|
| 12 |
+
"hidden_act": "silu",
|
| 13 |
+
"hidden_size": 128,
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 256,
|
| 16 |
+
"max_position_embeddings": 512,
|
| 17 |
+
"mlp_bias": false,
|
| 18 |
+
"mlp_type": "glu",
|
| 19 |
+
"model_type": "tiny_llama",
|
| 20 |
+
"num_attention_heads": 4,
|
| 21 |
+
"num_hidden_layers": 9,
|
| 22 |
+
"num_key_value_heads": 4,
|
| 23 |
+
"pad_token_id": 0,
|
| 24 |
+
"pretraining_tp": 1,
|
| 25 |
+
"rms_norm_eps": 1e-06,
|
| 26 |
+
"rope_parameters": {
|
| 27 |
+
"rope_theta": 10000.0,
|
| 28 |
+
"rope_type": "default"
|
| 29 |
+
},
|
| 30 |
+
"tie_word_embeddings": true,
|
| 31 |
+
"tokenizer_name": "w-ahmad/tiny-stories-tokenizer",
|
| 32 |
+
"transformers_version": "5.15.0.dev0",
|
| 33 |
+
"use_cache": false,
|
| 34 |
+
"vocab_size": 4096
|
| 35 |
+
}
|
out/glu-gelu-9L_run/checkpoint-1500/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:02945cf70fed9c6e8088853f25a2118cdd716fe4cd30efc4b3fbc33b4554a983
|
| 3 |
+
size 4011496
|
out/glu-gelu-9L_run/checkpoint-1500/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:62950e32ae8361a13306e433bbe68d89378073f7f6089d0063c7023e0f942526
|
| 3 |
+
size 8074746
|
out/glu-gelu-9L_run/checkpoint-1500/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e2768285b45b2a0c05f6f50bbb8c0287fca6f62a8cde6d1b1f02151ac72ee8dc
|
| 3 |
+
size 14244
|
out/glu-gelu-9L_run/checkpoint-1500/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b26a759cc207e28dea06eae7ad531c2dd78a09978f6972edbfc1566adccd7142
|
| 3 |
+
size 1064
|
out/glu-gelu-9L_run/checkpoint-1500/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out/glu-gelu-9L_run/checkpoint-1500/tokenizer_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<|endoftext|>",
|
| 5 |
+
"eos_token": "<|endoftext|>",
|
| 6 |
+
"errors": "replace",
|
| 7 |
+
"is_local": false,
|
| 8 |
+
"local_files_only": false,
|
| 9 |
+
"model_max_length": 1024,
|
| 10 |
+
"pad_token": "<|endoftext|>",
|
| 11 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 12 |
+
"unk_token": "<|endoftext|>"
|
| 13 |
+
}
|
out/glu-gelu-9L_run/checkpoint-1500/trainer_state.json
ADDED
|
@@ -0,0 +1,615 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": null,
|
| 3 |
+
"best_metric": null,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 0.10111223458038422,
|
| 6 |
+
"eval_steps": 200,
|
| 7 |
+
"global_step": 1500,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"epoch": 0.0013481631277384564,
|
| 14 |
+
"grad_norm": 1.2578125,
|
| 15 |
+
"learning_rate": 0.0003,
|
| 16 |
+
"loss": 7.793476104736328,
|
| 17 |
+
"step": 20
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"epoch": 0.002696326255476913,
|
| 21 |
+
"grad_norm": 1.171875,
|
| 22 |
+
"learning_rate": 0.0003,
|
| 23 |
+
"loss": 7.021186828613281,
|
| 24 |
+
"step": 40
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"epoch": 0.004044489383215369,
|
| 28 |
+
"grad_norm": 1.0,
|
| 29 |
+
"learning_rate": 0.0003,
|
| 30 |
+
"loss": 6.446919250488281,
|
| 31 |
+
"step": 60
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"epoch": 0.005392652510953826,
|
| 35 |
+
"grad_norm": 1.4609375,
|
| 36 |
+
"learning_rate": 0.0003,
|
| 37 |
+
"loss": 5.989651489257812,
|
| 38 |
+
"step": 80
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"epoch": 0.006740815638692282,
|
| 42 |
+
"grad_norm": 2.328125,
|
| 43 |
+
"learning_rate": 0.0003,
|
| 44 |
+
"loss": 5.436912536621094,
|
| 45 |
+
"step": 100
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"epoch": 0.008088978766430738,
|
| 49 |
+
"grad_norm": 2.671875,
|
| 50 |
+
"learning_rate": 0.0003,
|
| 51 |
+
"loss": 4.910789871215821,
|
| 52 |
+
"step": 120
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"epoch": 0.009437141894169195,
|
| 56 |
+
"grad_norm": 3.28125,
|
| 57 |
+
"learning_rate": 0.0003,
|
| 58 |
+
"loss": 4.441200637817383,
|
| 59 |
+
"step": 140
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"epoch": 0.010785305021907651,
|
| 63 |
+
"grad_norm": 2.625,
|
| 64 |
+
"learning_rate": 0.0003,
|
| 65 |
+
"loss": 4.035322952270508,
|
| 66 |
+
"step": 160
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"epoch": 0.012133468149646108,
|
| 70 |
+
"grad_norm": 3.765625,
|
| 71 |
+
"learning_rate": 0.0003,
|
| 72 |
+
"loss": 3.6691635131835936,
|
| 73 |
+
"step": 180
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"epoch": 0.013481631277384564,
|
| 77 |
+
"grad_norm": 2.296875,
|
| 78 |
+
"learning_rate": 0.0003,
|
| 79 |
+
"loss": 3.315158462524414,
|
| 80 |
+
"step": 200
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"epoch": 0.013481631277384564,
|
| 84 |
+
"eval_loss": 3.140667200088501,
|
| 85 |
+
"eval_runtime": 8.3121,
|
| 86 |
+
"eval_samples_per_second": 1146.166,
|
| 87 |
+
"eval_steps_per_second": 17.926,
|
| 88 |
+
"step": 200
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"epoch": 0.01482979440512302,
|
| 92 |
+
"grad_norm": 2.453125,
|
| 93 |
+
"learning_rate": 0.0003,
|
| 94 |
+
"loss": 2.9744741439819338,
|
| 95 |
+
"step": 220
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"epoch": 0.016177957532861477,
|
| 99 |
+
"grad_norm": 2.359375,
|
| 100 |
+
"learning_rate": 0.0003,
|
| 101 |
+
"loss": 2.6262161254882814,
|
| 102 |
+
"step": 240
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"epoch": 0.01752612066059993,
|
| 106 |
+
"grad_norm": 2.234375,
|
| 107 |
+
"learning_rate": 0.0003,
|
| 108 |
+
"loss": 2.3146018981933594,
|
| 109 |
+
"step": 260
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"epoch": 0.01887428378833839,
|
| 113 |
+
"grad_norm": 2.015625,
|
| 114 |
+
"learning_rate": 0.0003,
|
| 115 |
+
"loss": 1.9927532196044921,
|
| 116 |
+
"step": 280
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"epoch": 0.020222446916076844,
|
| 120 |
+
"grad_norm": 1.609375,
|
| 121 |
+
"learning_rate": 0.0003,
|
| 122 |
+
"loss": 1.6939159393310548,
|
| 123 |
+
"step": 300
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"epoch": 0.021570610043815303,
|
| 127 |
+
"grad_norm": 1.734375,
|
| 128 |
+
"learning_rate": 0.0003,
|
| 129 |
+
"loss": 1.4503639221191407,
|
| 130 |
+
"step": 320
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"epoch": 0.022918773171553757,
|
| 134 |
+
"grad_norm": 1.828125,
|
| 135 |
+
"learning_rate": 0.0003,
|
| 136 |
+
"loss": 1.2639431953430176,
|
| 137 |
+
"step": 340
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"epoch": 0.024266936299292215,
|
| 141 |
+
"grad_norm": 1.984375,
|
| 142 |
+
"learning_rate": 0.0003,
|
| 143 |
+
"loss": 1.1161455154418944,
|
| 144 |
+
"step": 360
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"epoch": 0.02561509942703067,
|
| 148 |
+
"grad_norm": 1.546875,
|
| 149 |
+
"learning_rate": 0.0003,
|
| 150 |
+
"loss": 0.9919822692871094,
|
| 151 |
+
"step": 380
|
| 152 |
+
},
|
| 153 |
+
{
|
| 154 |
+
"epoch": 0.026963262554769128,
|
| 155 |
+
"grad_norm": 1.1484375,
|
| 156 |
+
"learning_rate": 0.0003,
|
| 157 |
+
"loss": 0.8975520133972168,
|
| 158 |
+
"step": 400
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"epoch": 0.026963262554769128,
|
| 162 |
+
"eval_loss": 0.8561499714851379,
|
| 163 |
+
"eval_runtime": 8.3662,
|
| 164 |
+
"eval_samples_per_second": 1138.75,
|
| 165 |
+
"eval_steps_per_second": 17.81,
|
| 166 |
+
"step": 400
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
"epoch": 0.028311425682507583,
|
| 170 |
+
"grad_norm": 0.67578125,
|
| 171 |
+
"learning_rate": 0.0003,
|
| 172 |
+
"loss": 0.7963034629821777,
|
| 173 |
+
"step": 420
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"epoch": 0.02965958881024604,
|
| 177 |
+
"grad_norm": 0.51171875,
|
| 178 |
+
"learning_rate": 0.0003,
|
| 179 |
+
"loss": 0.7076507568359375,
|
| 180 |
+
"step": 440
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"epoch": 0.031007751937984496,
|
| 184 |
+
"grad_norm": 0.439453125,
|
| 185 |
+
"learning_rate": 0.0003,
|
| 186 |
+
"loss": 0.6221071720123291,
|
| 187 |
+
"step": 460
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"epoch": 0.032355915065722954,
|
| 191 |
+
"grad_norm": 0.423828125,
|
| 192 |
+
"learning_rate": 0.0003,
|
| 193 |
+
"loss": 0.5685368537902832,
|
| 194 |
+
"step": 480
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"epoch": 0.03370407819346141,
|
| 198 |
+
"grad_norm": 0.3671875,
|
| 199 |
+
"learning_rate": 0.0003,
|
| 200 |
+
"loss": 0.5213922977447509,
|
| 201 |
+
"step": 500
|
| 202 |
+
},
|
| 203 |
+
{
|
| 204 |
+
"epoch": 0.03505224132119986,
|
| 205 |
+
"grad_norm": 0.380859375,
|
| 206 |
+
"learning_rate": 0.0003,
|
| 207 |
+
"loss": 0.4871851444244385,
|
| 208 |
+
"step": 520
|
| 209 |
+
},
|
| 210 |
+
{
|
| 211 |
+
"epoch": 0.03640040444893832,
|
| 212 |
+
"grad_norm": 0.36328125,
|
| 213 |
+
"learning_rate": 0.0003,
|
| 214 |
+
"loss": 0.4552904605865479,
|
| 215 |
+
"step": 540
|
| 216 |
+
},
|
| 217 |
+
{
|
| 218 |
+
"epoch": 0.03774856757667678,
|
| 219 |
+
"grad_norm": 0.388671875,
|
| 220 |
+
"learning_rate": 0.0003,
|
| 221 |
+
"loss": 0.4377324104309082,
|
| 222 |
+
"step": 560
|
| 223 |
+
},
|
| 224 |
+
{
|
| 225 |
+
"epoch": 0.03909673070441524,
|
| 226 |
+
"grad_norm": 0.400390625,
|
| 227 |
+
"learning_rate": 0.0003,
|
| 228 |
+
"loss": 0.4190248966217041,
|
| 229 |
+
"step": 580
|
| 230 |
+
},
|
| 231 |
+
{
|
| 232 |
+
"epoch": 0.04044489383215369,
|
| 233 |
+
"grad_norm": 0.392578125,
|
| 234 |
+
"learning_rate": 0.0003,
|
| 235 |
+
"loss": 0.40812134742736816,
|
| 236 |
+
"step": 600
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"epoch": 0.04044489383215369,
|
| 240 |
+
"eval_loss": 0.40287962555885315,
|
| 241 |
+
"eval_runtime": 8.3848,
|
| 242 |
+
"eval_samples_per_second": 1136.228,
|
| 243 |
+
"eval_steps_per_second": 17.77,
|
| 244 |
+
"step": 600
|
| 245 |
+
},
|
| 246 |
+
{
|
| 247 |
+
"epoch": 0.04179305695989215,
|
| 248 |
+
"grad_norm": 0.40234375,
|
| 249 |
+
"learning_rate": 0.0003,
|
| 250 |
+
"loss": 0.39397249221801756,
|
| 251 |
+
"step": 620
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"epoch": 0.043141220087630605,
|
| 255 |
+
"grad_norm": 0.4140625,
|
| 256 |
+
"learning_rate": 0.0003,
|
| 257 |
+
"loss": 0.38487560749053956,
|
| 258 |
+
"step": 640
|
| 259 |
+
},
|
| 260 |
+
{
|
| 261 |
+
"epoch": 0.044489383215369056,
|
| 262 |
+
"grad_norm": 0.376953125,
|
| 263 |
+
"learning_rate": 0.0003,
|
| 264 |
+
"loss": 0.37073094844818116,
|
| 265 |
+
"step": 660
|
| 266 |
+
},
|
| 267 |
+
{
|
| 268 |
+
"epoch": 0.045837546343107514,
|
| 269 |
+
"grad_norm": 2.453125,
|
| 270 |
+
"learning_rate": 0.0003,
|
| 271 |
+
"loss": 0.36380269527435305,
|
| 272 |
+
"step": 680
|
| 273 |
+
},
|
| 274 |
+
{
|
| 275 |
+
"epoch": 0.04718570947084597,
|
| 276 |
+
"grad_norm": 1.171875,
|
| 277 |
+
"learning_rate": 0.0003,
|
| 278 |
+
"loss": 0.3727259159088135,
|
| 279 |
+
"step": 700
|
| 280 |
+
},
|
| 281 |
+
{
|
| 282 |
+
"epoch": 0.04853387259858443,
|
| 283 |
+
"grad_norm": 0.44921875,
|
| 284 |
+
"learning_rate": 0.0003,
|
| 285 |
+
"loss": 0.36068120002746584,
|
| 286 |
+
"step": 720
|
| 287 |
+
},
|
| 288 |
+
{
|
| 289 |
+
"epoch": 0.04988203572632288,
|
| 290 |
+
"grad_norm": 0.3359375,
|
| 291 |
+
"learning_rate": 0.0003,
|
| 292 |
+
"loss": 0.345484185218811,
|
| 293 |
+
"step": 740
|
| 294 |
+
},
|
| 295 |
+
{
|
| 296 |
+
"epoch": 0.05123019885406134,
|
| 297 |
+
"grad_norm": 0.271484375,
|
| 298 |
+
"learning_rate": 0.0003,
|
| 299 |
+
"loss": 0.3413747549057007,
|
| 300 |
+
"step": 760
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
"epoch": 0.0525783619817998,
|
| 304 |
+
"grad_norm": 0.279296875,
|
| 305 |
+
"learning_rate": 0.0003,
|
| 306 |
+
"loss": 0.3339890956878662,
|
| 307 |
+
"step": 780
|
| 308 |
+
},
|
| 309 |
+
{
|
| 310 |
+
"epoch": 0.053926525109538256,
|
| 311 |
+
"grad_norm": 0.27734375,
|
| 312 |
+
"learning_rate": 0.0003,
|
| 313 |
+
"loss": 0.32567362785339354,
|
| 314 |
+
"step": 800
|
| 315 |
+
},
|
| 316 |
+
{
|
| 317 |
+
"epoch": 0.053926525109538256,
|
| 318 |
+
"eval_loss": 0.32622790336608887,
|
| 319 |
+
"eval_runtime": 8.4003,
|
| 320 |
+
"eval_samples_per_second": 1134.122,
|
| 321 |
+
"eval_steps_per_second": 17.737,
|
| 322 |
+
"step": 800
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"epoch": 0.05527468823727671,
|
| 326 |
+
"grad_norm": 0.275390625,
|
| 327 |
+
"learning_rate": 0.0003,
|
| 328 |
+
"loss": 0.3216629266738892,
|
| 329 |
+
"step": 820
|
| 330 |
+
},
|
| 331 |
+
{
|
| 332 |
+
"epoch": 0.056622851365015166,
|
| 333 |
+
"grad_norm": 0.291015625,
|
| 334 |
+
"learning_rate": 0.0003,
|
| 335 |
+
"loss": 0.3161738157272339,
|
| 336 |
+
"step": 840
|
| 337 |
+
},
|
| 338 |
+
{
|
| 339 |
+
"epoch": 0.057971014492753624,
|
| 340 |
+
"grad_norm": 0.26171875,
|
| 341 |
+
"learning_rate": 0.0003,
|
| 342 |
+
"loss": 0.30926101207733153,
|
| 343 |
+
"step": 860
|
| 344 |
+
},
|
| 345 |
+
{
|
| 346 |
+
"epoch": 0.05931917762049208,
|
| 347 |
+
"grad_norm": 0.27734375,
|
| 348 |
+
"learning_rate": 0.0003,
|
| 349 |
+
"loss": 0.30281963348388674,
|
| 350 |
+
"step": 880
|
| 351 |
+
},
|
| 352 |
+
{
|
| 353 |
+
"epoch": 0.06066734074823053,
|
| 354 |
+
"grad_norm": 0.287109375,
|
| 355 |
+
"learning_rate": 0.0003,
|
| 356 |
+
"loss": 0.301728343963623,
|
| 357 |
+
"step": 900
|
| 358 |
+
},
|
| 359 |
+
{
|
| 360 |
+
"epoch": 0.06201550387596899,
|
| 361 |
+
"grad_norm": 0.29296875,
|
| 362 |
+
"learning_rate": 0.0003,
|
| 363 |
+
"loss": 0.2986367464065552,
|
| 364 |
+
"step": 920
|
| 365 |
+
},
|
| 366 |
+
{
|
| 367 |
+
"epoch": 0.06336366700370745,
|
| 368 |
+
"grad_norm": 0.306640625,
|
| 369 |
+
"learning_rate": 0.0003,
|
| 370 |
+
"loss": 0.294226336479187,
|
| 371 |
+
"step": 940
|
| 372 |
+
},
|
| 373 |
+
{
|
| 374 |
+
"epoch": 0.06471183013144591,
|
| 375 |
+
"grad_norm": 0.33984375,
|
| 376 |
+
"learning_rate": 0.0003,
|
| 377 |
+
"loss": 0.28919248580932616,
|
| 378 |
+
"step": 960
|
| 379 |
+
},
|
| 380 |
+
{
|
| 381 |
+
"epoch": 0.06605999325918437,
|
| 382 |
+
"grad_norm": 0.296875,
|
| 383 |
+
"learning_rate": 0.0003,
|
| 384 |
+
"loss": 0.2873764276504517,
|
| 385 |
+
"step": 980
|
| 386 |
+
},
|
| 387 |
+
{
|
| 388 |
+
"epoch": 0.06740815638692282,
|
| 389 |
+
"grad_norm": 0.322265625,
|
| 390 |
+
"learning_rate": 0.0003,
|
| 391 |
+
"loss": 0.2850848436355591,
|
| 392 |
+
"step": 1000
|
| 393 |
+
},
|
| 394 |
+
{
|
| 395 |
+
"epoch": 0.06740815638692282,
|
| 396 |
+
"eval_loss": 0.284612774848938,
|
| 397 |
+
"eval_runtime": 8.55,
|
| 398 |
+
"eval_samples_per_second": 1114.271,
|
| 399 |
+
"eval_steps_per_second": 17.427,
|
| 400 |
+
"step": 1000
|
| 401 |
+
},
|
| 402 |
+
{
|
| 403 |
+
"epoch": 0.06875631951466127,
|
| 404 |
+
"grad_norm": 0.357421875,
|
| 405 |
+
"learning_rate": 0.0003,
|
| 406 |
+
"loss": 0.2803910255432129,
|
| 407 |
+
"step": 1020
|
| 408 |
+
},
|
| 409 |
+
{
|
| 410 |
+
"epoch": 0.07010448264239973,
|
| 411 |
+
"grad_norm": 0.37890625,
|
| 412 |
+
"learning_rate": 0.0003,
|
| 413 |
+
"loss": 0.27601516246795654,
|
| 414 |
+
"step": 1040
|
| 415 |
+
},
|
| 416 |
+
{
|
| 417 |
+
"epoch": 0.07145264577013818,
|
| 418 |
+
"grad_norm": 0.3203125,
|
| 419 |
+
"learning_rate": 0.0003,
|
| 420 |
+
"loss": 0.27540276050567625,
|
| 421 |
+
"step": 1060
|
| 422 |
+
},
|
| 423 |
+
{
|
| 424 |
+
"epoch": 0.07280080889787664,
|
| 425 |
+
"grad_norm": 0.318359375,
|
| 426 |
+
"learning_rate": 0.0003,
|
| 427 |
+
"loss": 0.2708603858947754,
|
| 428 |
+
"step": 1080
|
| 429 |
+
},
|
| 430 |
+
{
|
| 431 |
+
"epoch": 0.0741489720256151,
|
| 432 |
+
"grad_norm": 0.328125,
|
| 433 |
+
"learning_rate": 0.0003,
|
| 434 |
+
"loss": 0.2696371555328369,
|
| 435 |
+
"step": 1100
|
| 436 |
+
},
|
| 437 |
+
{
|
| 438 |
+
"epoch": 0.07549713515335356,
|
| 439 |
+
"grad_norm": 0.3671875,
|
| 440 |
+
"learning_rate": 0.0003,
|
| 441 |
+
"loss": 0.26611151695251467,
|
| 442 |
+
"step": 1120
|
| 443 |
+
},
|
| 444 |
+
{
|
| 445 |
+
"epoch": 0.07684529828109202,
|
| 446 |
+
"grad_norm": 1.828125,
|
| 447 |
+
"learning_rate": 0.0003,
|
| 448 |
+
"loss": 0.27770705223083497,
|
| 449 |
+
"step": 1140
|
| 450 |
+
},
|
| 451 |
+
{
|
| 452 |
+
"epoch": 0.07819346140883048,
|
| 453 |
+
"grad_norm": 0.5390625,
|
| 454 |
+
"learning_rate": 0.0003,
|
| 455 |
+
"loss": 0.28163862228393555,
|
| 456 |
+
"step": 1160
|
| 457 |
+
},
|
| 458 |
+
{
|
| 459 |
+
"epoch": 0.07954162453656892,
|
| 460 |
+
"grad_norm": 0.3671875,
|
| 461 |
+
"learning_rate": 0.0003,
|
| 462 |
+
"loss": 0.2673502445220947,
|
| 463 |
+
"step": 1180
|
| 464 |
+
},
|
| 465 |
+
{
|
| 466 |
+
"epoch": 0.08088978766430738,
|
| 467 |
+
"grad_norm": 0.275390625,
|
| 468 |
+
"learning_rate": 0.0003,
|
| 469 |
+
"loss": 0.262909460067749,
|
| 470 |
+
"step": 1200
|
| 471 |
+
},
|
| 472 |
+
{
|
| 473 |
+
"epoch": 0.08088978766430738,
|
| 474 |
+
"eval_loss": 0.26177507638931274,
|
| 475 |
+
"eval_runtime": 8.3534,
|
| 476 |
+
"eval_samples_per_second": 1140.5,
|
| 477 |
+
"eval_steps_per_second": 17.837,
|
| 478 |
+
"step": 1200
|
| 479 |
+
},
|
| 480 |
+
{
|
| 481 |
+
"epoch": 0.08223795079204584,
|
| 482 |
+
"grad_norm": 0.26953125,
|
| 483 |
+
"learning_rate": 0.0003,
|
| 484 |
+
"loss": 0.2581258535385132,
|
| 485 |
+
"step": 1220
|
| 486 |
+
},
|
| 487 |
+
{
|
| 488 |
+
"epoch": 0.0835861139197843,
|
| 489 |
+
"grad_norm": 0.26171875,
|
| 490 |
+
"learning_rate": 0.0003,
|
| 491 |
+
"loss": 0.25597529411315917,
|
| 492 |
+
"step": 1240
|
| 493 |
+
},
|
| 494 |
+
{
|
| 495 |
+
"epoch": 0.08493427704752275,
|
| 496 |
+
"grad_norm": 0.2578125,
|
| 497 |
+
"learning_rate": 0.0003,
|
| 498 |
+
"loss": 0.25467369556427,
|
| 499 |
+
"step": 1260
|
| 500 |
+
},
|
| 501 |
+
{
|
| 502 |
+
"epoch": 0.08628244017526121,
|
| 503 |
+
"grad_norm": 0.25,
|
| 504 |
+
"learning_rate": 0.0003,
|
| 505 |
+
"loss": 0.2502788543701172,
|
| 506 |
+
"step": 1280
|
| 507 |
+
},
|
| 508 |
+
{
|
| 509 |
+
"epoch": 0.08763060330299967,
|
| 510 |
+
"grad_norm": 0.259765625,
|
| 511 |
+
"learning_rate": 0.0003,
|
| 512 |
+
"loss": 0.25013630390167235,
|
| 513 |
+
"step": 1300
|
| 514 |
+
},
|
| 515 |
+
{
|
| 516 |
+
"epoch": 0.08897876643073811,
|
| 517 |
+
"grad_norm": 0.2470703125,
|
| 518 |
+
"learning_rate": 0.0003,
|
| 519 |
+
"loss": 0.24711339473724364,
|
| 520 |
+
"step": 1320
|
| 521 |
+
},
|
| 522 |
+
{
|
| 523 |
+
"epoch": 0.09032692955847657,
|
| 524 |
+
"grad_norm": 0.25,
|
| 525 |
+
"learning_rate": 0.0003,
|
| 526 |
+
"loss": 0.2463146924972534,
|
| 527 |
+
"step": 1340
|
| 528 |
+
},
|
| 529 |
+
{
|
| 530 |
+
"epoch": 0.09167509268621503,
|
| 531 |
+
"grad_norm": 0.32421875,
|
| 532 |
+
"learning_rate": 0.0003,
|
| 533 |
+
"loss": 0.2437490701675415,
|
| 534 |
+
"step": 1360
|
| 535 |
+
},
|
| 536 |
+
{
|
| 537 |
+
"epoch": 0.09302325581395349,
|
| 538 |
+
"grad_norm": 0.259765625,
|
| 539 |
+
"learning_rate": 0.0003,
|
| 540 |
+
"loss": 0.2432482957839966,
|
| 541 |
+
"step": 1380
|
| 542 |
+
},
|
| 543 |
+
{
|
| 544 |
+
"epoch": 0.09437141894169195,
|
| 545 |
+
"grad_norm": 0.265625,
|
| 546 |
+
"learning_rate": 0.0003,
|
| 547 |
+
"loss": 0.24097964763641358,
|
| 548 |
+
"step": 1400
|
| 549 |
+
},
|
| 550 |
+
{
|
| 551 |
+
"epoch": 0.09437141894169195,
|
| 552 |
+
"eval_loss": 0.24285024404525757,
|
| 553 |
+
"eval_runtime": 8.4015,
|
| 554 |
+
"eval_samples_per_second": 1133.969,
|
| 555 |
+
"eval_steps_per_second": 17.735,
|
| 556 |
+
"step": 1400
|
| 557 |
+
},
|
| 558 |
+
{
|
| 559 |
+
"epoch": 0.0957195820694304,
|
| 560 |
+
"grad_norm": 0.265625,
|
| 561 |
+
"learning_rate": 0.0003,
|
| 562 |
+
"loss": 0.2406073570251465,
|
| 563 |
+
"step": 1420
|
| 564 |
+
},
|
| 565 |
+
{
|
| 566 |
+
"epoch": 0.09706774519716886,
|
| 567 |
+
"grad_norm": 0.255859375,
|
| 568 |
+
"learning_rate": 0.0003,
|
| 569 |
+
"loss": 0.23866963386535645,
|
| 570 |
+
"step": 1440
|
| 571 |
+
},
|
| 572 |
+
{
|
| 573 |
+
"epoch": 0.09841590832490732,
|
| 574 |
+
"grad_norm": 0.267578125,
|
| 575 |
+
"learning_rate": 0.0003,
|
| 576 |
+
"loss": 0.2364635467529297,
|
| 577 |
+
"step": 1460
|
| 578 |
+
},
|
| 579 |
+
{
|
| 580 |
+
"epoch": 0.09976407145264576,
|
| 581 |
+
"grad_norm": 0.2578125,
|
| 582 |
+
"learning_rate": 0.0003,
|
| 583 |
+
"loss": 0.23464763164520264,
|
| 584 |
+
"step": 1480
|
| 585 |
+
},
|
| 586 |
+
{
|
| 587 |
+
"epoch": 0.10111223458038422,
|
| 588 |
+
"grad_norm": 0.24609375,
|
| 589 |
+
"learning_rate": 0.0003,
|
| 590 |
+
"loss": 0.23385767936706542,
|
| 591 |
+
"step": 1500
|
| 592 |
+
}
|
| 593 |
+
],
|
| 594 |
+
"logging_steps": 20,
|
| 595 |
+
"max_steps": 2000,
|
| 596 |
+
"num_input_tokens_seen": 0,
|
| 597 |
+
"num_train_epochs": 1,
|
| 598 |
+
"save_steps": 500,
|
| 599 |
+
"stateful_callbacks": {
|
| 600 |
+
"TrainerControl": {
|
| 601 |
+
"args": {
|
| 602 |
+
"should_epoch_stop": false,
|
| 603 |
+
"should_evaluate": false,
|
| 604 |
+
"should_log": false,
|
| 605 |
+
"should_save": true,
|
| 606 |
+
"should_training_stop": false
|
| 607 |
+
},
|
| 608 |
+
"attributes": {}
|
| 609 |
+
}
|
| 610 |
+
},
|
| 611 |
+
"total_flos": 435582664704000.0,
|
| 612 |
+
"train_batch_size": 64,
|
| 613 |
+
"trial_name": null,
|
| 614 |
+
"trial_params": null
|
| 615 |
+
}
|
out/glu-gelu-9L_run/checkpoint-1500/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a5bc9b69db12445b4a7919b29e76d261b3c2acbea92402190b4ca5d146c69daa
|
| 3 |
+
size 4920
|
out/glu-gelu-9L_run/checkpoint-2000/config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"TinyLlamaForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_bias": false,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"bos_token_id": 1,
|
| 9 |
+
"dtype": "bfloat16",
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
+
"head_dim": 32,
|
| 12 |
+
"hidden_act": "silu",
|
| 13 |
+
"hidden_size": 128,
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 256,
|
| 16 |
+
"max_position_embeddings": 512,
|
| 17 |
+
"mlp_bias": false,
|
| 18 |
+
"mlp_type": "glu",
|
| 19 |
+
"model_type": "tiny_llama",
|
| 20 |
+
"num_attention_heads": 4,
|
| 21 |
+
"num_hidden_layers": 9,
|
| 22 |
+
"num_key_value_heads": 4,
|
| 23 |
+
"pad_token_id": 0,
|
| 24 |
+
"pretraining_tp": 1,
|
| 25 |
+
"rms_norm_eps": 1e-06,
|
| 26 |
+
"rope_parameters": {
|
| 27 |
+
"rope_theta": 10000.0,
|
| 28 |
+
"rope_type": "default"
|
| 29 |
+
},
|
| 30 |
+
"tie_word_embeddings": true,
|
| 31 |
+
"tokenizer_name": "w-ahmad/tiny-stories-tokenizer",
|
| 32 |
+
"transformers_version": "5.15.0.dev0",
|
| 33 |
+
"use_cache": false,
|
| 34 |
+
"vocab_size": 4096
|
| 35 |
+
}
|
out/glu-gelu-9L_run/checkpoint-2000/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:efa7bcb247c2e6fbd4d32ab423b71b076c710576b4833e9258447d136870faaf
|
| 3 |
+
size 4011496
|
out/glu-gelu-9L_run/checkpoint-2000/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c1d8ce91bbbfc275aa72005f5fd5506f144e86ade8681b0ecd59995238f0408b
|
| 3 |
+
size 8074746
|
out/glu-gelu-9L_run/checkpoint-2000/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b1a97db8e41139aa1239ba7fb79ddeb0af5998c6305a440c1fe182e6ad02f2f5
|
| 3 |
+
size 14244
|
out/glu-gelu-9L_run/checkpoint-2000/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e91519ad666af6acc4beafd44aa617aefb90f632388a0f75cbf88f957400c190
|
| 3 |
+
size 1064
|
out/glu-gelu-9L_run/checkpoint-2000/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out/glu-gelu-9L_run/checkpoint-2000/tokenizer_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<|endoftext|>",
|
| 5 |
+
"eos_token": "<|endoftext|>",
|
| 6 |
+
"errors": "replace",
|
| 7 |
+
"is_local": false,
|
| 8 |
+
"local_files_only": false,
|
| 9 |
+
"model_max_length": 1024,
|
| 10 |
+
"pad_token": "<|endoftext|>",
|
| 11 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 12 |
+
"unk_token": "<|endoftext|>"
|
| 13 |
+
}
|
out/glu-gelu-9L_run/checkpoint-2000/trainer_state.json
ADDED
|
@@ -0,0 +1,814 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": null,
|
| 3 |
+
"best_metric": null,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 0.13481631277384565,
|
| 6 |
+
"eval_steps": 200,
|
| 7 |
+
"global_step": 2000,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"epoch": 0.0013481631277384564,
|
| 14 |
+
"grad_norm": 1.2578125,
|
| 15 |
+
"learning_rate": 0.0003,
|
| 16 |
+
"loss": 7.793476104736328,
|
| 17 |
+
"step": 20
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"epoch": 0.002696326255476913,
|
| 21 |
+
"grad_norm": 1.171875,
|
| 22 |
+
"learning_rate": 0.0003,
|
| 23 |
+
"loss": 7.021186828613281,
|
| 24 |
+
"step": 40
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"epoch": 0.004044489383215369,
|
| 28 |
+
"grad_norm": 1.0,
|
| 29 |
+
"learning_rate": 0.0003,
|
| 30 |
+
"loss": 6.446919250488281,
|
| 31 |
+
"step": 60
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"epoch": 0.005392652510953826,
|
| 35 |
+
"grad_norm": 1.4609375,
|
| 36 |
+
"learning_rate": 0.0003,
|
| 37 |
+
"loss": 5.989651489257812,
|
| 38 |
+
"step": 80
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"epoch": 0.006740815638692282,
|
| 42 |
+
"grad_norm": 2.328125,
|
| 43 |
+
"learning_rate": 0.0003,
|
| 44 |
+
"loss": 5.436912536621094,
|
| 45 |
+
"step": 100
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"epoch": 0.008088978766430738,
|
| 49 |
+
"grad_norm": 2.671875,
|
| 50 |
+
"learning_rate": 0.0003,
|
| 51 |
+
"loss": 4.910789871215821,
|
| 52 |
+
"step": 120
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"epoch": 0.009437141894169195,
|
| 56 |
+
"grad_norm": 3.28125,
|
| 57 |
+
"learning_rate": 0.0003,
|
| 58 |
+
"loss": 4.441200637817383,
|
| 59 |
+
"step": 140
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"epoch": 0.010785305021907651,
|
| 63 |
+
"grad_norm": 2.625,
|
| 64 |
+
"learning_rate": 0.0003,
|
| 65 |
+
"loss": 4.035322952270508,
|
| 66 |
+
"step": 160
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"epoch": 0.012133468149646108,
|
| 70 |
+
"grad_norm": 3.765625,
|
| 71 |
+
"learning_rate": 0.0003,
|
| 72 |
+
"loss": 3.6691635131835936,
|
| 73 |
+
"step": 180
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"epoch": 0.013481631277384564,
|
| 77 |
+
"grad_norm": 2.296875,
|
| 78 |
+
"learning_rate": 0.0003,
|
| 79 |
+
"loss": 3.315158462524414,
|
| 80 |
+
"step": 200
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"epoch": 0.013481631277384564,
|
| 84 |
+
"eval_loss": 3.140667200088501,
|
| 85 |
+
"eval_runtime": 8.3121,
|
| 86 |
+
"eval_samples_per_second": 1146.166,
|
| 87 |
+
"eval_steps_per_second": 17.926,
|
| 88 |
+
"step": 200
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"epoch": 0.01482979440512302,
|
| 92 |
+
"grad_norm": 2.453125,
|
| 93 |
+
"learning_rate": 0.0003,
|
| 94 |
+
"loss": 2.9744741439819338,
|
| 95 |
+
"step": 220
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"epoch": 0.016177957532861477,
|
| 99 |
+
"grad_norm": 2.359375,
|
| 100 |
+
"learning_rate": 0.0003,
|
| 101 |
+
"loss": 2.6262161254882814,
|
| 102 |
+
"step": 240
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"epoch": 0.01752612066059993,
|
| 106 |
+
"grad_norm": 2.234375,
|
| 107 |
+
"learning_rate": 0.0003,
|
| 108 |
+
"loss": 2.3146018981933594,
|
| 109 |
+
"step": 260
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"epoch": 0.01887428378833839,
|
| 113 |
+
"grad_norm": 2.015625,
|
| 114 |
+
"learning_rate": 0.0003,
|
| 115 |
+
"loss": 1.9927532196044921,
|
| 116 |
+
"step": 280
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"epoch": 0.020222446916076844,
|
| 120 |
+
"grad_norm": 1.609375,
|
| 121 |
+
"learning_rate": 0.0003,
|
| 122 |
+
"loss": 1.6939159393310548,
|
| 123 |
+
"step": 300
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"epoch": 0.021570610043815303,
|
| 127 |
+
"grad_norm": 1.734375,
|
| 128 |
+
"learning_rate": 0.0003,
|
| 129 |
+
"loss": 1.4503639221191407,
|
| 130 |
+
"step": 320
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"epoch": 0.022918773171553757,
|
| 134 |
+
"grad_norm": 1.828125,
|
| 135 |
+
"learning_rate": 0.0003,
|
| 136 |
+
"loss": 1.2639431953430176,
|
| 137 |
+
"step": 340
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"epoch": 0.024266936299292215,
|
| 141 |
+
"grad_norm": 1.984375,
|
| 142 |
+
"learning_rate": 0.0003,
|
| 143 |
+
"loss": 1.1161455154418944,
|
| 144 |
+
"step": 360
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"epoch": 0.02561509942703067,
|
| 148 |
+
"grad_norm": 1.546875,
|
| 149 |
+
"learning_rate": 0.0003,
|
| 150 |
+
"loss": 0.9919822692871094,
|
| 151 |
+
"step": 380
|
| 152 |
+
},
|
| 153 |
+
{
|
| 154 |
+
"epoch": 0.026963262554769128,
|
| 155 |
+
"grad_norm": 1.1484375,
|
| 156 |
+
"learning_rate": 0.0003,
|
| 157 |
+
"loss": 0.8975520133972168,
|
| 158 |
+
"step": 400
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"epoch": 0.026963262554769128,
|
| 162 |
+
"eval_loss": 0.8561499714851379,
|
| 163 |
+
"eval_runtime": 8.3662,
|
| 164 |
+
"eval_samples_per_second": 1138.75,
|
| 165 |
+
"eval_steps_per_second": 17.81,
|
| 166 |
+
"step": 400
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
"epoch": 0.028311425682507583,
|
| 170 |
+
"grad_norm": 0.67578125,
|
| 171 |
+
"learning_rate": 0.0003,
|
| 172 |
+
"loss": 0.7963034629821777,
|
| 173 |
+
"step": 420
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"epoch": 0.02965958881024604,
|
| 177 |
+
"grad_norm": 0.51171875,
|
| 178 |
+
"learning_rate": 0.0003,
|
| 179 |
+
"loss": 0.7076507568359375,
|
| 180 |
+
"step": 440
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"epoch": 0.031007751937984496,
|
| 184 |
+
"grad_norm": 0.439453125,
|
| 185 |
+
"learning_rate": 0.0003,
|
| 186 |
+
"loss": 0.6221071720123291,
|
| 187 |
+
"step": 460
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"epoch": 0.032355915065722954,
|
| 191 |
+
"grad_norm": 0.423828125,
|
| 192 |
+
"learning_rate": 0.0003,
|
| 193 |
+
"loss": 0.5685368537902832,
|
| 194 |
+
"step": 480
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"epoch": 0.03370407819346141,
|
| 198 |
+
"grad_norm": 0.3671875,
|
| 199 |
+
"learning_rate": 0.0003,
|
| 200 |
+
"loss": 0.5213922977447509,
|
| 201 |
+
"step": 500
|
| 202 |
+
},
|
| 203 |
+
{
|
| 204 |
+
"epoch": 0.03505224132119986,
|
| 205 |
+
"grad_norm": 0.380859375,
|
| 206 |
+
"learning_rate": 0.0003,
|
| 207 |
+
"loss": 0.4871851444244385,
|
| 208 |
+
"step": 520
|
| 209 |
+
},
|
| 210 |
+
{
|
| 211 |
+
"epoch": 0.03640040444893832,
|
| 212 |
+
"grad_norm": 0.36328125,
|
| 213 |
+
"learning_rate": 0.0003,
|
| 214 |
+
"loss": 0.4552904605865479,
|
| 215 |
+
"step": 540
|
| 216 |
+
},
|
| 217 |
+
{
|
| 218 |
+
"epoch": 0.03774856757667678,
|
| 219 |
+
"grad_norm": 0.388671875,
|
| 220 |
+
"learning_rate": 0.0003,
|
| 221 |
+
"loss": 0.4377324104309082,
|
| 222 |
+
"step": 560
|
| 223 |
+
},
|
| 224 |
+
{
|
| 225 |
+
"epoch": 0.03909673070441524,
|
| 226 |
+
"grad_norm": 0.400390625,
|
| 227 |
+
"learning_rate": 0.0003,
|
| 228 |
+
"loss": 0.4190248966217041,
|
| 229 |
+
"step": 580
|
| 230 |
+
},
|
| 231 |
+
{
|
| 232 |
+
"epoch": 0.04044489383215369,
|
| 233 |
+
"grad_norm": 0.392578125,
|
| 234 |
+
"learning_rate": 0.0003,
|
| 235 |
+
"loss": 0.40812134742736816,
|
| 236 |
+
"step": 600
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"epoch": 0.04044489383215369,
|
| 240 |
+
"eval_loss": 0.40287962555885315,
|
| 241 |
+
"eval_runtime": 8.3848,
|
| 242 |
+
"eval_samples_per_second": 1136.228,
|
| 243 |
+
"eval_steps_per_second": 17.77,
|
| 244 |
+
"step": 600
|
| 245 |
+
},
|
| 246 |
+
{
|
| 247 |
+
"epoch": 0.04179305695989215,
|
| 248 |
+
"grad_norm": 0.40234375,
|
| 249 |
+
"learning_rate": 0.0003,
|
| 250 |
+
"loss": 0.39397249221801756,
|
| 251 |
+
"step": 620
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"epoch": 0.043141220087630605,
|
| 255 |
+
"grad_norm": 0.4140625,
|
| 256 |
+
"learning_rate": 0.0003,
|
| 257 |
+
"loss": 0.38487560749053956,
|
| 258 |
+
"step": 640
|
| 259 |
+
},
|
| 260 |
+
{
|
| 261 |
+
"epoch": 0.044489383215369056,
|
| 262 |
+
"grad_norm": 0.376953125,
|
| 263 |
+
"learning_rate": 0.0003,
|
| 264 |
+
"loss": 0.37073094844818116,
|
| 265 |
+
"step": 660
|
| 266 |
+
},
|
| 267 |
+
{
|
| 268 |
+
"epoch": 0.045837546343107514,
|
| 269 |
+
"grad_norm": 2.453125,
|
| 270 |
+
"learning_rate": 0.0003,
|
| 271 |
+
"loss": 0.36380269527435305,
|
| 272 |
+
"step": 680
|
| 273 |
+
},
|
| 274 |
+
{
|
| 275 |
+
"epoch": 0.04718570947084597,
|
| 276 |
+
"grad_norm": 1.171875,
|
| 277 |
+
"learning_rate": 0.0003,
|
| 278 |
+
"loss": 0.3727259159088135,
|
| 279 |
+
"step": 700
|
| 280 |
+
},
|
| 281 |
+
{
|
| 282 |
+
"epoch": 0.04853387259858443,
|
| 283 |
+
"grad_norm": 0.44921875,
|
| 284 |
+
"learning_rate": 0.0003,
|
| 285 |
+
"loss": 0.36068120002746584,
|
| 286 |
+
"step": 720
|
| 287 |
+
},
|
| 288 |
+
{
|
| 289 |
+
"epoch": 0.04988203572632288,
|
| 290 |
+
"grad_norm": 0.3359375,
|
| 291 |
+
"learning_rate": 0.0003,
|
| 292 |
+
"loss": 0.345484185218811,
|
| 293 |
+
"step": 740
|
| 294 |
+
},
|
| 295 |
+
{
|
| 296 |
+
"epoch": 0.05123019885406134,
|
| 297 |
+
"grad_norm": 0.271484375,
|
| 298 |
+
"learning_rate": 0.0003,
|
| 299 |
+
"loss": 0.3413747549057007,
|
| 300 |
+
"step": 760
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
"epoch": 0.0525783619817998,
|
| 304 |
+
"grad_norm": 0.279296875,
|
| 305 |
+
"learning_rate": 0.0003,
|
| 306 |
+
"loss": 0.3339890956878662,
|
| 307 |
+
"step": 780
|
| 308 |
+
},
|
| 309 |
+
{
|
| 310 |
+
"epoch": 0.053926525109538256,
|
| 311 |
+
"grad_norm": 0.27734375,
|
| 312 |
+
"learning_rate": 0.0003,
|
| 313 |
+
"loss": 0.32567362785339354,
|
| 314 |
+
"step": 800
|
| 315 |
+
},
|
| 316 |
+
{
|
| 317 |
+
"epoch": 0.053926525109538256,
|
| 318 |
+
"eval_loss": 0.32622790336608887,
|
| 319 |
+
"eval_runtime": 8.4003,
|
| 320 |
+
"eval_samples_per_second": 1134.122,
|
| 321 |
+
"eval_steps_per_second": 17.737,
|
| 322 |
+
"step": 800
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"epoch": 0.05527468823727671,
|
| 326 |
+
"grad_norm": 0.275390625,
|
| 327 |
+
"learning_rate": 0.0003,
|
| 328 |
+
"loss": 0.3216629266738892,
|
| 329 |
+
"step": 820
|
| 330 |
+
},
|
| 331 |
+
{
|
| 332 |
+
"epoch": 0.056622851365015166,
|
| 333 |
+
"grad_norm": 0.291015625,
|
| 334 |
+
"learning_rate": 0.0003,
|
| 335 |
+
"loss": 0.3161738157272339,
|
| 336 |
+
"step": 840
|
| 337 |
+
},
|
| 338 |
+
{
|
| 339 |
+
"epoch": 0.057971014492753624,
|
| 340 |
+
"grad_norm": 0.26171875,
|
| 341 |
+
"learning_rate": 0.0003,
|
| 342 |
+
"loss": 0.30926101207733153,
|
| 343 |
+
"step": 860
|
| 344 |
+
},
|
| 345 |
+
{
|
| 346 |
+
"epoch": 0.05931917762049208,
|
| 347 |
+
"grad_norm": 0.27734375,
|
| 348 |
+
"learning_rate": 0.0003,
|
| 349 |
+
"loss": 0.30281963348388674,
|
| 350 |
+
"step": 880
|
| 351 |
+
},
|
| 352 |
+
{
|
| 353 |
+
"epoch": 0.06066734074823053,
|
| 354 |
+
"grad_norm": 0.287109375,
|
| 355 |
+
"learning_rate": 0.0003,
|
| 356 |
+
"loss": 0.301728343963623,
|
| 357 |
+
"step": 900
|
| 358 |
+
},
|
| 359 |
+
{
|
| 360 |
+
"epoch": 0.06201550387596899,
|
| 361 |
+
"grad_norm": 0.29296875,
|
| 362 |
+
"learning_rate": 0.0003,
|
| 363 |
+
"loss": 0.2986367464065552,
|
| 364 |
+
"step": 920
|
| 365 |
+
},
|
| 366 |
+
{
|
| 367 |
+
"epoch": 0.06336366700370745,
|
| 368 |
+
"grad_norm": 0.306640625,
|
| 369 |
+
"learning_rate": 0.0003,
|
| 370 |
+
"loss": 0.294226336479187,
|
| 371 |
+
"step": 940
|
| 372 |
+
},
|
| 373 |
+
{
|
| 374 |
+
"epoch": 0.06471183013144591,
|
| 375 |
+
"grad_norm": 0.33984375,
|
| 376 |
+
"learning_rate": 0.0003,
|
| 377 |
+
"loss": 0.28919248580932616,
|
| 378 |
+
"step": 960
|
| 379 |
+
},
|
| 380 |
+
{
|
| 381 |
+
"epoch": 0.06605999325918437,
|
| 382 |
+
"grad_norm": 0.296875,
|
| 383 |
+
"learning_rate": 0.0003,
|
| 384 |
+
"loss": 0.2873764276504517,
|
| 385 |
+
"step": 980
|
| 386 |
+
},
|
| 387 |
+
{
|
| 388 |
+
"epoch": 0.06740815638692282,
|
| 389 |
+
"grad_norm": 0.322265625,
|
| 390 |
+
"learning_rate": 0.0003,
|
| 391 |
+
"loss": 0.2850848436355591,
|
| 392 |
+
"step": 1000
|
| 393 |
+
},
|
| 394 |
+
{
|
| 395 |
+
"epoch": 0.06740815638692282,
|
| 396 |
+
"eval_loss": 0.284612774848938,
|
| 397 |
+
"eval_runtime": 8.55,
|
| 398 |
+
"eval_samples_per_second": 1114.271,
|
| 399 |
+
"eval_steps_per_second": 17.427,
|
| 400 |
+
"step": 1000
|
| 401 |
+
},
|
| 402 |
+
{
|
| 403 |
+
"epoch": 0.06875631951466127,
|
| 404 |
+
"grad_norm": 0.357421875,
|
| 405 |
+
"learning_rate": 0.0003,
|
| 406 |
+
"loss": 0.2803910255432129,
|
| 407 |
+
"step": 1020
|
| 408 |
+
},
|
| 409 |
+
{
|
| 410 |
+
"epoch": 0.07010448264239973,
|
| 411 |
+
"grad_norm": 0.37890625,
|
| 412 |
+
"learning_rate": 0.0003,
|
| 413 |
+
"loss": 0.27601516246795654,
|
| 414 |
+
"step": 1040
|
| 415 |
+
},
|
| 416 |
+
{
|
| 417 |
+
"epoch": 0.07145264577013818,
|
| 418 |
+
"grad_norm": 0.3203125,
|
| 419 |
+
"learning_rate": 0.0003,
|
| 420 |
+
"loss": 0.27540276050567625,
|
| 421 |
+
"step": 1060
|
| 422 |
+
},
|
| 423 |
+
{
|
| 424 |
+
"epoch": 0.07280080889787664,
|
| 425 |
+
"grad_norm": 0.318359375,
|
| 426 |
+
"learning_rate": 0.0003,
|
| 427 |
+
"loss": 0.2708603858947754,
|
| 428 |
+
"step": 1080
|
| 429 |
+
},
|
| 430 |
+
{
|
| 431 |
+
"epoch": 0.0741489720256151,
|
| 432 |
+
"grad_norm": 0.328125,
|
| 433 |
+
"learning_rate": 0.0003,
|
| 434 |
+
"loss": 0.2696371555328369,
|
| 435 |
+
"step": 1100
|
| 436 |
+
},
|
| 437 |
+
{
|
| 438 |
+
"epoch": 0.07549713515335356,
|
| 439 |
+
"grad_norm": 0.3671875,
|
| 440 |
+
"learning_rate": 0.0003,
|
| 441 |
+
"loss": 0.26611151695251467,
|
| 442 |
+
"step": 1120
|
| 443 |
+
},
|
| 444 |
+
{
|
| 445 |
+
"epoch": 0.07684529828109202,
|
| 446 |
+
"grad_norm": 1.828125,
|
| 447 |
+
"learning_rate": 0.0003,
|
| 448 |
+
"loss": 0.27770705223083497,
|
| 449 |
+
"step": 1140
|
| 450 |
+
},
|
| 451 |
+
{
|
| 452 |
+
"epoch": 0.07819346140883048,
|
| 453 |
+
"grad_norm": 0.5390625,
|
| 454 |
+
"learning_rate": 0.0003,
|
| 455 |
+
"loss": 0.28163862228393555,
|
| 456 |
+
"step": 1160
|
| 457 |
+
},
|
| 458 |
+
{
|
| 459 |
+
"epoch": 0.07954162453656892,
|
| 460 |
+
"grad_norm": 0.3671875,
|
| 461 |
+
"learning_rate": 0.0003,
|
| 462 |
+
"loss": 0.2673502445220947,
|
| 463 |
+
"step": 1180
|
| 464 |
+
},
|
| 465 |
+
{
|
| 466 |
+
"epoch": 0.08088978766430738,
|
| 467 |
+
"grad_norm": 0.275390625,
|
| 468 |
+
"learning_rate": 0.0003,
|
| 469 |
+
"loss": 0.262909460067749,
|
| 470 |
+
"step": 1200
|
| 471 |
+
},
|
| 472 |
+
{
|
| 473 |
+
"epoch": 0.08088978766430738,
|
| 474 |
+
"eval_loss": 0.26177507638931274,
|
| 475 |
+
"eval_runtime": 8.3534,
|
| 476 |
+
"eval_samples_per_second": 1140.5,
|
| 477 |
+
"eval_steps_per_second": 17.837,
|
| 478 |
+
"step": 1200
|
| 479 |
+
},
|
| 480 |
+
{
|
| 481 |
+
"epoch": 0.08223795079204584,
|
| 482 |
+
"grad_norm": 0.26953125,
|
| 483 |
+
"learning_rate": 0.0003,
|
| 484 |
+
"loss": 0.2581258535385132,
|
| 485 |
+
"step": 1220
|
| 486 |
+
},
|
| 487 |
+
{
|
| 488 |
+
"epoch": 0.0835861139197843,
|
| 489 |
+
"grad_norm": 0.26171875,
|
| 490 |
+
"learning_rate": 0.0003,
|
| 491 |
+
"loss": 0.25597529411315917,
|
| 492 |
+
"step": 1240
|
| 493 |
+
},
|
| 494 |
+
{
|
| 495 |
+
"epoch": 0.08493427704752275,
|
| 496 |
+
"grad_norm": 0.2578125,
|
| 497 |
+
"learning_rate": 0.0003,
|
| 498 |
+
"loss": 0.25467369556427,
|
| 499 |
+
"step": 1260
|
| 500 |
+
},
|
| 501 |
+
{
|
| 502 |
+
"epoch": 0.08628244017526121,
|
| 503 |
+
"grad_norm": 0.25,
|
| 504 |
+
"learning_rate": 0.0003,
|
| 505 |
+
"loss": 0.2502788543701172,
|
| 506 |
+
"step": 1280
|
| 507 |
+
},
|
| 508 |
+
{
|
| 509 |
+
"epoch": 0.08763060330299967,
|
| 510 |
+
"grad_norm": 0.259765625,
|
| 511 |
+
"learning_rate": 0.0003,
|
| 512 |
+
"loss": 0.25013630390167235,
|
| 513 |
+
"step": 1300
|
| 514 |
+
},
|
| 515 |
+
{
|
| 516 |
+
"epoch": 0.08897876643073811,
|
| 517 |
+
"grad_norm": 0.2470703125,
|
| 518 |
+
"learning_rate": 0.0003,
|
| 519 |
+
"loss": 0.24711339473724364,
|
| 520 |
+
"step": 1320
|
| 521 |
+
},
|
| 522 |
+
{
|
| 523 |
+
"epoch": 0.09032692955847657,
|
| 524 |
+
"grad_norm": 0.25,
|
| 525 |
+
"learning_rate": 0.0003,
|
| 526 |
+
"loss": 0.2463146924972534,
|
| 527 |
+
"step": 1340
|
| 528 |
+
},
|
| 529 |
+
{
|
| 530 |
+
"epoch": 0.09167509268621503,
|
| 531 |
+
"grad_norm": 0.32421875,
|
| 532 |
+
"learning_rate": 0.0003,
|
| 533 |
+
"loss": 0.2437490701675415,
|
| 534 |
+
"step": 1360
|
| 535 |
+
},
|
| 536 |
+
{
|
| 537 |
+
"epoch": 0.09302325581395349,
|
| 538 |
+
"grad_norm": 0.259765625,
|
| 539 |
+
"learning_rate": 0.0003,
|
| 540 |
+
"loss": 0.2432482957839966,
|
| 541 |
+
"step": 1380
|
| 542 |
+
},
|
| 543 |
+
{
|
| 544 |
+
"epoch": 0.09437141894169195,
|
| 545 |
+
"grad_norm": 0.265625,
|
| 546 |
+
"learning_rate": 0.0003,
|
| 547 |
+
"loss": 0.24097964763641358,
|
| 548 |
+
"step": 1400
|
| 549 |
+
},
|
| 550 |
+
{
|
| 551 |
+
"epoch": 0.09437141894169195,
|
| 552 |
+
"eval_loss": 0.24285024404525757,
|
| 553 |
+
"eval_runtime": 8.4015,
|
| 554 |
+
"eval_samples_per_second": 1133.969,
|
| 555 |
+
"eval_steps_per_second": 17.735,
|
| 556 |
+
"step": 1400
|
| 557 |
+
},
|
| 558 |
+
{
|
| 559 |
+
"epoch": 0.0957195820694304,
|
| 560 |
+
"grad_norm": 0.265625,
|
| 561 |
+
"learning_rate": 0.0003,
|
| 562 |
+
"loss": 0.2406073570251465,
|
| 563 |
+
"step": 1420
|
| 564 |
+
},
|
| 565 |
+
{
|
| 566 |
+
"epoch": 0.09706774519716886,
|
| 567 |
+
"grad_norm": 0.255859375,
|
| 568 |
+
"learning_rate": 0.0003,
|
| 569 |
+
"loss": 0.23866963386535645,
|
| 570 |
+
"step": 1440
|
| 571 |
+
},
|
| 572 |
+
{
|
| 573 |
+
"epoch": 0.09841590832490732,
|
| 574 |
+
"grad_norm": 0.267578125,
|
| 575 |
+
"learning_rate": 0.0003,
|
| 576 |
+
"loss": 0.2364635467529297,
|
| 577 |
+
"step": 1460
|
| 578 |
+
},
|
| 579 |
+
{
|
| 580 |
+
"epoch": 0.09976407145264576,
|
| 581 |
+
"grad_norm": 0.2578125,
|
| 582 |
+
"learning_rate": 0.0003,
|
| 583 |
+
"loss": 0.23464763164520264,
|
| 584 |
+
"step": 1480
|
| 585 |
+
},
|
| 586 |
+
{
|
| 587 |
+
"epoch": 0.10111223458038422,
|
| 588 |
+
"grad_norm": 0.24609375,
|
| 589 |
+
"learning_rate": 0.0003,
|
| 590 |
+
"loss": 0.23385767936706542,
|
| 591 |
+
"step": 1500
|
| 592 |
+
},
|
| 593 |
+
{
|
| 594 |
+
"epoch": 0.10246039770812268,
|
| 595 |
+
"grad_norm": 0.2451171875,
|
| 596 |
+
"learning_rate": 0.0003,
|
| 597 |
+
"loss": 0.23197500705718993,
|
| 598 |
+
"step": 1520
|
| 599 |
+
},
|
| 600 |
+
{
|
| 601 |
+
"epoch": 0.10380856083586114,
|
| 602 |
+
"grad_norm": 0.291015625,
|
| 603 |
+
"learning_rate": 0.0003,
|
| 604 |
+
"loss": 0.2319192886352539,
|
| 605 |
+
"step": 1540
|
| 606 |
+
},
|
| 607 |
+
{
|
| 608 |
+
"epoch": 0.1051567239635996,
|
| 609 |
+
"grad_norm": 0.30078125,
|
| 610 |
+
"learning_rate": 0.0003,
|
| 611 |
+
"loss": 0.2309124231338501,
|
| 612 |
+
"step": 1560
|
| 613 |
+
},
|
| 614 |
+
{
|
| 615 |
+
"epoch": 0.10650488709133805,
|
| 616 |
+
"grad_norm": 0.263671875,
|
| 617 |
+
"learning_rate": 0.0003,
|
| 618 |
+
"loss": 0.2315352201461792,
|
| 619 |
+
"step": 1580
|
| 620 |
+
},
|
| 621 |
+
{
|
| 622 |
+
"epoch": 0.10785305021907651,
|
| 623 |
+
"grad_norm": 1.0546875,
|
| 624 |
+
"learning_rate": 0.0003,
|
| 625 |
+
"loss": 0.2452239990234375,
|
| 626 |
+
"step": 1600
|
| 627 |
+
},
|
| 628 |
+
{
|
| 629 |
+
"epoch": 0.10785305021907651,
|
| 630 |
+
"eval_loss": 0.24468769133090973,
|
| 631 |
+
"eval_runtime": 8.3885,
|
| 632 |
+
"eval_samples_per_second": 1135.725,
|
| 633 |
+
"eval_steps_per_second": 17.762,
|
| 634 |
+
"step": 1600
|
| 635 |
+
},
|
| 636 |
+
{
|
| 637 |
+
"epoch": 0.10920121334681497,
|
| 638 |
+
"grad_norm": 0.400390625,
|
| 639 |
+
"learning_rate": 0.0003,
|
| 640 |
+
"loss": 0.23531816005706788,
|
| 641 |
+
"step": 1620
|
| 642 |
+
},
|
| 643 |
+
{
|
| 644 |
+
"epoch": 0.11054937647455342,
|
| 645 |
+
"grad_norm": 0.267578125,
|
| 646 |
+
"learning_rate": 0.0003,
|
| 647 |
+
"loss": 0.22987775802612304,
|
| 648 |
+
"step": 1640
|
| 649 |
+
},
|
| 650 |
+
{
|
| 651 |
+
"epoch": 0.11189753960229187,
|
| 652 |
+
"grad_norm": 0.234375,
|
| 653 |
+
"learning_rate": 0.0003,
|
| 654 |
+
"loss": 0.22664937973022461,
|
| 655 |
+
"step": 1660
|
| 656 |
+
},
|
| 657 |
+
{
|
| 658 |
+
"epoch": 0.11324570273003033,
|
| 659 |
+
"grad_norm": 0.2314453125,
|
| 660 |
+
"learning_rate": 0.0003,
|
| 661 |
+
"loss": 0.22559750080108643,
|
| 662 |
+
"step": 1680
|
| 663 |
+
},
|
| 664 |
+
{
|
| 665 |
+
"epoch": 0.11459386585776879,
|
| 666 |
+
"grad_norm": 0.2373046875,
|
| 667 |
+
"learning_rate": 0.0003,
|
| 668 |
+
"loss": 0.22569913864135743,
|
| 669 |
+
"step": 1700
|
| 670 |
+
},
|
| 671 |
+
{
|
| 672 |
+
"epoch": 0.11594202898550725,
|
| 673 |
+
"grad_norm": 0.228515625,
|
| 674 |
+
"learning_rate": 0.0003,
|
| 675 |
+
"loss": 0.22344863414764404,
|
| 676 |
+
"step": 1720
|
| 677 |
+
},
|
| 678 |
+
{
|
| 679 |
+
"epoch": 0.1172901921132457,
|
| 680 |
+
"grad_norm": 0.2314453125,
|
| 681 |
+
"learning_rate": 0.0003,
|
| 682 |
+
"loss": 0.22342846393585206,
|
| 683 |
+
"step": 1740
|
| 684 |
+
},
|
| 685 |
+
{
|
| 686 |
+
"epoch": 0.11863835524098416,
|
| 687 |
+
"grad_norm": 0.23046875,
|
| 688 |
+
"learning_rate": 0.0003,
|
| 689 |
+
"loss": 0.22171788215637206,
|
| 690 |
+
"step": 1760
|
| 691 |
+
},
|
| 692 |
+
{
|
| 693 |
+
"epoch": 0.11998651836872262,
|
| 694 |
+
"grad_norm": 0.22265625,
|
| 695 |
+
"learning_rate": 0.0003,
|
| 696 |
+
"loss": 0.2223306655883789,
|
| 697 |
+
"step": 1780
|
| 698 |
+
},
|
| 699 |
+
{
|
| 700 |
+
"epoch": 0.12133468149646107,
|
| 701 |
+
"grad_norm": 0.228515625,
|
| 702 |
+
"learning_rate": 0.0003,
|
| 703 |
+
"loss": 0.22238383293151856,
|
| 704 |
+
"step": 1800
|
| 705 |
+
},
|
| 706 |
+
{
|
| 707 |
+
"epoch": 0.12133468149646107,
|
| 708 |
+
"eval_loss": 0.2212776094675064,
|
| 709 |
+
"eval_runtime": 8.3797,
|
| 710 |
+
"eval_samples_per_second": 1136.917,
|
| 711 |
+
"eval_steps_per_second": 17.781,
|
| 712 |
+
"step": 1800
|
| 713 |
+
},
|
| 714 |
+
{
|
| 715 |
+
"epoch": 0.12268284462419952,
|
| 716 |
+
"grad_norm": 0.228515625,
|
| 717 |
+
"learning_rate": 0.0003,
|
| 718 |
+
"loss": 0.22141022682189943,
|
| 719 |
+
"step": 1820
|
| 720 |
+
},
|
| 721 |
+
{
|
| 722 |
+
"epoch": 0.12403100775193798,
|
| 723 |
+
"grad_norm": 0.232421875,
|
| 724 |
+
"learning_rate": 0.0003,
|
| 725 |
+
"loss": 0.21716527938842772,
|
| 726 |
+
"step": 1840
|
| 727 |
+
},
|
| 728 |
+
{
|
| 729 |
+
"epoch": 0.12537917087967643,
|
| 730 |
+
"grad_norm": 0.2353515625,
|
| 731 |
+
"learning_rate": 0.0003,
|
| 732 |
+
"loss": 0.21714138984680176,
|
| 733 |
+
"step": 1860
|
| 734 |
+
},
|
| 735 |
+
{
|
| 736 |
+
"epoch": 0.1267273340074149,
|
| 737 |
+
"grad_norm": 0.2294921875,
|
| 738 |
+
"learning_rate": 0.0003,
|
| 739 |
+
"loss": 0.2167724370956421,
|
| 740 |
+
"step": 1880
|
| 741 |
+
},
|
| 742 |
+
{
|
| 743 |
+
"epoch": 0.12807549713515334,
|
| 744 |
+
"grad_norm": 0.2255859375,
|
| 745 |
+
"learning_rate": 0.0003,
|
| 746 |
+
"loss": 0.2163745403289795,
|
| 747 |
+
"step": 1900
|
| 748 |
+
},
|
| 749 |
+
{
|
| 750 |
+
"epoch": 0.12942366026289182,
|
| 751 |
+
"grad_norm": 0.2333984375,
|
| 752 |
+
"learning_rate": 0.0003,
|
| 753 |
+
"loss": 0.21465139389038085,
|
| 754 |
+
"step": 1920
|
| 755 |
+
},
|
| 756 |
+
{
|
| 757 |
+
"epoch": 0.13077182339063026,
|
| 758 |
+
"grad_norm": 0.2236328125,
|
| 759 |
+
"learning_rate": 0.0003,
|
| 760 |
+
"loss": 0.21518900394439697,
|
| 761 |
+
"step": 1940
|
| 762 |
+
},
|
| 763 |
+
{
|
| 764 |
+
"epoch": 0.13211998651836873,
|
| 765 |
+
"grad_norm": 0.2255859375,
|
| 766 |
+
"learning_rate": 0.0003,
|
| 767 |
+
"loss": 0.21305620670318604,
|
| 768 |
+
"step": 1960
|
| 769 |
+
},
|
| 770 |
+
{
|
| 771 |
+
"epoch": 0.13346814964610718,
|
| 772 |
+
"grad_norm": 0.22265625,
|
| 773 |
+
"learning_rate": 0.0003,
|
| 774 |
+
"loss": 0.21399173736572266,
|
| 775 |
+
"step": 1980
|
| 776 |
+
},
|
| 777 |
+
{
|
| 778 |
+
"epoch": 0.13481631277384565,
|
| 779 |
+
"grad_norm": 0.220703125,
|
| 780 |
+
"learning_rate": 0.0003,
|
| 781 |
+
"loss": 0.21352832317352294,
|
| 782 |
+
"step": 2000
|
| 783 |
+
},
|
| 784 |
+
{
|
| 785 |
+
"epoch": 0.13481631277384565,
|
| 786 |
+
"eval_loss": 0.21510063111782074,
|
| 787 |
+
"eval_runtime": 8.4122,
|
| 788 |
+
"eval_samples_per_second": 1132.528,
|
| 789 |
+
"eval_steps_per_second": 17.712,
|
| 790 |
+
"step": 2000
|
| 791 |
+
}
|
| 792 |
+
],
|
| 793 |
+
"logging_steps": 20,
|
| 794 |
+
"max_steps": 2000,
|
| 795 |
+
"num_input_tokens_seen": 0,
|
| 796 |
+
"num_train_epochs": 1,
|
| 797 |
+
"save_steps": 500,
|
| 798 |
+
"stateful_callbacks": {
|
| 799 |
+
"TrainerControl": {
|
| 800 |
+
"args": {
|
| 801 |
+
"should_epoch_stop": false,
|
| 802 |
+
"should_evaluate": false,
|
| 803 |
+
"should_log": false,
|
| 804 |
+
"should_save": true,
|
| 805 |
+
"should_training_stop": true
|
| 806 |
+
},
|
| 807 |
+
"attributes": {}
|
| 808 |
+
}
|
| 809 |
+
},
|
| 810 |
+
"total_flos": 580776886272000.0,
|
| 811 |
+
"train_batch_size": 64,
|
| 812 |
+
"trial_name": null,
|
| 813 |
+
"trial_params": null
|
| 814 |
+
}
|
out/glu-gelu-9L_run/checkpoint-2000/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a5bc9b69db12445b4a7919b29e76d261b3c2acbea92402190b4ca5d146c69daa
|
| 3 |
+
size 4920
|
out/glu-gelu-9L_run/checkpoint-500/config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"TinyLlamaForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_bias": false,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"bos_token_id": 1,
|
| 9 |
+
"dtype": "bfloat16",
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
+
"head_dim": 32,
|
| 12 |
+
"hidden_act": "silu",
|
| 13 |
+
"hidden_size": 128,
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 256,
|
| 16 |
+
"max_position_embeddings": 512,
|
| 17 |
+
"mlp_bias": false,
|
| 18 |
+
"mlp_type": "glu",
|
| 19 |
+
"model_type": "tiny_llama",
|
| 20 |
+
"num_attention_heads": 4,
|
| 21 |
+
"num_hidden_layers": 9,
|
| 22 |
+
"num_key_value_heads": 4,
|
| 23 |
+
"pad_token_id": 0,
|
| 24 |
+
"pretraining_tp": 1,
|
| 25 |
+
"rms_norm_eps": 1e-06,
|
| 26 |
+
"rope_parameters": {
|
| 27 |
+
"rope_theta": 10000.0,
|
| 28 |
+
"rope_type": "default"
|
| 29 |
+
},
|
| 30 |
+
"tie_word_embeddings": true,
|
| 31 |
+
"tokenizer_name": "w-ahmad/tiny-stories-tokenizer",
|
| 32 |
+
"transformers_version": "5.15.0.dev0",
|
| 33 |
+
"use_cache": false,
|
| 34 |
+
"vocab_size": 4096
|
| 35 |
+
}
|
out/glu-gelu-9L_run/checkpoint-500/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:87d2485366e666ffe60c69a356f612ec9466a7f4ca08911d72d1afb077fb92b8
|
| 3 |
+
size 4011496
|
out/glu-gelu-9L_run/checkpoint-500/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9b4891f5d92679afc5c80fecf82636d6a4bc82ccaeb318adb74e33e82840daf
|
| 3 |
+
size 8074746
|
out/glu-gelu-9L_run/checkpoint-500/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3cf9097d4513154245c48236b6ec5137b7ee2a21c9f58f2cba798ea275c6026f
|
| 3 |
+
size 14244
|
out/glu-gelu-9L_run/checkpoint-500/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e328dcb5672eefa48692126747c226aede5ae2e575011f8f5a2b20326a61f850
|
| 3 |
+
size 1064
|
out/glu-gelu-9L_run/checkpoint-500/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out/glu-gelu-9L_run/checkpoint-500/tokenizer_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<|endoftext|>",
|
| 5 |
+
"eos_token": "<|endoftext|>",
|
| 6 |
+
"errors": "replace",
|
| 7 |
+
"is_local": false,
|
| 8 |
+
"local_files_only": false,
|
| 9 |
+
"model_max_length": 1024,
|
| 10 |
+
"pad_token": "<|endoftext|>",
|
| 11 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 12 |
+
"unk_token": "<|endoftext|>"
|
| 13 |
+
}
|
out/glu-gelu-9L_run/checkpoint-500/trainer_state.json
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": null,
|
| 3 |
+
"best_metric": null,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 0.03370407819346141,
|
| 6 |
+
"eval_steps": 200,
|
| 7 |
+
"global_step": 500,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"epoch": 0.0013481631277384564,
|
| 14 |
+
"grad_norm": 1.2578125,
|
| 15 |
+
"learning_rate": 0.0003,
|
| 16 |
+
"loss": 7.793476104736328,
|
| 17 |
+
"step": 20
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"epoch": 0.002696326255476913,
|
| 21 |
+
"grad_norm": 1.171875,
|
| 22 |
+
"learning_rate": 0.0003,
|
| 23 |
+
"loss": 7.021186828613281,
|
| 24 |
+
"step": 40
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"epoch": 0.004044489383215369,
|
| 28 |
+
"grad_norm": 1.0,
|
| 29 |
+
"learning_rate": 0.0003,
|
| 30 |
+
"loss": 6.446919250488281,
|
| 31 |
+
"step": 60
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"epoch": 0.005392652510953826,
|
| 35 |
+
"grad_norm": 1.4609375,
|
| 36 |
+
"learning_rate": 0.0003,
|
| 37 |
+
"loss": 5.989651489257812,
|
| 38 |
+
"step": 80
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"epoch": 0.006740815638692282,
|
| 42 |
+
"grad_norm": 2.328125,
|
| 43 |
+
"learning_rate": 0.0003,
|
| 44 |
+
"loss": 5.436912536621094,
|
| 45 |
+
"step": 100
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"epoch": 0.008088978766430738,
|
| 49 |
+
"grad_norm": 2.671875,
|
| 50 |
+
"learning_rate": 0.0003,
|
| 51 |
+
"loss": 4.910789871215821,
|
| 52 |
+
"step": 120
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"epoch": 0.009437141894169195,
|
| 56 |
+
"grad_norm": 3.28125,
|
| 57 |
+
"learning_rate": 0.0003,
|
| 58 |
+
"loss": 4.441200637817383,
|
| 59 |
+
"step": 140
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"epoch": 0.010785305021907651,
|
| 63 |
+
"grad_norm": 2.625,
|
| 64 |
+
"learning_rate": 0.0003,
|
| 65 |
+
"loss": 4.035322952270508,
|
| 66 |
+
"step": 160
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"epoch": 0.012133468149646108,
|
| 70 |
+
"grad_norm": 3.765625,
|
| 71 |
+
"learning_rate": 0.0003,
|
| 72 |
+
"loss": 3.6691635131835936,
|
| 73 |
+
"step": 180
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"epoch": 0.013481631277384564,
|
| 77 |
+
"grad_norm": 2.296875,
|
| 78 |
+
"learning_rate": 0.0003,
|
| 79 |
+
"loss": 3.315158462524414,
|
| 80 |
+
"step": 200
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"epoch": 0.013481631277384564,
|
| 84 |
+
"eval_loss": 3.140667200088501,
|
| 85 |
+
"eval_runtime": 8.3121,
|
| 86 |
+
"eval_samples_per_second": 1146.166,
|
| 87 |
+
"eval_steps_per_second": 17.926,
|
| 88 |
+
"step": 200
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"epoch": 0.01482979440512302,
|
| 92 |
+
"grad_norm": 2.453125,
|
| 93 |
+
"learning_rate": 0.0003,
|
| 94 |
+
"loss": 2.9744741439819338,
|
| 95 |
+
"step": 220
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"epoch": 0.016177957532861477,
|
| 99 |
+
"grad_norm": 2.359375,
|
| 100 |
+
"learning_rate": 0.0003,
|
| 101 |
+
"loss": 2.6262161254882814,
|
| 102 |
+
"step": 240
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"epoch": 0.01752612066059993,
|
| 106 |
+
"grad_norm": 2.234375,
|
| 107 |
+
"learning_rate": 0.0003,
|
| 108 |
+
"loss": 2.3146018981933594,
|
| 109 |
+
"step": 260
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"epoch": 0.01887428378833839,
|
| 113 |
+
"grad_norm": 2.015625,
|
| 114 |
+
"learning_rate": 0.0003,
|
| 115 |
+
"loss": 1.9927532196044921,
|
| 116 |
+
"step": 280
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"epoch": 0.020222446916076844,
|
| 120 |
+
"grad_norm": 1.609375,
|
| 121 |
+
"learning_rate": 0.0003,
|
| 122 |
+
"loss": 1.6939159393310548,
|
| 123 |
+
"step": 300
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"epoch": 0.021570610043815303,
|
| 127 |
+
"grad_norm": 1.734375,
|
| 128 |
+
"learning_rate": 0.0003,
|
| 129 |
+
"loss": 1.4503639221191407,
|
| 130 |
+
"step": 320
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"epoch": 0.022918773171553757,
|
| 134 |
+
"grad_norm": 1.828125,
|
| 135 |
+
"learning_rate": 0.0003,
|
| 136 |
+
"loss": 1.2639431953430176,
|
| 137 |
+
"step": 340
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"epoch": 0.024266936299292215,
|
| 141 |
+
"grad_norm": 1.984375,
|
| 142 |
+
"learning_rate": 0.0003,
|
| 143 |
+
"loss": 1.1161455154418944,
|
| 144 |
+
"step": 360
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"epoch": 0.02561509942703067,
|
| 148 |
+
"grad_norm": 1.546875,
|
| 149 |
+
"learning_rate": 0.0003,
|
| 150 |
+
"loss": 0.9919822692871094,
|
| 151 |
+
"step": 380
|
| 152 |
+
},
|
| 153 |
+
{
|
| 154 |
+
"epoch": 0.026963262554769128,
|
| 155 |
+
"grad_norm": 1.1484375,
|
| 156 |
+
"learning_rate": 0.0003,
|
| 157 |
+
"loss": 0.8975520133972168,
|
| 158 |
+
"step": 400
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"epoch": 0.026963262554769128,
|
| 162 |
+
"eval_loss": 0.8561499714851379,
|
| 163 |
+
"eval_runtime": 8.3662,
|
| 164 |
+
"eval_samples_per_second": 1138.75,
|
| 165 |
+
"eval_steps_per_second": 17.81,
|
| 166 |
+
"step": 400
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
"epoch": 0.028311425682507583,
|
| 170 |
+
"grad_norm": 0.67578125,
|
| 171 |
+
"learning_rate": 0.0003,
|
| 172 |
+
"loss": 0.7963034629821777,
|
| 173 |
+
"step": 420
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"epoch": 0.02965958881024604,
|
| 177 |
+
"grad_norm": 0.51171875,
|
| 178 |
+
"learning_rate": 0.0003,
|
| 179 |
+
"loss": 0.7076507568359375,
|
| 180 |
+
"step": 440
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"epoch": 0.031007751937984496,
|
| 184 |
+
"grad_norm": 0.439453125,
|
| 185 |
+
"learning_rate": 0.0003,
|
| 186 |
+
"loss": 0.6221071720123291,
|
| 187 |
+
"step": 460
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"epoch": 0.032355915065722954,
|
| 191 |
+
"grad_norm": 0.423828125,
|
| 192 |
+
"learning_rate": 0.0003,
|
| 193 |
+
"loss": 0.5685368537902832,
|
| 194 |
+
"step": 480
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"epoch": 0.03370407819346141,
|
| 198 |
+
"grad_norm": 0.3671875,
|
| 199 |
+
"learning_rate": 0.0003,
|
| 200 |
+
"loss": 0.5213922977447509,
|
| 201 |
+
"step": 500
|
| 202 |
+
}
|
| 203 |
+
],
|
| 204 |
+
"logging_steps": 20,
|
| 205 |
+
"max_steps": 2000,
|
| 206 |
+
"num_input_tokens_seen": 0,
|
| 207 |
+
"num_train_epochs": 1,
|
| 208 |
+
"save_steps": 500,
|
| 209 |
+
"stateful_callbacks": {
|
| 210 |
+
"TrainerControl": {
|
| 211 |
+
"args": {
|
| 212 |
+
"should_epoch_stop": false,
|
| 213 |
+
"should_evaluate": false,
|
| 214 |
+
"should_log": false,
|
| 215 |
+
"should_save": true,
|
| 216 |
+
"should_training_stop": false
|
| 217 |
+
},
|
| 218 |
+
"attributes": {}
|
| 219 |
+
}
|
| 220 |
+
},
|
| 221 |
+
"total_flos": 145194221568000.0,
|
| 222 |
+
"train_batch_size": 64,
|
| 223 |
+
"trial_name": null,
|
| 224 |
+
"trial_params": null
|
| 225 |
+
}
|
out/glu-gelu-9L_run/checkpoint-500/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a5bc9b69db12445b4a7919b29e76d261b3c2acbea92402190b4ca5d146c69daa
|
| 3 |
+
size 4920
|
out/glu-gelu-9L_run/config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"TinyLlamaForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_bias": false,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"bos_token_id": 1,
|
| 9 |
+
"dtype": "bfloat16",
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
+
"head_dim": 32,
|
| 12 |
+
"hidden_act": "silu",
|
| 13 |
+
"hidden_size": 128,
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 256,
|
| 16 |
+
"max_position_embeddings": 512,
|
| 17 |
+
"mlp_bias": false,
|
| 18 |
+
"mlp_type": "glu",
|
| 19 |
+
"model_type": "tiny_llama",
|
| 20 |
+
"num_attention_heads": 4,
|
| 21 |
+
"num_hidden_layers": 9,
|
| 22 |
+
"num_key_value_heads": 4,
|
| 23 |
+
"pad_token_id": 0,
|
| 24 |
+
"pretraining_tp": 1,
|
| 25 |
+
"rms_norm_eps": 1e-06,
|
| 26 |
+
"rope_parameters": {
|
| 27 |
+
"rope_theta": 10000.0,
|
| 28 |
+
"rope_type": "default"
|
| 29 |
+
},
|
| 30 |
+
"tie_word_embeddings": true,
|
| 31 |
+
"tokenizer_name": "w-ahmad/tiny-stories-tokenizer",
|
| 32 |
+
"transformers_version": "5.15.0.dev0",
|
| 33 |
+
"use_cache": false,
|
| 34 |
+
"vocab_size": 4096
|
| 35 |
+
}
|
out/glu-gelu-9L_run/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:efa7bcb247c2e6fbd4d32ab423b71b076c710576b4833e9258447d136870faaf
|
| 3 |
+
size 4011496
|
out/glu-gelu-9L_run/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out/glu-gelu-9L_run/tokenizer_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<|endoftext|>",
|
| 5 |
+
"eos_token": "<|endoftext|>",
|
| 6 |
+
"errors": "replace",
|
| 7 |
+
"is_local": false,
|
| 8 |
+
"local_files_only": false,
|
| 9 |
+
"model_max_length": 1024,
|
| 10 |
+
"pad_token": "<|endoftext|>",
|
| 11 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 12 |
+
"unk_token": "<|endoftext|>"
|
| 13 |
+
}
|
out/glu-gelu-9L_run/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a5bc9b69db12445b4a7919b29e76d261b3c2acbea92402190b4ca5d146c69daa
|
| 3 |
+
size 4920
|
out/glu-gelu-9L_run/training_log.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out/glu-linear-9L_run/checkpoint-1000/config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "linear",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"TinyLlamaForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_bias": false,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"bos_token_id": 1,
|
| 9 |
+
"dtype": "bfloat16",
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
+
"head_dim": 32,
|
| 12 |
+
"hidden_act": "silu",
|
| 13 |
+
"hidden_size": 128,
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 256,
|
| 16 |
+
"max_position_embeddings": 512,
|
| 17 |
+
"mlp_bias": false,
|
| 18 |
+
"mlp_type": "glu",
|
| 19 |
+
"model_type": "tiny_llama",
|
| 20 |
+
"num_attention_heads": 4,
|
| 21 |
+
"num_hidden_layers": 9,
|
| 22 |
+
"num_key_value_heads": 4,
|
| 23 |
+
"pad_token_id": 0,
|
| 24 |
+
"pretraining_tp": 1,
|
| 25 |
+
"rms_norm_eps": 1e-06,
|
| 26 |
+
"rope_parameters": {
|
| 27 |
+
"rope_theta": 10000.0,
|
| 28 |
+
"rope_type": "default"
|
| 29 |
+
},
|
| 30 |
+
"tie_word_embeddings": true,
|
| 31 |
+
"tokenizer_name": "w-ahmad/tiny-stories-tokenizer",
|
| 32 |
+
"transformers_version": "5.15.0.dev0",
|
| 33 |
+
"use_cache": false,
|
| 34 |
+
"vocab_size": 4096
|
| 35 |
+
}
|