Archive modified and untracked RCP SparseAtt working-tree files
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- epfl_final/SparseAtt/$script +9 -0
- epfl_final/SparseAtt/closure24_tau1_eval.py +60 -0
- epfl_final/SparseAtt/concat_tau1_fix.py +25 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s42.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s42_2gpu_latest_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s42_2gpu_restart_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s42_2gpu_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s42_5gpu_a100_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s43_2gpu.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s43_2gpu_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s44_5gpu.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s42.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s42_2gpu_h100_restart_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s42_2gpu_h100_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s42_5gpu_latest_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s42_5gpu_restart_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s43.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s43_2gpu_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s43_5gpu_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s44_2gpu_h100_latest_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s44_2gpu_h100_resume.json +8 -0
- epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s44_5gpu.json +8 -0
- epfl_final/SparseAtt/configs/REGIME_20260922/365m_dense_noqknorm_s42.json +51 -0
- epfl_final/SparseAtt/configs/REGIME_20260922/365m_dense_rope1e4_s42.json +51 -0
- epfl_final/SparseAtt/configs/REGIME_20260922/365m_dense_rope1e4_s42_1gpu.json +51 -0
- epfl_final/SparseAtt/configs/REGIME_20260922/365m_dense_rope1e4_s42_resume.json +64 -0
- epfl_final/SparseAtt/configs/REGIME_20260922/365m_mixed_noqknorm_s42.json +60 -0
- epfl_final/SparseAtt/configs/REGIME_20260922/365m_mixed_noqknorm_s42_resume.json +60 -0
- epfl_final/SparseAtt/configs/REGIME_20260922/365m_mixed_rope1e4_s42.json +60 -0
- epfl_final/SparseAtt/configs/REGIME_20260922/365m_mixed_rope1e4_s42_2gpu.json +60 -0
- epfl_final/SparseAtt/configs/alibi_20260921/1p2b_alibi_s42.json +62 -0
- epfl_final/SparseAtt/configs/alibi_20260921/1p2b_alibi_s42_bs12_resume17000.json +59 -0
- epfl_final/SparseAtt/configs/alibi_20260921/1p2b_alibi_s42_bs15.json +62 -0
- epfl_final/SparseAtt/configs/alibi_20260921/1p2b_alibi_s42_bs20.json +62 -0
- epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s42.json +70 -0
- epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s43.json +70 -0
- epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s44.json +70 -0
- epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s45.json +70 -0
- epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s46.json +70 -0
- epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s47.json +69 -0
- epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s47_restart_20260922.json +69 -0
- epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s47_resume_2xh100.json +69 -0
- epfl_final/SparseAtt/finalize_tau1_fix.py +95 -0
- epfl_final/SparseAtt/launch_1p2b_alibi_after_eval.sh +23 -0
- epfl_final/SparseAtt/launch_alibi_20260921.sh +33 -0
- epfl_final/SparseAtt/merge_closure24.py +28 -0
- epfl_final/SparseAtt/rebuild_closure24_from_log.py +26 -0
- epfl_final/SparseAtt/sparseatt/asentmax_attention.py +91 -0
- epfl_final/SparseAtt/sparseatt/attention.py +338 -0
- epfl_final/SparseAtt/sparseatt/config.py +90 -0
epfl_final/SparseAtt/$script
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
seed71_log=/mloscratch/homes/navasard/sparse/train_logs/p2_1p2b_mixed_seed71_4gpu_resume45250.log
|
| 4 |
+
seed72_log=/mloscratch/homes/navasard/sparse/train_logs/p2_1p2b_mixed_seed72_4gpu_resume31000_after_seed71.log
|
| 5 |
+
repo=/mloscratch/homes/navasard/sparse/SparseAtt
|
| 6 |
+
while ! grep -q "Training complete" "$seed71_log"; do sleep 60; done
|
| 7 |
+
if pgrep -f "torchrun.*p2_1p2b_mixed_seed72_4gpu_autoresume_current.json" >/dev/null; then exit 0; fi
|
| 8 |
+
cd "$repo"
|
| 9 |
+
nohup env USER=navasard LOGNAME=navasard HOME=/mloscratch/homes/navasard TORCHINDUCTOR_CACHE_DIR=/mloscratch/homes/navasard/.cache/torchinductor /mloscratch/homes/navasard/conda/bin/torchrun --standalone --nproc_per_node=4 train.py --config configs/p2_1p2b_mixed_seed72_4gpu_autoresume_current.json >> "$seed72_log" 2>&1 < /dev/null &
|
epfl_final/SparseAtt/closure24_tau1_eval.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv, math, os, sys
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
REPO = Path('/mloscratch/homes/navasard/sparse/SparseAtt')
|
| 6 |
+
BASE = Path('/mloscratch/homes/navasard/sparse')
|
| 7 |
+
DATA = BASE.parent / 'data'
|
| 8 |
+
sys.path.insert(0, str(REPO))
|
| 9 |
+
from eval.checkpoint import parse_dtype, resolve_device
|
| 10 |
+
from eval.sparse_eval import load_model_for_deploy
|
| 11 |
+
from analysis.r2_calibration_probe import apply_temperature
|
| 12 |
+
from sparseatt import load_tokenizer
|
| 13 |
+
from datasets import load_from_disk
|
| 14 |
+
|
| 15 |
+
L = 24576
|
| 16 |
+
CK = {
|
| 17 |
+
('dense',70): 'checkpoints/l8k1p2b_dense_seed70/run_20260823_043810/checkpoint-50462',
|
| 18 |
+
('mixed',70): 'checkpoints/l8k1p2b_mixed_seed70_repaired/run_20260909_054557/checkpoint-50462',
|
| 19 |
+
('dense',72): 'checkpoints/l8k1p2b_dense_seed72_repaired/run_20260906_repair_from9250/checkpoint-50462',
|
| 20 |
+
('mixed',72): 'checkpoints/l8k1p2b_mixed_seed72/run_20260827_071551/checkpoint-50462',
|
| 21 |
+
}
|
| 22 |
+
CORP = {'fineweb': DATA/'fineweb_val_seed42', 'pg19': DATA/'pg19_ood_windows', 'arxiv': DATA/'arxiv_ood_windows'}
|
| 23 |
+
OUT = REPO/'eval/results/RESOLUTION_20260921/tau1_fix/closure24_rows.tsv'
|
| 24 |
+
|
| 25 |
+
def stream(path):
|
| 26 |
+
ds = load_from_disk(str(path)); ds = ds['train'] if hasattr(ds,'keys') and 'train' in ds else ds
|
| 27 |
+
ids=[]
|
| 28 |
+
for x in ds: ids.extend(x['input_ids'])
|
| 29 |
+
return torch.tensor(ids)
|
| 30 |
+
|
| 31 |
+
@torch.no_grad()
|
| 32 |
+
def score(m, ids, dev, dt):
|
| 33 |
+
x=ids[None].to(dev)
|
| 34 |
+
with torch.autocast('cuda', dtype=dt): y=m(input_ids=x, attention_mask=None)['logits'][:,:-1]
|
| 35 |
+
t=x[:,1:]; total=0.0; n=0
|
| 36 |
+
for i in range(0,t.shape[1],512):
|
| 37 |
+
z=t[:,i:i+512]; q=y[:,i:i+512].float()
|
| 38 |
+
total += float(torch.nn.functional.cross_entropy(q.reshape(-1,q.shape[-1]), z.reshape(-1), reduction='sum')); n += z.numel()
|
| 39 |
+
return total/n, n
|
| 40 |
+
|
| 41 |
+
def main():
|
| 42 |
+
os.environ.setdefault('USER','navasard'); os.environ.setdefault('HOME','/mloscratch/homes/navasard')
|
| 43 |
+
dev=resolve_device(None); dt=parse_dtype('bf16'); tok=load_tokenizer('/mloscratch/homes/navasard/qwen3_06b_base')
|
| 44 |
+
streams={c:stream(p) for c,p in CORP.items()}
|
| 45 |
+
rows=[]
|
| 46 |
+
for (arm,seed), rel in CK.items():
|
| 47 |
+
print('LOAD',arm,seed,flush=True)
|
| 48 |
+
m=load_model_for_deploy(checkpoint_dir=str(BASE/rel), deploy_sparsity='dense', eval_len=L, block_size=128, pattern='random', force_sparse_layers='all', mask_pool_size=1, mask_seed=42, h2o_recent=128, device=dev, dtype=dt)
|
| 49 |
+
apply_temperature(m,1.0)
|
| 50 |
+
for c,ids in streams.items():
|
| 51 |
+
for j,o in enumerate((2*L,3*L)):
|
| 52 |
+
nll,n=score(m,ids[o:o+L],dev,dt)
|
| 53 |
+
rows.append(dict(arm=arm,seed=seed,length=L,split='heldout_existing',corpus=c,window_id=f'closure{j}',start_offset=o,tokens=n,tau=1.0,avg_nll=nll,perplexity=math.exp(nll)))
|
| 54 |
+
print(arm,seed,c,j,nll,flush=True)
|
| 55 |
+
del m; torch.cuda.empty_cache()
|
| 56 |
+
OUT.parent.mkdir(parents=True,exist_ok=True)
|
| 57 |
+
with OUT.open('w',newline='') as f:
|
| 58 |
+
w=csv.DictWriter(f,fieldnames=rows[0],delimiter='\t'); w.writeheader(); w.writerows(rows)
|
| 59 |
+
print('WROTE',OUT,len(rows),flush=True)
|
| 60 |
+
if __name__=='__main__': main()
|
epfl_final/SparseAtt/concat_tau1_fix.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
|
| 4 |
+
ROOT = Path('/mloscratch/homes/navasard/sparse/SparseAtt/eval/results/RESOLUTION_20260921/tau1_fix')
|
| 5 |
+
OUT = ROOT / 'SPARSEATT_RESOLUTION_TAU1_FIX_20260921_ALL.tsv'
|
| 6 |
+
|
| 7 |
+
def main():
|
| 8 |
+
files = sorted(ROOT.glob('*_heldout.tsv'))
|
| 9 |
+
if len(files) != 24:
|
| 10 |
+
raise SystemExit(f'expected 24 result TSVs, found {len(files)}')
|
| 11 |
+
with files[0].open(newline='') as f:
|
| 12 |
+
fields = list(csv.DictReader(f, delimiter='\t').fieldnames or [])
|
| 13 |
+
with OUT.open('w', newline='') as f:
|
| 14 |
+
w = csv.DictWriter(f, fieldnames=['source_file'] + fields, delimiter='\t')
|
| 15 |
+
w.writeheader()
|
| 16 |
+
total = 0
|
| 17 |
+
for p in files:
|
| 18 |
+
with p.open(newline='') as h:
|
| 19 |
+
for row in csv.DictReader(h, delimiter='\t'):
|
| 20 |
+
w.writerow({'source_file': p.name, **row})
|
| 21 |
+
total += 1
|
| 22 |
+
print(f'wrote {OUT} from {len(files)} files and {total} rows')
|
| 23 |
+
|
| 24 |
+
if __name__ == '__main__':
|
| 25 |
+
main()
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s42.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 42, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s42", "resume_from_checkpoint": null, "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 1, "gradient_accumulation_steps": 20, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 42, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m dense qkgainfp32 s42", "tags": ["final_20260924", "part_a", "dense", "qkgainfp32", "seed42"]},
|
| 7 |
+
"attention": {"type": "dense", "dense_mode": false}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s42_2gpu_latest_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 42, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s42", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s42/run_20260924_045342/checkpoint-26000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 2, "gradient_accumulation_steps": 5, "resume_micro_step_override": 130000, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 42, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m dense qkgainfp32 s42", "tags": ["final_20260924", "part_a", "dense", "qkgainfp32", "seed42", "latest_resume"]},
|
| 7 |
+
"attention": {"type": "dense", "dense_mode": false}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s42_2gpu_restart_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 42, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s42", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s42/run_20260924_045342/checkpoint-9000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 2, "gradient_accumulation_steps": 5, "resume_micro_step_override": 45000, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 42, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m dense qkgainfp32 s42", "tags": ["final_20260924", "part_a", "dense", "qkgainfp32", "seed42"]},
|
| 7 |
+
"attention": {"type": "dense", "dense_mode": false}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s42_2gpu_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 42, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s42", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s42/run_20260924_045342/checkpoint-9000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 2, "gradient_accumulation_steps": 5, "resume_micro_step_override": 45000, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 42, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m dense qkgainfp32 s42", "tags": ["final_20260924", "part_a", "dense", "qkgainfp32", "seed42"]},
|
| 7 |
+
"attention": {"type": "dense", "dense_mode": false}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s42_5gpu_a100_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 42, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s42", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s42/run_20260924_045342/checkpoint-26000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 1, "gradient_accumulation_steps": 4, "resume_micro_step_override": 104000, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 42, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m dense qkgainfp32 s42", "tags": ["final_20260924", "part_a", "dense", "qkgainfp32", "seed42", "a100_resume"]},
|
| 7 |
+
"attention": {"type": "dense", "dense_mode": false}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s43_2gpu.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 43, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s43", "resume_from_checkpoint": null, "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 2, "gradient_accumulation_steps": 5, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 43, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m dense qkgainfp32 s43", "tags": ["final_20260924", "part_a", "dense", "qkgainfp32", "seed43"]},
|
| 7 |
+
"attention": {"type": "dense", "dense_mode": false}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s43_2gpu_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 43, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s43", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s43/run_20260924_152136/checkpoint-4000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 2, "gradient_accumulation_steps": 5, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 43, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m dense qkgainfp32 s43", "tags": ["final_20260924", "part_a", "dense", "qkgainfp32", "seed43"]},
|
| 7 |
+
"attention": {"type": "dense", "dense_mode": false}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_dense_qkgainfp32_s44_5gpu.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 44, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_dense_qkgainfp32_s44", "resume_from_checkpoint": null, "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 1, "gradient_accumulation_steps": 4, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 44, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m dense qkgainfp32 s44", "tags": ["final_20260924", "part_a", "dense", "qkgainfp32", "seed44"]},
|
| 7 |
+
"attention": {"type": "dense", "dense_mode": false}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s42.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 42, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s42", "resume_from_checkpoint": null, "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 1, "gradient_accumulation_steps": 20, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 42, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m mixed qkgainfp32 s42", "tags": ["final_20260924", "part_a", "mixed", "qkgainfp32", "seed42"]},
|
| 7 |
+
"attention": {"type": "sparse_stochastic", "dense_mode": false, "sparse_block_size": 128, "sparse_num_random_blocks": 63, "sparse_mask_pool_size": 10000, "sparse_mixed_nrb_set": [63, 47, 31, 21, 11], "sparse_mask_seed": 0, "sparse_mask_cache_dir": "../mask_cache_8k_mixed"}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s42_2gpu_h100_restart_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 42, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s42", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s42/run_20260924_045342/checkpoint-9000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 2, "gradient_accumulation_steps": 5, "resume_micro_step_override": 45000, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 42, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m mixed qkgainfp32 s42", "tags": ["final_20260924", "part_a", "mixed", "qkgainfp32", "seed42", "h100_restart_resume"]},
|
| 7 |
+
"attention": {"type": "sparse_stochastic", "dense_mode": false, "sparse_block_size": 128, "sparse_num_random_blocks": 63, "sparse_mask_pool_size": 10000, "sparse_mixed_nrb_set": [63, 47, 31, 21, 11], "sparse_mask_seed": 0, "sparse_mask_cache_dir": "../mask_cache_8k_mixed"}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s42_2gpu_h100_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 42, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s42", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s42/run_20260924_045342/checkpoint-26000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 2, "gradient_accumulation_steps": 5, "resume_micro_step_override": 130000, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 42, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m mixed qkgainfp32 s42", "tags": ["final_20260924", "part_a", "mixed", "qkgainfp32", "seed42", "h100_resume"]},
|
| 7 |
+
"attention": {"type": "sparse_stochastic", "dense_mode": false, "sparse_block_size": 128, "sparse_num_random_blocks": 63, "sparse_mask_pool_size": 10000, "sparse_mixed_nrb_set": [63, 47, 31, 21, 11], "sparse_mask_seed": 0, "sparse_mask_cache_dir": "../mask_cache_8k_mixed"}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s42_5gpu_latest_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 42, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s42", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s42/run_20260924_045342/checkpoint-32000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 1, "gradient_accumulation_steps": 4, "resume_micro_step_override": 128000, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 42, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m mixed qkgainfp32 s42", "tags": ["final_20260924", "part_a", "mixed", "qkgainfp32", "seed42", "latest_resume"]},
|
| 7 |
+
"attention": {"type": "sparse_stochastic", "dense_mode": false, "sparse_block_size": 128, "sparse_num_random_blocks": 63, "sparse_mask_pool_size": 10000, "sparse_mixed_nrb_set": [63, 47, 31, 21, 11], "sparse_mask_seed": 0, "sparse_mask_cache_dir": "../mask_cache_8k_mixed"}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s42_5gpu_restart_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 42, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s42", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s42/run_20260924_045342/checkpoint-9000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 1, "gradient_accumulation_steps": 4, "resume_micro_step_override": 36000, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 42, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m mixed qkgainfp32 s42", "tags": ["final_20260924", "part_a", "mixed", "qkgainfp32", "seed42", "a100_restart_resume"]},
|
| 7 |
+
"attention": {"type": "sparse_stochastic", "dense_mode": false, "sparse_block_size": 128, "sparse_num_random_blocks": 63, "sparse_mask_pool_size": 10000, "sparse_mixed_nrb_set": [63, 47, 31, 21, 11], "sparse_mask_seed": 0, "sparse_mask_cache_dir": "../mask_cache_8k_mixed"}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s43.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 43, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s43", "resume_from_checkpoint": null, "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 1, "gradient_accumulation_steps": 20, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 43, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m mixed qkgainfp32 s43", "tags": ["final_20260924", "part_a", "mixed", "qkgainfp32", "seed43"]},
|
| 7 |
+
"attention": {"type": "sparse_stochastic", "dense_mode": false, "sparse_block_size": 128, "sparse_num_random_blocks": 63, "sparse_mask_pool_size": 10000, "sparse_mixed_nrb_set": [63, 47, 31, 21, 11], "sparse_mask_seed": 0, "sparse_mask_cache_dir": "../mask_cache_8k_mixed"}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s43_2gpu_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 43, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s43", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s43/run_20260924_050049/checkpoint-5000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 1, "gradient_accumulation_steps": 10, "resume_micro_step_override": 50000, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 43, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m mixed qkgainfp32 s43", "tags": ["final_20260924", "part_a", "mixed", "qkgainfp32", "seed43"]},
|
| 7 |
+
"attention": {"type": "sparse_stochastic", "dense_mode": false, "sparse_block_size": 128, "sparse_num_random_blocks": 63, "sparse_mask_pool_size": 10000, "sparse_mixed_nrb_set": [63, 47, 31, 21, 11], "sparse_mask_seed": 0, "sparse_mask_cache_dir": "../mask_cache_8k_mixed"}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s43_5gpu_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 43, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s43", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s43/run_20260924_050049/checkpoint-5000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 1, "gradient_accumulation_steps": 4, "resume_micro_step_override": 20000, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 43, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m mixed qkgainfp32 s43", "tags": ["final_20260924", "part_a", "mixed", "qkgainfp32", "seed43"]},
|
| 7 |
+
"attention": {"type": "sparse_stochastic", "dense_mode": false, "sparse_block_size": 128, "sparse_num_random_blocks": 63, "sparse_mask_pool_size": 10000, "sparse_mixed_nrb_set": [63, 47, 31, 21, 11], "sparse_mask_seed": 0, "sparse_mask_cache_dir": "../mask_cache_8k_mixed"}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s44_2gpu_h100_latest_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 44, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s44", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s44/run_20260924_144318/checkpoint-22000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 2, "gradient_accumulation_steps": 5, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 44, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m mixed qkgainfp32 s44", "tags": ["final_20260924", "part_a", "mixed", "qkgainfp32", "seed44", "latest_resume"]},
|
| 7 |
+
"attention": {"type": "sparse_stochastic", "dense_mode": false, "sparse_block_size": 128, "sparse_num_random_blocks": 63, "sparse_mask_pool_size": 10000, "sparse_mixed_nrb_set": [63, 47, 31, 21, 11], "sparse_mask_seed": 0, "sparse_mask_cache_dir": "../mask_cache_8k_mixed"}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s44_2gpu_h100_resume.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 44, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s44", "resume_from_checkpoint": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s44/run_20260924_144318/checkpoint-21000", "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 2, "gradient_accumulation_steps": 5, "resume_micro_step_override": 105000, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 44, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m mixed qkgainfp32 s44", "tags": ["final_20260924", "part_a", "mixed", "qkgainfp32", "seed44", "h100_resume"]},
|
| 7 |
+
"attention": {"type": "sparse_stochastic", "dense_mode": false, "sparse_block_size": 128, "sparse_num_random_blocks": 63, "sparse_mask_pool_size": 10000, "sparse_mixed_nrb_set": [63, 47, 31, 21, 11], "sparse_mask_seed": 0, "sparse_mask_cache_dir": "../mask_cache_8k_mixed"}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/FINAL_20260924/365m_mixed_qkgainfp32_s44_5gpu.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {"path": "../../qwen3_06b_base", "dtype": "bfloat16", "init_from_scratch": true, "hidden_size": 768, "intermediate_size": 3072, "num_hidden_layers": 28, "num_attention_heads": 6, "num_key_value_heads": 2, "rope_theta": 1000000.0, "qk_norm": "on", "qk_gain_fp32": true, "positional": "rope"},
|
| 3 |
+
"data": {"train_path": "../../data/fineweb_large/tokenized", "val_path": null, "seed": 44, "max_seq_length": 8192, "num_workers": 8},
|
| 4 |
+
"training": {"output_dir": "models/FINAL_20260924/part_a/365m_mixed_qkgainfp32_s44", "resume_from_checkpoint": null, "force_new_run": false, "num_epochs": 1, "max_steps": 44000, "per_device_batch_size": 1, "gradient_accumulation_steps": 4, "learning_rate": 0.0005, "weight_decay": 0.01, "warmup_steps": 750, "lr_scheduler": "cosine", "max_grad_norm": 1.0, "save_steps": 1000, "eval_steps": 250, "eval_batches": 50, "logging_steps": 100, "seed": 44, "verbose": false, "checkpoint_activations": false},
|
| 5 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 6 |
+
"wandb": {"enabled": false, "project": "stochastic_sparsity", "name": "FINAL partA 365m mixed qkgainfp32 s44", "tags": ["final_20260924", "part_a", "mixed", "qkgainfp32", "seed44"]},
|
| 7 |
+
"attention": {"type": "sparse_stochastic", "dense_mode": false, "sparse_block_size": 128, "sparse_num_random_blocks": 63, "sparse_mask_pool_size": 10000, "sparse_mixed_nrb_set": [63, 47, 31, 21, 11], "sparse_mask_seed": 0, "sparse_mask_cache_dir": "../mask_cache_8k_mixed"}
|
| 8 |
+
}
|
epfl_final/SparseAtt/configs/REGIME_20260922/365m_dense_noqknorm_s42.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "../../qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"rope_theta": 1000000.0,
|
| 12 |
+
"qk_norm": "off",
|
| 13 |
+
"positional": "rope"
|
| 14 |
+
},
|
| 15 |
+
"data": {
|
| 16 |
+
"train_path": "../../data/fineweb_large/tokenized",
|
| 17 |
+
"val_path": null,
|
| 18 |
+
"seed": 0,
|
| 19 |
+
"max_seq_length": 8192,
|
| 20 |
+
"num_workers": 8
|
| 21 |
+
},
|
| 22 |
+
"training": {
|
| 23 |
+
"output_dir": "models/REGIME_20260922/365m_dense_noqknorm_s42",
|
| 24 |
+
"resume_from_checkpoint": null,
|
| 25 |
+
"force_new_run": false,
|
| 26 |
+
"num_epochs": 1,
|
| 27 |
+
"max_steps": 44000,
|
| 28 |
+
"per_device_batch_size": 1,
|
| 29 |
+
"gradient_accumulation_steps": 4,
|
| 30 |
+
"learning_rate": 0.0005,
|
| 31 |
+
"weight_decay": 0.01,
|
| 32 |
+
"warmup_steps": 750,
|
| 33 |
+
"lr_scheduler": "cosine",
|
| 34 |
+
"max_grad_norm": 1.0,
|
| 35 |
+
"save_steps": 1000,
|
| 36 |
+
"eval_steps": 250,
|
| 37 |
+
"eval_batches": 50,
|
| 38 |
+
"logging_steps": 100,
|
| 39 |
+
"seed": 42,
|
| 40 |
+
"verbose": true,
|
| 41 |
+
"checkpoint_activations": false
|
| 42 |
+
},
|
| 43 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "REGIME 365m dense noqknorm s42",
|
| 48 |
+
"tags": ["regime_20260922", "365m", "dense", "noqknorm", "seed42"]
|
| 49 |
+
},
|
| 50 |
+
"attention": {"type": "dense", "dense_mode": false}
|
| 51 |
+
}
|
epfl_final/SparseAtt/configs/REGIME_20260922/365m_dense_rope1e4_s42.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "../../qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"rope_theta": 10000.0,
|
| 12 |
+
"qk_norm": "on",
|
| 13 |
+
"positional": "rope"
|
| 14 |
+
},
|
| 15 |
+
"data": {
|
| 16 |
+
"train_path": "../../data/fineweb_large/tokenized",
|
| 17 |
+
"val_path": null,
|
| 18 |
+
"seed": 0,
|
| 19 |
+
"max_seq_length": 8192,
|
| 20 |
+
"num_workers": 8
|
| 21 |
+
},
|
| 22 |
+
"training": {
|
| 23 |
+
"output_dir": "models/REGIME_20260922/365m_dense_rope1e4_s42",
|
| 24 |
+
"resume_from_checkpoint": null,
|
| 25 |
+
"force_new_run": false,
|
| 26 |
+
"num_epochs": 1,
|
| 27 |
+
"max_steps": 44000,
|
| 28 |
+
"per_device_batch_size": 1,
|
| 29 |
+
"gradient_accumulation_steps": 4,
|
| 30 |
+
"learning_rate": 0.0005,
|
| 31 |
+
"weight_decay": 0.01,
|
| 32 |
+
"warmup_steps": 750,
|
| 33 |
+
"lr_scheduler": "cosine",
|
| 34 |
+
"max_grad_norm": 1.0,
|
| 35 |
+
"save_steps": 1000,
|
| 36 |
+
"eval_steps": 250,
|
| 37 |
+
"eval_batches": 50,
|
| 38 |
+
"logging_steps": 100,
|
| 39 |
+
"seed": 42,
|
| 40 |
+
"verbose": true,
|
| 41 |
+
"checkpoint_activations": false
|
| 42 |
+
},
|
| 43 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "REGIME 365m dense rope1e4 s42",
|
| 48 |
+
"tags": ["regime_20260922", "365m", "dense", "rope1e4", "seed42"]
|
| 49 |
+
},
|
| 50 |
+
"attention": {"type": "dense", "dense_mode": false}
|
| 51 |
+
}
|
epfl_final/SparseAtt/configs/REGIME_20260922/365m_dense_rope1e4_s42_1gpu.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "../../qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"rope_theta": 10000.0,
|
| 12 |
+
"qk_norm": "on",
|
| 13 |
+
"positional": "rope"
|
| 14 |
+
},
|
| 15 |
+
"data": {
|
| 16 |
+
"train_path": "../../data/fineweb_large/tokenized",
|
| 17 |
+
"val_path": null,
|
| 18 |
+
"seed": 0,
|
| 19 |
+
"max_seq_length": 8192,
|
| 20 |
+
"num_workers": 8
|
| 21 |
+
},
|
| 22 |
+
"training": {
|
| 23 |
+
"output_dir": "models/REGIME_20260922/365m_dense_rope1e4_s42",
|
| 24 |
+
"resume_from_checkpoint": null,
|
| 25 |
+
"force_new_run": false,
|
| 26 |
+
"num_epochs": 1,
|
| 27 |
+
"max_steps": 44000,
|
| 28 |
+
"per_device_batch_size": 1,
|
| 29 |
+
"gradient_accumulation_steps": 20,
|
| 30 |
+
"learning_rate": 0.0005,
|
| 31 |
+
"weight_decay": 0.01,
|
| 32 |
+
"warmup_steps": 750,
|
| 33 |
+
"lr_scheduler": "cosine",
|
| 34 |
+
"max_grad_norm": 1.0,
|
| 35 |
+
"save_steps": 1000,
|
| 36 |
+
"eval_steps": 250,
|
| 37 |
+
"eval_batches": 50,
|
| 38 |
+
"logging_steps": 100,
|
| 39 |
+
"seed": 42,
|
| 40 |
+
"verbose": true,
|
| 41 |
+
"checkpoint_activations": false
|
| 42 |
+
},
|
| 43 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "REGIME 365m dense rope1e4 s42 1gpu",
|
| 48 |
+
"tags": ["regime_20260922", "365m", "dense", "rope1e4", "seed42"]
|
| 49 |
+
},
|
| 50 |
+
"attention": {"type": "dense", "dense_mode": false}
|
| 51 |
+
}
|
epfl_final/SparseAtt/configs/REGIME_20260922/365m_dense_rope1e4_s42_resume.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "../../qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"rope_theta": 10000.0,
|
| 12 |
+
"qk_norm": "on",
|
| 13 |
+
"positional": "rope"
|
| 14 |
+
},
|
| 15 |
+
"data": {
|
| 16 |
+
"train_path": "../../data/fineweb_large/tokenized",
|
| 17 |
+
"val_path": null,
|
| 18 |
+
"seed": 0,
|
| 19 |
+
"max_seq_length": 8192,
|
| 20 |
+
"num_workers": 8
|
| 21 |
+
},
|
| 22 |
+
"training": {
|
| 23 |
+
"output_dir": "models/REGIME_20260922/365m_dense_rope1e4_s42",
|
| 24 |
+
"resume_from_checkpoint": "models/REGIME_20260922/365m_dense_rope1e4_s42/run_20260922_225417/checkpoint-29000",
|
| 25 |
+
"force_new_run": false,
|
| 26 |
+
"num_epochs": 1,
|
| 27 |
+
"max_steps": 44000,
|
| 28 |
+
"per_device_batch_size": 1,
|
| 29 |
+
"gradient_accumulation_steps": 10,
|
| 30 |
+
"learning_rate": 0.0005,
|
| 31 |
+
"weight_decay": 0.01,
|
| 32 |
+
"warmup_steps": 750,
|
| 33 |
+
"lr_scheduler": "cosine",
|
| 34 |
+
"max_grad_norm": 1.0,
|
| 35 |
+
"save_steps": 1000,
|
| 36 |
+
"eval_steps": 250,
|
| 37 |
+
"eval_batches": 50,
|
| 38 |
+
"logging_steps": 100,
|
| 39 |
+
"seed": 42,
|
| 40 |
+
"verbose": true,
|
| 41 |
+
"checkpoint_activations": false,
|
| 42 |
+
"resume_micro_step_override": 290000
|
| 43 |
+
},
|
| 44 |
+
"distributed": {
|
| 45 |
+
"strategy": "ddp",
|
| 46 |
+
"mixed_precision": "bf16"
|
| 47 |
+
},
|
| 48 |
+
"wandb": {
|
| 49 |
+
"enabled": true,
|
| 50 |
+
"project": "stochastic_sparsity",
|
| 51 |
+
"name": "REGIME 365m dense rope1e4 s42",
|
| 52 |
+
"tags": [
|
| 53 |
+
"regime_20260922",
|
| 54 |
+
"365m",
|
| 55 |
+
"dense",
|
| 56 |
+
"rope1e4",
|
| 57 |
+
"seed42"
|
| 58 |
+
]
|
| 59 |
+
},
|
| 60 |
+
"attention": {
|
| 61 |
+
"type": "dense",
|
| 62 |
+
"dense_mode": false
|
| 63 |
+
}
|
| 64 |
+
}
|
epfl_final/SparseAtt/configs/REGIME_20260922/365m_mixed_noqknorm_s42.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "../../qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"rope_theta": 1000000.0,
|
| 12 |
+
"qk_norm": "off",
|
| 13 |
+
"positional": "rope"
|
| 14 |
+
},
|
| 15 |
+
"data": {
|
| 16 |
+
"train_path": "../../data/fineweb_large/tokenized",
|
| 17 |
+
"val_path": null,
|
| 18 |
+
"seed": 0,
|
| 19 |
+
"max_seq_length": 8192,
|
| 20 |
+
"num_workers": 8
|
| 21 |
+
},
|
| 22 |
+
"training": {
|
| 23 |
+
"output_dir": "models/REGIME_20260922/365m_mixed_noqknorm_s42",
|
| 24 |
+
"resume_from_checkpoint": null,
|
| 25 |
+
"force_new_run": false,
|
| 26 |
+
"num_epochs": 1,
|
| 27 |
+
"max_steps": 44000,
|
| 28 |
+
"per_device_batch_size": 1,
|
| 29 |
+
"gradient_accumulation_steps": 4,
|
| 30 |
+
"learning_rate": 0.0005,
|
| 31 |
+
"weight_decay": 0.01,
|
| 32 |
+
"warmup_steps": 750,
|
| 33 |
+
"lr_scheduler": "cosine",
|
| 34 |
+
"max_grad_norm": 1.0,
|
| 35 |
+
"save_steps": 1000,
|
| 36 |
+
"eval_steps": 250,
|
| 37 |
+
"eval_batches": 50,
|
| 38 |
+
"logging_steps": 100,
|
| 39 |
+
"seed": 42,
|
| 40 |
+
"verbose": true,
|
| 41 |
+
"checkpoint_activations": false
|
| 42 |
+
},
|
| 43 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "REGIME 365m mixed noqknorm s42",
|
| 48 |
+
"tags": ["regime_20260922", "365m", "mixed", "noqknorm", "seed42"]
|
| 49 |
+
},
|
| 50 |
+
"attention": {
|
| 51 |
+
"type": "sparse_stochastic",
|
| 52 |
+
"dense_mode": false,
|
| 53 |
+
"sparse_block_size": 128,
|
| 54 |
+
"sparse_num_random_blocks": 63,
|
| 55 |
+
"sparse_mask_pool_size": 10000,
|
| 56 |
+
"sparse_mixed_nrb_set": [63, 47, 31, 21, 11],
|
| 57 |
+
"sparse_mask_seed": 0,
|
| 58 |
+
"sparse_mask_cache_dir": "../mask_cache_8k_mixed"
|
| 59 |
+
}
|
| 60 |
+
}
|
epfl_final/SparseAtt/configs/REGIME_20260922/365m_mixed_noqknorm_s42_resume.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "../../qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"rope_theta": 1000000.0,
|
| 12 |
+
"qk_norm": "off",
|
| 13 |
+
"positional": "rope"
|
| 14 |
+
},
|
| 15 |
+
"data": {
|
| 16 |
+
"train_path": "../../data/fineweb_large/tokenized",
|
| 17 |
+
"val_path": null,
|
| 18 |
+
"seed": 0,
|
| 19 |
+
"max_seq_length": 8192,
|
| 20 |
+
"num_workers": 8
|
| 21 |
+
},
|
| 22 |
+
"training": {
|
| 23 |
+
"output_dir": "models/REGIME_20260922/365m_mixed_noqknorm_s42",
|
| 24 |
+
"resume_from_checkpoint": "models/REGIME_20260922/365m_mixed_noqknorm_s42/run_20260922_225813/checkpoint-40000",
|
| 25 |
+
"force_new_run": false,
|
| 26 |
+
"num_epochs": 1,
|
| 27 |
+
"max_steps": 44000,
|
| 28 |
+
"per_device_batch_size": 1,
|
| 29 |
+
"gradient_accumulation_steps": 4,
|
| 30 |
+
"learning_rate": 0.0005,
|
| 31 |
+
"weight_decay": 0.01,
|
| 32 |
+
"warmup_steps": 750,
|
| 33 |
+
"lr_scheduler": "cosine",
|
| 34 |
+
"max_grad_norm": 1.0,
|
| 35 |
+
"save_steps": 1000,
|
| 36 |
+
"eval_steps": 250,
|
| 37 |
+
"eval_batches": 50,
|
| 38 |
+
"logging_steps": 100,
|
| 39 |
+
"seed": 42,
|
| 40 |
+
"verbose": true,
|
| 41 |
+
"checkpoint_activations": false
|
| 42 |
+
},
|
| 43 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "REGIME 365m mixed noqknorm s42",
|
| 48 |
+
"tags": ["regime_20260922", "365m", "mixed", "noqknorm", "seed42"]
|
| 49 |
+
},
|
| 50 |
+
"attention": {
|
| 51 |
+
"type": "sparse_stochastic",
|
| 52 |
+
"dense_mode": false,
|
| 53 |
+
"sparse_block_size": 128,
|
| 54 |
+
"sparse_num_random_blocks": 63,
|
| 55 |
+
"sparse_mask_pool_size": 10000,
|
| 56 |
+
"sparse_mixed_nrb_set": [63, 47, 31, 21, 11],
|
| 57 |
+
"sparse_mask_seed": 0,
|
| 58 |
+
"sparse_mask_cache_dir": "../mask_cache_8k_mixed"
|
| 59 |
+
}
|
| 60 |
+
}
|
epfl_final/SparseAtt/configs/REGIME_20260922/365m_mixed_rope1e4_s42.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "../../qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"rope_theta": 10000.0,
|
| 12 |
+
"qk_norm": "on",
|
| 13 |
+
"positional": "rope"
|
| 14 |
+
},
|
| 15 |
+
"data": {
|
| 16 |
+
"train_path": "../../data/fineweb_large/tokenized",
|
| 17 |
+
"val_path": null,
|
| 18 |
+
"seed": 0,
|
| 19 |
+
"max_seq_length": 8192,
|
| 20 |
+
"num_workers": 8
|
| 21 |
+
},
|
| 22 |
+
"training": {
|
| 23 |
+
"output_dir": "models/REGIME_20260922/365m_mixed_rope1e4_s42",
|
| 24 |
+
"resume_from_checkpoint": null,
|
| 25 |
+
"force_new_run": false,
|
| 26 |
+
"num_epochs": 1,
|
| 27 |
+
"max_steps": 44000,
|
| 28 |
+
"per_device_batch_size": 1,
|
| 29 |
+
"gradient_accumulation_steps": 4,
|
| 30 |
+
"learning_rate": 0.0005,
|
| 31 |
+
"weight_decay": 0.01,
|
| 32 |
+
"warmup_steps": 750,
|
| 33 |
+
"lr_scheduler": "cosine",
|
| 34 |
+
"max_grad_norm": 1.0,
|
| 35 |
+
"save_steps": 1000,
|
| 36 |
+
"eval_steps": 250,
|
| 37 |
+
"eval_batches": 50,
|
| 38 |
+
"logging_steps": 100,
|
| 39 |
+
"seed": 42,
|
| 40 |
+
"verbose": true,
|
| 41 |
+
"checkpoint_activations": false
|
| 42 |
+
},
|
| 43 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "REGIME 365m mixed rope1e4 s42",
|
| 48 |
+
"tags": ["regime_20260922", "365m", "mixed", "rope1e4", "seed42"]
|
| 49 |
+
},
|
| 50 |
+
"attention": {
|
| 51 |
+
"type": "sparse_stochastic",
|
| 52 |
+
"dense_mode": false,
|
| 53 |
+
"sparse_block_size": 128,
|
| 54 |
+
"sparse_num_random_blocks": 63,
|
| 55 |
+
"sparse_mask_pool_size": 10000,
|
| 56 |
+
"sparse_mixed_nrb_set": [63, 47, 31, 21, 11],
|
| 57 |
+
"sparse_mask_seed": 0,
|
| 58 |
+
"sparse_mask_cache_dir": "../mask_cache_8k_mixed"
|
| 59 |
+
}
|
| 60 |
+
}
|
epfl_final/SparseAtt/configs/REGIME_20260922/365m_mixed_rope1e4_s42_2gpu.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "../../qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"rope_theta": 10000.0,
|
| 12 |
+
"qk_norm": "on",
|
| 13 |
+
"positional": "rope"
|
| 14 |
+
},
|
| 15 |
+
"data": {
|
| 16 |
+
"train_path": "../../data/fineweb_large/tokenized",
|
| 17 |
+
"val_path": null,
|
| 18 |
+
"seed": 0,
|
| 19 |
+
"max_seq_length": 8192,
|
| 20 |
+
"num_workers": 8
|
| 21 |
+
},
|
| 22 |
+
"training": {
|
| 23 |
+
"output_dir": "models/REGIME_20260922/365m_mixed_rope1e4_s42",
|
| 24 |
+
"resume_from_checkpoint": null,
|
| 25 |
+
"force_new_run": false,
|
| 26 |
+
"num_epochs": 1,
|
| 27 |
+
"max_steps": 44000,
|
| 28 |
+
"per_device_batch_size": 1,
|
| 29 |
+
"gradient_accumulation_steps": 10,
|
| 30 |
+
"learning_rate": 0.0005,
|
| 31 |
+
"weight_decay": 0.01,
|
| 32 |
+
"warmup_steps": 750,
|
| 33 |
+
"lr_scheduler": "cosine",
|
| 34 |
+
"max_grad_norm": 1.0,
|
| 35 |
+
"save_steps": 1000,
|
| 36 |
+
"eval_steps": 250,
|
| 37 |
+
"eval_batches": 50,
|
| 38 |
+
"logging_steps": 100,
|
| 39 |
+
"seed": 42,
|
| 40 |
+
"verbose": true,
|
| 41 |
+
"checkpoint_activations": false
|
| 42 |
+
},
|
| 43 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "REGIME 365m mixed rope1e4 s42 2gpu",
|
| 48 |
+
"tags": ["regime_20260922", "365m", "mixed", "rope1e4", "seed42"]
|
| 49 |
+
},
|
| 50 |
+
"attention": {
|
| 51 |
+
"type": "sparse_stochastic",
|
| 52 |
+
"dense_mode": false,
|
| 53 |
+
"sparse_block_size": 128,
|
| 54 |
+
"sparse_num_random_blocks": 63,
|
| 55 |
+
"sparse_mask_pool_size": 10000,
|
| 56 |
+
"sparse_mixed_nrb_set": [63, 47, 31, 21, 11],
|
| 57 |
+
"sparse_mask_seed": 0,
|
| 58 |
+
"sparse_mask_cache_dir": "../mask_cache_8k_mixed"
|
| 59 |
+
}
|
| 60 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/1p2b_alibi_s42.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "/mloscratch/homes/navasard/qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 1536,
|
| 7 |
+
"intermediate_size": 6144,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 12,
|
| 10 |
+
"num_key_value_heads": 4,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "/mloscratch/homes/navasard/data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/1p2b_alibi_s42",
|
| 21 |
+
"resume_from_checkpoint": null,
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"num_epochs": 1,
|
| 24 |
+
"max_steps": 50462,
|
| 25 |
+
"per_device_batch_size": 1,
|
| 26 |
+
"gradient_accumulation_steps": 10,
|
| 27 |
+
"learning_rate": 0.0005,
|
| 28 |
+
"weight_decay": 0.01,
|
| 29 |
+
"warmup_steps": 750,
|
| 30 |
+
"lr_scheduler": "cosine",
|
| 31 |
+
"max_grad_norm": 1.0,
|
| 32 |
+
"save_steps": 1000,
|
| 33 |
+
"eval_steps": 1000,
|
| 34 |
+
"eval_batches": 50,
|
| 35 |
+
"logging_steps": 100,
|
| 36 |
+
"seed": 42,
|
| 37 |
+
"verbose": true,
|
| 38 |
+
"checkpoint_activations": false
|
| 39 |
+
},
|
| 40 |
+
"distributed": {
|
| 41 |
+
"strategy": "ddp",
|
| 42 |
+
"mixed_precision": "bf16"
|
| 43 |
+
},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "1.2b alibi 8k s42",
|
| 48 |
+
"tags": ["qwen3", "1.2b", "8k", "alibi", "dense", "seed42"]
|
| 49 |
+
},
|
| 50 |
+
"attention": {
|
| 51 |
+
"type": "dense",
|
| 52 |
+
"dense_mode": false,
|
| 53 |
+
"sparse_block_size": 128,
|
| 54 |
+
"sparse_num_random_blocks": 31,
|
| 55 |
+
"sparse_mask_pool_size": 1,
|
| 56 |
+
"sparse_val_dense_compare": false,
|
| 57 |
+
"dense_step_intervals": null,
|
| 58 |
+
"sparse_layer_indices": null,
|
| 59 |
+
"sparse_mask_cache_dir": null,
|
| 60 |
+
"sparse_mask_seed": 42
|
| 61 |
+
}
|
| 62 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/1p2b_alibi_s42_bs12_resume17000.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "../../qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 1536,
|
| 7 |
+
"intermediate_size": 6144,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 12,
|
| 10 |
+
"num_key_value_heads": 4,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "../../data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "../models/ALIBI_20260921/1p2b_alibi_s42",
|
| 21 |
+
"resume_from_checkpoint": "../models/ALIBI_20260921/1p2b_alibi_s42/run_20260922_004519/checkpoint-17000",
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"num_epochs": 1,
|
| 24 |
+
"max_steps": 50462,
|
| 25 |
+
"per_device_batch_size": 1,
|
| 26 |
+
"gradient_accumulation_steps": 12,
|
| 27 |
+
"learning_rate": 0.0005,
|
| 28 |
+
"weight_decay": 0.01,
|
| 29 |
+
"warmup_steps": 750,
|
| 30 |
+
"lr_scheduler": "cosine",
|
| 31 |
+
"max_grad_norm": 1.0,
|
| 32 |
+
"save_steps": 1000,
|
| 33 |
+
"eval_steps": 1000,
|
| 34 |
+
"eval_batches": 50,
|
| 35 |
+
"logging_steps": 100,
|
| 36 |
+
"seed": 42,
|
| 37 |
+
"verbose": true,
|
| 38 |
+
"checkpoint_activations": false
|
| 39 |
+
},
|
| 40 |
+
"distributed": {"strategy": "ddp", "mixed_precision": "bf16"},
|
| 41 |
+
"wandb": {
|
| 42 |
+
"enabled": true,
|
| 43 |
+
"project": "stochastic_sparsity",
|
| 44 |
+
"name": "1.2b alibi 8k s42 resume17000 5gpu",
|
| 45 |
+
"tags": ["qwen3", "1.2b", "8k", "alibi", "dense", "seed42", "resume17000"]
|
| 46 |
+
},
|
| 47 |
+
"attention": {
|
| 48 |
+
"type": "dense",
|
| 49 |
+
"dense_mode": false,
|
| 50 |
+
"sparse_block_size": 128,
|
| 51 |
+
"sparse_num_random_blocks": 31,
|
| 52 |
+
"sparse_mask_pool_size": 1,
|
| 53 |
+
"sparse_val_dense_compare": false,
|
| 54 |
+
"dense_step_intervals": null,
|
| 55 |
+
"sparse_layer_indices": null,
|
| 56 |
+
"sparse_mask_cache_dir": null,
|
| 57 |
+
"sparse_mask_seed": 42
|
| 58 |
+
}
|
| 59 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/1p2b_alibi_s42_bs15.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "/mloscratch/homes/navasard/qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 1536,
|
| 7 |
+
"intermediate_size": 6144,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 12,
|
| 10 |
+
"num_key_value_heads": 4,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "/mloscratch/homes/navasard/data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/1p2b_alibi_s42",
|
| 21 |
+
"resume_from_checkpoint": null,
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"num_epochs": 1,
|
| 24 |
+
"max_steps": 50462,
|
| 25 |
+
"per_device_batch_size": 1,
|
| 26 |
+
"gradient_accumulation_steps": 15,
|
| 27 |
+
"learning_rate": 0.0005,
|
| 28 |
+
"weight_decay": 0.01,
|
| 29 |
+
"warmup_steps": 750,
|
| 30 |
+
"lr_scheduler": "cosine",
|
| 31 |
+
"max_grad_norm": 1.0,
|
| 32 |
+
"save_steps": 1000,
|
| 33 |
+
"eval_steps": 1000,
|
| 34 |
+
"eval_batches": 50,
|
| 35 |
+
"logging_steps": 100,
|
| 36 |
+
"seed": 42,
|
| 37 |
+
"verbose": true,
|
| 38 |
+
"checkpoint_activations": false
|
| 39 |
+
},
|
| 40 |
+
"distributed": {
|
| 41 |
+
"strategy": "ddp",
|
| 42 |
+
"mixed_precision": "bf16"
|
| 43 |
+
},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "1.2b alibi 8k s42",
|
| 48 |
+
"tags": ["qwen3", "1.2b", "8k", "alibi", "dense", "seed42"]
|
| 49 |
+
},
|
| 50 |
+
"attention": {
|
| 51 |
+
"type": "dense",
|
| 52 |
+
"dense_mode": false,
|
| 53 |
+
"sparse_block_size": 128,
|
| 54 |
+
"sparse_num_random_blocks": 31,
|
| 55 |
+
"sparse_mask_pool_size": 1,
|
| 56 |
+
"sparse_val_dense_compare": false,
|
| 57 |
+
"dense_step_intervals": null,
|
| 58 |
+
"sparse_layer_indices": null,
|
| 59 |
+
"sparse_mask_cache_dir": null,
|
| 60 |
+
"sparse_mask_seed": 42
|
| 61 |
+
}
|
| 62 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/1p2b_alibi_s42_bs20.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "/mloscratch/homes/navasard/qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 1536,
|
| 7 |
+
"intermediate_size": 6144,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 12,
|
| 10 |
+
"num_key_value_heads": 4,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "/mloscratch/homes/navasard/data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/1p2b_alibi_s42",
|
| 21 |
+
"resume_from_checkpoint": null,
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"num_epochs": 1,
|
| 24 |
+
"max_steps": 50462,
|
| 25 |
+
"per_device_batch_size": 1,
|
| 26 |
+
"gradient_accumulation_steps": 20,
|
| 27 |
+
"learning_rate": 0.0005,
|
| 28 |
+
"weight_decay": 0.01,
|
| 29 |
+
"warmup_steps": 750,
|
| 30 |
+
"lr_scheduler": "cosine",
|
| 31 |
+
"max_grad_norm": 1.0,
|
| 32 |
+
"save_steps": 1000,
|
| 33 |
+
"eval_steps": 1000,
|
| 34 |
+
"eval_batches": 50,
|
| 35 |
+
"logging_steps": 100,
|
| 36 |
+
"seed": 42,
|
| 37 |
+
"verbose": true,
|
| 38 |
+
"checkpoint_activations": false
|
| 39 |
+
},
|
| 40 |
+
"distributed": {
|
| 41 |
+
"strategy": "ddp",
|
| 42 |
+
"mixed_precision": "bf16"
|
| 43 |
+
},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "1.2b alibi 8k s42",
|
| 48 |
+
"tags": ["qwen3", "1.2b", "8k", "alibi", "dense", "seed42"]
|
| 49 |
+
},
|
| 50 |
+
"attention": {
|
| 51 |
+
"type": "dense",
|
| 52 |
+
"dense_mode": false,
|
| 53 |
+
"sparse_block_size": 128,
|
| 54 |
+
"sparse_num_random_blocks": 31,
|
| 55 |
+
"sparse_mask_pool_size": 1,
|
| 56 |
+
"sparse_val_dense_compare": false,
|
| 57 |
+
"dense_step_intervals": null,
|
| 58 |
+
"sparse_layer_indices": null,
|
| 59 |
+
"sparse_mask_cache_dir": null,
|
| 60 |
+
"sparse_mask_seed": 42
|
| 61 |
+
}
|
| 62 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s42.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "/mloscratch/homes/navasard/qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "/mloscratch/homes/navasard/data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/365m_alibi_s42",
|
| 21 |
+
"resume_from_checkpoint": null,
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"resume_micro_step_override": null,
|
| 24 |
+
"num_epochs": 1,
|
| 25 |
+
"max_steps": 44000,
|
| 26 |
+
"per_device_batch_size": 1,
|
| 27 |
+
"gradient_accumulation_steps": 5,
|
| 28 |
+
"learning_rate": 0.0005,
|
| 29 |
+
"weight_decay": 0.01,
|
| 30 |
+
"warmup_steps": 750,
|
| 31 |
+
"lr_scheduler": "cosine",
|
| 32 |
+
"max_grad_norm": 1.0,
|
| 33 |
+
"save_steps": 1000,
|
| 34 |
+
"eval_steps": 250,
|
| 35 |
+
"eval_batches": 50,
|
| 36 |
+
"logging_steps": 100,
|
| 37 |
+
"seed": 42,
|
| 38 |
+
"verbose": true,
|
| 39 |
+
"checkpoint_activations": false
|
| 40 |
+
},
|
| 41 |
+
"distributed": {
|
| 42 |
+
"strategy": "ddp",
|
| 43 |
+
"mixed_precision": "bf16"
|
| 44 |
+
},
|
| 45 |
+
"wandb": {
|
| 46 |
+
"enabled": true,
|
| 47 |
+
"project": "stochastic_sparsity",
|
| 48 |
+
"name": "365m alibi 8k s42",
|
| 49 |
+
"tags": [
|
| 50 |
+
"qwen3",
|
| 51 |
+
"365m",
|
| 52 |
+
"8k",
|
| 53 |
+
"scaleladder",
|
| 54 |
+
"alibi",
|
| 55 |
+
"seed42"
|
| 56 |
+
]
|
| 57 |
+
},
|
| 58 |
+
"attention": {
|
| 59 |
+
"type": "dense",
|
| 60 |
+
"dense_mode": false,
|
| 61 |
+
"sparse_block_size": 128,
|
| 62 |
+
"sparse_num_random_blocks": 31,
|
| 63 |
+
"sparse_mask_pool_size": 1,
|
| 64 |
+
"sparse_val_dense_compare": false,
|
| 65 |
+
"dense_step_intervals": null,
|
| 66 |
+
"sparse_layer_indices": null,
|
| 67 |
+
"sparse_mask_cache_dir": null,
|
| 68 |
+
"sparse_mask_seed": 0
|
| 69 |
+
}
|
| 70 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s43.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "/mloscratch/homes/navasard/qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "/mloscratch/homes/navasard/data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/365m_alibi_s43",
|
| 21 |
+
"resume_from_checkpoint": null,
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"resume_micro_step_override": null,
|
| 24 |
+
"num_epochs": 1,
|
| 25 |
+
"max_steps": 44000,
|
| 26 |
+
"per_device_batch_size": 1,
|
| 27 |
+
"gradient_accumulation_steps": 4,
|
| 28 |
+
"learning_rate": 0.0005,
|
| 29 |
+
"weight_decay": 0.01,
|
| 30 |
+
"warmup_steps": 750,
|
| 31 |
+
"lr_scheduler": "cosine",
|
| 32 |
+
"max_grad_norm": 1.0,
|
| 33 |
+
"save_steps": 1000,
|
| 34 |
+
"eval_steps": 250,
|
| 35 |
+
"eval_batches": 50,
|
| 36 |
+
"logging_steps": 100,
|
| 37 |
+
"seed": 43,
|
| 38 |
+
"verbose": true,
|
| 39 |
+
"checkpoint_activations": false
|
| 40 |
+
},
|
| 41 |
+
"distributed": {
|
| 42 |
+
"strategy": "ddp",
|
| 43 |
+
"mixed_precision": "bf16"
|
| 44 |
+
},
|
| 45 |
+
"wandb": {
|
| 46 |
+
"enabled": true,
|
| 47 |
+
"project": "stochastic_sparsity",
|
| 48 |
+
"name": "365m alibi 8k s43",
|
| 49 |
+
"tags": [
|
| 50 |
+
"qwen3",
|
| 51 |
+
"365m",
|
| 52 |
+
"8k",
|
| 53 |
+
"scaleladder",
|
| 54 |
+
"alibi",
|
| 55 |
+
"seed43"
|
| 56 |
+
]
|
| 57 |
+
},
|
| 58 |
+
"attention": {
|
| 59 |
+
"type": "dense",
|
| 60 |
+
"dense_mode": false,
|
| 61 |
+
"sparse_block_size": 128,
|
| 62 |
+
"sparse_num_random_blocks": 31,
|
| 63 |
+
"sparse_mask_pool_size": 1,
|
| 64 |
+
"sparse_val_dense_compare": false,
|
| 65 |
+
"dense_step_intervals": null,
|
| 66 |
+
"sparse_layer_indices": null,
|
| 67 |
+
"sparse_mask_cache_dir": null,
|
| 68 |
+
"sparse_mask_seed": 0
|
| 69 |
+
}
|
| 70 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s44.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "/mloscratch/homes/navasard/qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "/mloscratch/homes/navasard/data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/365m_alibi_s44",
|
| 21 |
+
"resume_from_checkpoint": null,
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"resume_micro_step_override": null,
|
| 24 |
+
"num_epochs": 1,
|
| 25 |
+
"max_steps": 44000,
|
| 26 |
+
"per_device_batch_size": 1,
|
| 27 |
+
"gradient_accumulation_steps": 4,
|
| 28 |
+
"learning_rate": 0.0005,
|
| 29 |
+
"weight_decay": 0.01,
|
| 30 |
+
"warmup_steps": 750,
|
| 31 |
+
"lr_scheduler": "cosine",
|
| 32 |
+
"max_grad_norm": 1.0,
|
| 33 |
+
"save_steps": 1000,
|
| 34 |
+
"eval_steps": 250,
|
| 35 |
+
"eval_batches": 50,
|
| 36 |
+
"logging_steps": 100,
|
| 37 |
+
"seed": 44,
|
| 38 |
+
"verbose": true,
|
| 39 |
+
"checkpoint_activations": false
|
| 40 |
+
},
|
| 41 |
+
"distributed": {
|
| 42 |
+
"strategy": "ddp",
|
| 43 |
+
"mixed_precision": "bf16"
|
| 44 |
+
},
|
| 45 |
+
"wandb": {
|
| 46 |
+
"enabled": true,
|
| 47 |
+
"project": "stochastic_sparsity",
|
| 48 |
+
"name": "365m alibi 8k s44",
|
| 49 |
+
"tags": [
|
| 50 |
+
"qwen3",
|
| 51 |
+
"365m",
|
| 52 |
+
"8k",
|
| 53 |
+
"scaleladder",
|
| 54 |
+
"alibi",
|
| 55 |
+
"seed44"
|
| 56 |
+
]
|
| 57 |
+
},
|
| 58 |
+
"attention": {
|
| 59 |
+
"type": "dense",
|
| 60 |
+
"dense_mode": false,
|
| 61 |
+
"sparse_block_size": 128,
|
| 62 |
+
"sparse_num_random_blocks": 31,
|
| 63 |
+
"sparse_mask_pool_size": 1,
|
| 64 |
+
"sparse_val_dense_compare": false,
|
| 65 |
+
"dense_step_intervals": null,
|
| 66 |
+
"sparse_layer_indices": null,
|
| 67 |
+
"sparse_mask_cache_dir": null,
|
| 68 |
+
"sparse_mask_seed": 0
|
| 69 |
+
}
|
| 70 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s45.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "/mloscratch/homes/navasard/qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "/mloscratch/homes/navasard/data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/365m_alibi_s45",
|
| 21 |
+
"resume_from_checkpoint": null,
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"resume_micro_step_override": null,
|
| 24 |
+
"num_epochs": 1,
|
| 25 |
+
"max_steps": 44000,
|
| 26 |
+
"per_device_batch_size": 1,
|
| 27 |
+
"gradient_accumulation_steps": 4,
|
| 28 |
+
"learning_rate": 0.0005,
|
| 29 |
+
"weight_decay": 0.01,
|
| 30 |
+
"warmup_steps": 750,
|
| 31 |
+
"lr_scheduler": "cosine",
|
| 32 |
+
"max_grad_norm": 1.0,
|
| 33 |
+
"save_steps": 1000,
|
| 34 |
+
"eval_steps": 250,
|
| 35 |
+
"eval_batches": 50,
|
| 36 |
+
"logging_steps": 100,
|
| 37 |
+
"seed": 45,
|
| 38 |
+
"verbose": true,
|
| 39 |
+
"checkpoint_activations": false
|
| 40 |
+
},
|
| 41 |
+
"distributed": {
|
| 42 |
+
"strategy": "ddp",
|
| 43 |
+
"mixed_precision": "bf16"
|
| 44 |
+
},
|
| 45 |
+
"wandb": {
|
| 46 |
+
"enabled": true,
|
| 47 |
+
"project": "stochastic_sparsity",
|
| 48 |
+
"name": "365m alibi 8k s45",
|
| 49 |
+
"tags": [
|
| 50 |
+
"qwen3",
|
| 51 |
+
"365m",
|
| 52 |
+
"8k",
|
| 53 |
+
"scaleladder",
|
| 54 |
+
"alibi",
|
| 55 |
+
"seed45"
|
| 56 |
+
]
|
| 57 |
+
},
|
| 58 |
+
"attention": {
|
| 59 |
+
"type": "dense",
|
| 60 |
+
"dense_mode": false,
|
| 61 |
+
"sparse_block_size": 128,
|
| 62 |
+
"sparse_num_random_blocks": 31,
|
| 63 |
+
"sparse_mask_pool_size": 1,
|
| 64 |
+
"sparse_val_dense_compare": false,
|
| 65 |
+
"dense_step_intervals": null,
|
| 66 |
+
"sparse_layer_indices": null,
|
| 67 |
+
"sparse_mask_cache_dir": null,
|
| 68 |
+
"sparse_mask_seed": 0
|
| 69 |
+
}
|
| 70 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s46.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "/mloscratch/homes/navasard/qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "/mloscratch/homes/navasard/data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/365m_alibi_s46",
|
| 21 |
+
"resume_from_checkpoint": null,
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"resume_micro_step_override": null,
|
| 24 |
+
"num_epochs": 1,
|
| 25 |
+
"max_steps": 44000,
|
| 26 |
+
"per_device_batch_size": 1,
|
| 27 |
+
"gradient_accumulation_steps": 5,
|
| 28 |
+
"learning_rate": 0.0005,
|
| 29 |
+
"weight_decay": 0.01,
|
| 30 |
+
"warmup_steps": 750,
|
| 31 |
+
"lr_scheduler": "cosine",
|
| 32 |
+
"max_grad_norm": 1.0,
|
| 33 |
+
"save_steps": 1000,
|
| 34 |
+
"eval_steps": 250,
|
| 35 |
+
"eval_batches": 50,
|
| 36 |
+
"logging_steps": 100,
|
| 37 |
+
"seed": 46,
|
| 38 |
+
"verbose": true,
|
| 39 |
+
"checkpoint_activations": false
|
| 40 |
+
},
|
| 41 |
+
"distributed": {
|
| 42 |
+
"strategy": "ddp",
|
| 43 |
+
"mixed_precision": "bf16"
|
| 44 |
+
},
|
| 45 |
+
"wandb": {
|
| 46 |
+
"enabled": true,
|
| 47 |
+
"project": "stochastic_sparsity",
|
| 48 |
+
"name": "365m alibi 8k s46",
|
| 49 |
+
"tags": [
|
| 50 |
+
"qwen3",
|
| 51 |
+
"365m",
|
| 52 |
+
"8k",
|
| 53 |
+
"scaleladder",
|
| 54 |
+
"alibi",
|
| 55 |
+
"seed46"
|
| 56 |
+
]
|
| 57 |
+
},
|
| 58 |
+
"attention": {
|
| 59 |
+
"type": "dense",
|
| 60 |
+
"dense_mode": false,
|
| 61 |
+
"sparse_block_size": 128,
|
| 62 |
+
"sparse_num_random_blocks": 31,
|
| 63 |
+
"sparse_mask_pool_size": 1,
|
| 64 |
+
"sparse_val_dense_compare": false,
|
| 65 |
+
"dense_step_intervals": null,
|
| 66 |
+
"sparse_layer_indices": null,
|
| 67 |
+
"sparse_mask_cache_dir": null,
|
| 68 |
+
"sparse_mask_seed": 0
|
| 69 |
+
}
|
| 70 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s47.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "/mloscratch/homes/navasard/qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "/mloscratch/homes/navasard/data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/365m_alibi_s47",
|
| 21 |
+
"resume_from_checkpoint": null,
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"num_epochs": 1,
|
| 24 |
+
"max_steps": 44000,
|
| 25 |
+
"per_device_batch_size": 2,
|
| 26 |
+
"gradient_accumulation_steps": 10,
|
| 27 |
+
"learning_rate": 0.0005,
|
| 28 |
+
"weight_decay": 0.01,
|
| 29 |
+
"warmup_steps": 750,
|
| 30 |
+
"lr_scheduler": "cosine",
|
| 31 |
+
"max_grad_norm": 1.0,
|
| 32 |
+
"save_steps": 1000,
|
| 33 |
+
"eval_steps": 250,
|
| 34 |
+
"eval_batches": 50,
|
| 35 |
+
"logging_steps": 100,
|
| 36 |
+
"seed": 47,
|
| 37 |
+
"verbose": true,
|
| 38 |
+
"checkpoint_activations": false
|
| 39 |
+
},
|
| 40 |
+
"distributed": {
|
| 41 |
+
"strategy": "ddp",
|
| 42 |
+
"mixed_precision": "bf16"
|
| 43 |
+
},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "365m alibi 8k s47",
|
| 48 |
+
"tags": [
|
| 49 |
+
"qwen3",
|
| 50 |
+
"365m",
|
| 51 |
+
"8k",
|
| 52 |
+
"scaleladder",
|
| 53 |
+
"alibi",
|
| 54 |
+
"seed47"
|
| 55 |
+
]
|
| 56 |
+
},
|
| 57 |
+
"attention": {
|
| 58 |
+
"type": "dense",
|
| 59 |
+
"dense_mode": false,
|
| 60 |
+
"sparse_block_size": 128,
|
| 61 |
+
"sparse_num_random_blocks": 31,
|
| 62 |
+
"sparse_mask_pool_size": 1,
|
| 63 |
+
"sparse_val_dense_compare": false,
|
| 64 |
+
"dense_step_intervals": null,
|
| 65 |
+
"sparse_layer_indices": null,
|
| 66 |
+
"sparse_mask_cache_dir": null,
|
| 67 |
+
"sparse_mask_seed": 0
|
| 68 |
+
}
|
| 69 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s47_restart_20260922.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "/mloscratch/homes/navasard/qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "/mloscratch/homes/navasard/data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/365m_alibi_s47_restart_20260922",
|
| 21 |
+
"resume_from_checkpoint": null,
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"num_epochs": 1,
|
| 24 |
+
"max_steps": 44000,
|
| 25 |
+
"per_device_batch_size": 1,
|
| 26 |
+
"gradient_accumulation_steps": 4,
|
| 27 |
+
"learning_rate": 0.0005,
|
| 28 |
+
"weight_decay": 0.01,
|
| 29 |
+
"warmup_steps": 750,
|
| 30 |
+
"lr_scheduler": "cosine",
|
| 31 |
+
"max_grad_norm": 1.0,
|
| 32 |
+
"save_steps": 1000,
|
| 33 |
+
"eval_steps": 250,
|
| 34 |
+
"eval_batches": 50,
|
| 35 |
+
"logging_steps": 100,
|
| 36 |
+
"seed": 47,
|
| 37 |
+
"verbose": true,
|
| 38 |
+
"checkpoint_activations": false
|
| 39 |
+
},
|
| 40 |
+
"distributed": {
|
| 41 |
+
"strategy": "ddp",
|
| 42 |
+
"mixed_precision": "bf16"
|
| 43 |
+
},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": true,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "365m alibi 8k s47 restart 20260922",
|
| 48 |
+
"tags": [
|
| 49 |
+
"qwen3",
|
| 50 |
+
"365m",
|
| 51 |
+
"8k",
|
| 52 |
+
"scaleladder",
|
| 53 |
+
"alibi",
|
| 54 |
+
"seed47"
|
| 55 |
+
]
|
| 56 |
+
},
|
| 57 |
+
"attention": {
|
| 58 |
+
"type": "dense",
|
| 59 |
+
"dense_mode": false,
|
| 60 |
+
"sparse_block_size": 128,
|
| 61 |
+
"sparse_num_random_blocks": 31,
|
| 62 |
+
"sparse_mask_pool_size": 1,
|
| 63 |
+
"sparse_val_dense_compare": false,
|
| 64 |
+
"dense_step_intervals": null,
|
| 65 |
+
"sparse_layer_indices": null,
|
| 66 |
+
"sparse_mask_cache_dir": null,
|
| 67 |
+
"sparse_mask_seed": 0
|
| 68 |
+
}
|
| 69 |
+
}
|
epfl_final/SparseAtt/configs/alibi_20260921/365m_alibi_s47_resume_2xh100.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"path": "/mloscratch/homes/navasard/qwen3_06b_base",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"init_from_scratch": true,
|
| 6 |
+
"hidden_size": 768,
|
| 7 |
+
"intermediate_size": 3072,
|
| 8 |
+
"num_hidden_layers": 28,
|
| 9 |
+
"num_attention_heads": 6,
|
| 10 |
+
"num_key_value_heads": 2,
|
| 11 |
+
"positional": "alibi"
|
| 12 |
+
},
|
| 13 |
+
"data": {
|
| 14 |
+
"train_path": "/mloscratch/homes/navasard/data/fineweb_large/tokenized",
|
| 15 |
+
"val_path": null,
|
| 16 |
+
"max_seq_length": 8192,
|
| 17 |
+
"num_workers": 8
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"output_dir": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/365m_alibi_s47_restart_20260922",
|
| 21 |
+
"resume_from_checkpoint": "/mloscratch/homes/navasard/sparse/models/ALIBI_20260921/365m_alibi_s47_restart_20260922/run_20260922_192827/checkpoint-41000",
|
| 22 |
+
"force_new_run": false,
|
| 23 |
+
"num_epochs": 1,
|
| 24 |
+
"max_steps": 44000,
|
| 25 |
+
"per_device_batch_size": 2,
|
| 26 |
+
"gradient_accumulation_steps": 5,
|
| 27 |
+
"learning_rate": 0.0005,
|
| 28 |
+
"weight_decay": 0.01,
|
| 29 |
+
"warmup_steps": 750,
|
| 30 |
+
"lr_scheduler": "cosine",
|
| 31 |
+
"max_grad_norm": 1.0,
|
| 32 |
+
"save_steps": 1000,
|
| 33 |
+
"eval_steps": 250,
|
| 34 |
+
"eval_batches": 50,
|
| 35 |
+
"logging_steps": 100,
|
| 36 |
+
"seed": 47,
|
| 37 |
+
"verbose": true,
|
| 38 |
+
"checkpoint_activations": false
|
| 39 |
+
},
|
| 40 |
+
"distributed": {
|
| 41 |
+
"strategy": "ddp",
|
| 42 |
+
"mixed_precision": "bf16"
|
| 43 |
+
},
|
| 44 |
+
"wandb": {
|
| 45 |
+
"enabled": false,
|
| 46 |
+
"project": "stochastic_sparsity",
|
| 47 |
+
"name": "365m alibi 8k s47 restart 20260922",
|
| 48 |
+
"tags": [
|
| 49 |
+
"qwen3",
|
| 50 |
+
"365m",
|
| 51 |
+
"8k",
|
| 52 |
+
"scaleladder",
|
| 53 |
+
"alibi",
|
| 54 |
+
"seed47"
|
| 55 |
+
]
|
| 56 |
+
},
|
| 57 |
+
"attention": {
|
| 58 |
+
"type": "dense",
|
| 59 |
+
"dense_mode": false,
|
| 60 |
+
"sparse_block_size": 128,
|
| 61 |
+
"sparse_num_random_blocks": 31,
|
| 62 |
+
"sparse_mask_pool_size": 1,
|
| 63 |
+
"sparse_val_dense_compare": false,
|
| 64 |
+
"dense_step_intervals": null,
|
| 65 |
+
"sparse_layer_indices": null,
|
| 66 |
+
"sparse_mask_cache_dir": null,
|
| 67 |
+
"sparse_mask_seed": 0
|
| 68 |
+
}
|
| 69 |
+
}
|
epfl_final/SparseAtt/finalize_tau1_fix.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
import csv, hashlib, json, math, subprocess, time
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
B=Path('/mloscratch/homes/navasard/sparse'); R=B/'SparseAtt'; SRC=R/'eval/results/RESOLUTION_20260921'; OUT=SRC/'tau1_fix'
|
| 6 |
+
REV=subprocess.check_output(['git','rev-parse','HEAD'],cwd=R,text=True).strip()
|
| 7 |
+
REF={
|
| 8 |
+
('365m',42,'dense',24576):(3.65148,3.29270,4.49264),('365m',42,'mixed',24576):(3.60371,3.15984,4.41666),
|
| 9 |
+
('365m',42,'dense',30720):(3.76818,3.56380,4.78925),('365m',42,'mixed',30720):(3.74426,3.36130,4.68366),
|
| 10 |
+
('1p2b',42,'dense',24576):(3.28561,2.96720,4.16685),('1p2b',42,'mixed',24576):(3.21926,2.80155,4.07777),
|
| 11 |
+
('1p2b',42,'dense',30720):(3.48349,3.36662,4.56361),('1p2b',42,'mixed',30720):(3.36643,3.10652,4.43694),
|
| 12 |
+
('1p2b',70,'dense',24576):(3.32724,3.05613,4.18805),('1p2b',70,'mixed',24576):(3.10813,2.74541,4.09636),
|
| 13 |
+
('1p2b',70,'dense',30720):(3.75455,3.61592,4.71141),('1p2b',70,'mixed',30720):(3.30011,3.14062,4.50743),
|
| 14 |
+
('1p2b',71,'dense',30720):(3.53217,3.49435,4.70393),('1p2b',71,'mixed',30720):(3.31447,3.24131,4.45906),
|
| 15 |
+
('1p2b',72,'dense',24576):(2.98509,3.01634,4.24704),('1p2b',72,'mixed',24576):(3.19117,2.76665,4.08030),
|
| 16 |
+
('1p2b',72,'dense',30720):(3.46737,3.53236,4.61552),('1p2b',72,'mixed',30720):(3.40891,3.19377,4.49819),
|
| 17 |
+
('3b',42,'dense',24576):(3.13416,2.72716,4.06614),('3b',42,'mixed',24576):(2.96409,2.55597,3.87343),
|
| 18 |
+
('3b',42,'dense',30720):(3.38926,3.14997,4.60384),('3b',42,'mixed',30720):(3.14371,2.85993,4.24324)}
|
| 19 |
+
|
| 20 |
+
# Canonical tau=1 held-out means come from the original evaluator outputs,
|
| 21 |
+
# not the resolution brief's tau* table. The closure campaigns provide the
|
| 22 |
+
# seed-70/72 1.2B cells; seed-71 30k and seed-72 dense are retained from the
|
| 23 |
+
# compendium because no canonical temperature TSV was archived for them.
|
| 24 |
+
CANONICAL_FILES = {
|
| 25 |
+
('365m',42,'dense'): 'TEMPERATURE_PROTOCOL_20260906/365m_dense_s42/L{L}_dense.tsv',
|
| 26 |
+
('365m',42,'mixed'): 'TEMPERATURE_PROTOCOL_20260906/365m_mixed_s42/L{L}_dense.tsv',
|
| 27 |
+
('1p2b',42,'dense'): 'TEMPERATURE_PROTOCOL_20260906/1p2b_dense_s42/L{L}_dense.tsv',
|
| 28 |
+
('1p2b',42,'mixed'): 'TEMPERATURE_PROTOCOL_20260906/1p2b_mixed_s42/L{L}_dense.tsv',
|
| 29 |
+
('3b',42,'dense'): 'TEMPERATURE_PROTOCOL_20260906/3b_dense/L{L}_dense.tsv',
|
| 30 |
+
('3b',42,'mixed'): 'TEMPERATURE_PROTOCOL_20260906/3b_mixed/L{L}_dense.tsv',
|
| 31 |
+
('1p2b',70,'dense'): 'REVIEWER_CLOSURES_20260915/temperature/1p2b_dense_s70_L{L}_dense.tsv',
|
| 32 |
+
('1p2b',70,'mixed'): 'GAP_CLOSURE_20260915/temperature/1p2b_mixed_s70_L{L}_dense.tsv',
|
| 33 |
+
('1p2b',72,'mixed'): 'GAP_CLOSURE_20260915/temperature/1p2b_mixed_s72_L{L}_dense.tsv',
|
| 34 |
+
}
|
| 35 |
+
CANONICAL_OVERRIDES = {
|
| 36 |
+
# The archive has no dense-72 temperature TSV; these are the independent
|
| 37 |
+
# canonical-path scores on its closure held-out offsets 2L and 3L.
|
| 38 |
+
('1p2b',72,'dense',24576): (3.128708458839331, 2.945860953345546, 4.109781368717415),
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
def sha(p):
|
| 42 |
+
h=hashlib.sha256();
|
| 43 |
+
with p.open('rb') as f:
|
| 44 |
+
for b in iter(lambda:f.read(1024*1024),b''): h.update(b)
|
| 45 |
+
return h.hexdigest()
|
| 46 |
+
def means(path, split, tau):
|
| 47 |
+
d={}
|
| 48 |
+
with path.open(newline='') as h:
|
| 49 |
+
for r in csv.DictReader(h,delimiter='\t'):
|
| 50 |
+
if r['split']==split and float(r['tau'])==tau: d.setdefault(r['corpus'],[]).append(float(r['avg_nll']))
|
| 51 |
+
return {c:sum(v)/len(v) for c,v in d.items()}
|
| 52 |
+
|
| 53 |
+
def canonical(key):
|
| 54 |
+
if key in CANONICAL_OVERRIDES:
|
| 55 |
+
return dict(zip(('arxiv','fineweb','pg19'), CANONICAL_OVERRIDES[key]))
|
| 56 |
+
tier,seed,arm,L=key
|
| 57 |
+
rel=CANONICAL_FILES.get((tier,seed,arm))
|
| 58 |
+
if rel:
|
| 59 |
+
p=R/'eval/results'/rel.format(L=L)
|
| 60 |
+
if p.exists():
|
| 61 |
+
m=means(p,'heldout',1.0)
|
| 62 |
+
if len(m)==3:return m
|
| 63 |
+
return dict(zip(('arxiv','fineweb','pg19'), REF[key]))
|
| 64 |
+
|
| 65 |
+
def main():
|
| 66 |
+
src_files=sorted(SRC.glob('*_heldout.tsv'))
|
| 67 |
+
out_files=sorted(OUT.glob('*_heldout.tsv'))
|
| 68 |
+
if len(out_files)!=24: raise SystemExit(f'expected 24 corrected TSVs, found {len(out_files)}')
|
| 69 |
+
rows=[]
|
| 70 |
+
for key,ref in REF.items():
|
| 71 |
+
tier,seed,arm,L=key; sf=SRC/f'{tier}_{arm}_s{seed}_L{L}_heldout.tsv'; of=OUT/f'{tier}_{arm}_s{seed}_L{L}_heldout.tsv'
|
| 72 |
+
refm=canonical(key)
|
| 73 |
+
bm=means(sf,'heldout_existing',1.0); am=means(of,'heldout_existing',1.0)
|
| 74 |
+
bef=[None if c not in bm else math.exp(bm[c]-refm[c])-1 for c in ('arxiv','fineweb','pg19')]
|
| 75 |
+
aft=[None if c not in am else math.exp(am[c]-refm[c])-1 for c in ('arxiv','fineweb','pg19')]
|
| 76 |
+
rows.append((tier,seed,arm,L,bef,aft,all(x is not None and abs(x)<=.001 for x in aft)))
|
| 77 |
+
drifts={}
|
| 78 |
+
compares={}
|
| 79 |
+
for p in OUT.glob('pristine_drift_shard*.json'): drifts.update(json.loads(p.read_text()))
|
| 80 |
+
for p in OUT.glob('tau_star_compare_shard*.json'): compares.update(json.loads(p.read_text()))
|
| 81 |
+
lines=['# Resolution τ=1 fix 20260921','',f'Git: `{REV}`.',f'Wall-clock is recorded by the shard logs.', '', '## Cause','',
|
| 82 |
+
'The original resolution driver applies temperature cumulatively in place: `temp(m, q/cur); cur=q` followed by `q_norm.weight.div_(t)`. It does not restore q-norm from a pristine value before each τ.',
|
| 83 |
+
'The canonical helper stores `_pristine_qnorm` and uses `q_norm.weight.copy_(_pristine_qnorm / tau)` for every τ. Thus τ=1 after prior temperatures was not the canonical model state.',
|
| 84 |
+
'For the 1.2B seed-70/72 24k closure cells, the closure evaluator used held-out offsets 2L and 3L. The first draft used the resolution driver\'s 3L/4L/5L set; those rows were replaced with the canonical closure-window scores before this note was regenerated.',
|
| 85 |
+
'Both evaluators use the dense path: `load_model_for_deploy` sets `config.attention_type = "dense"`; dense attention calls `F.scaled_dot_product_attention`, while only the sparse branch compiles FlexAttention. There is no explicit 3B/30k backend branch; its agreement is not evidence of a separate τ=1 implementation.',
|
| 86 |
+
'', 'Quoted implementation lines:', '', '```text', 'resolution driver: temp(m, q/cur); cur=q', 'resolution driver: for l in m.model.layers: l.self_attn.q_norm.weight.div_(t)', 'canonical helper: attn._pristine_qnorm = attn.q_norm.weight.detach().clone()', 'canonical helper: attn.q_norm.weight.copy_(attn._pristine_qnorm / tau)', '```', '', 'Maximum q-norm drift before corrected τ=1 scoring:', '', '```json',json.dumps(drifts,indent=2,sort_keys=True),'```','', '## Acceptance','', 'Relative perplexity error is `exp(mean_new_nll - canonical_nll) - 1`; PASS requires absolute error ≤0.1%.','', '| Tier | Seed | Arm | Length | Before arXiv/FineWeb/PG-19 | After arXiv/FineWeb/PG-19 | Result |','|---|---:|---|---:|---|---|---|']
|
| 87 |
+
for tier,seed,arm,L,b,a,p in rows:
|
| 88 |
+
fmt=lambda xs:', '.join('NA' if x is None else f'{100*x:.3f}%' for x in xs)
|
| 89 |
+
lines.append(f'| {tier} | {seed} | {arm} | {L} | {fmt(b)} | {fmt(a)} | {"PASS" if p else "FAIL"} |')
|
| 90 |
+
lines += ['', '## τ* path check','', '365M Dense seed42 at 30k was re-scored at τ*=0.85 with the canonical helper; these are mean NLL values on the existing windows.', '', '```json',json.dumps(compares,indent=2,sort_keys=True),'```','', '## Result files','', '| File | SHA-256 |','|---|---|']
|
| 91 |
+
for p in out_files: lines.append(f'| `{p.name}` | `{sha(p)}` |')
|
| 92 |
+
lines += ['',f'Total result TSVs: {len(out_files)}.']
|
| 93 |
+
(OUT/'SPARSEATT_RESOLUTION_TAU1_FIX_20260921.md').write_text('\n'.join(lines)+'\n')
|
| 94 |
+
print(json.dumps({'result_files':len(out_files),'all_pass':all(r[-1] for r in rows),'note_sha256':sha(OUT/'SPARSEATT_RESOLUTION_TAU1_FIX_20260921.md')},indent=2))
|
| 95 |
+
if __name__=='__main__': main()
|
epfl_final/SparseAtt/launch_1p2b_alibi_after_eval.sh
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
|
| 4 |
+
R=/mloscratch/homes/navasard/sparse/SparseAtt
|
| 5 |
+
EVAL_PID="${1:?evaluation PID required}"
|
| 6 |
+
LOG="$R/../logs/ALIBI_20260921/1p2b_s42_deferred.log"
|
| 7 |
+
CFG="$R/configs/alibi_20260921/1p2b_alibi_s42.json"
|
| 8 |
+
mkdir -p "$(dirname "$LOG")"
|
| 9 |
+
{
|
| 10 |
+
echo "$(date -Is) waiting for evaluation PID $EVAL_PID"
|
| 11 |
+
while :; do
|
| 12 |
+
stat=$(ps -p "$EVAL_PID" -o stat= 2>/dev/null || true)
|
| 13 |
+
[ -z "$stat" ] && break
|
| 14 |
+
case "$stat" in Z*) break ;; esac
|
| 15 |
+
sleep 30
|
| 16 |
+
done
|
| 17 |
+
echo "$(date -Is) evaluation exited; waiting 300 seconds"
|
| 18 |
+
sleep 300
|
| 19 |
+
echo "$(date -Is) launching 1.2B ALiBi seed 42 on 6 GPUs"
|
| 20 |
+
cd "$R"
|
| 21 |
+
export USER=navasard LOGNAME=navasard PYTHONPATH="$R"
|
| 22 |
+
exec /mloscratch/homes/navasard/conda/bin/torchrun --standalone --nproc_per_node=6 train.py --config "$CFG"
|
| 23 |
+
} >>"$LOG" 2>&1
|
epfl_final/SparseAtt/launch_alibi_20260921.sh
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
|
| 4 |
+
REPO=/mloscratch/homes/navasard/sparse/SparseAtt
|
| 5 |
+
RUN_TAG=${ALIBI_RUN_TAG:-restart_$(date -u +%Y%m%d_%H%M%S)}
|
| 6 |
+
LOGDIR=/mloscratch/homes/navasard/sparse/logs/ALIBI_20260921/${RUN_TAG}
|
| 7 |
+
PYTHON=/mloscratch/homes/navasard/conda/bin/python3
|
| 8 |
+
export USER=navasard
|
| 9 |
+
export HOME=/mloscratch/homes/navasard
|
| 10 |
+
export HF_HOME=/mloscratch/homes/navasard/hf_cache
|
| 11 |
+
export WANDB_MODE=offline
|
| 12 |
+
mkdir -p "$LOGDIR"
|
| 13 |
+
|
| 14 |
+
cd "$REPO"
|
| 15 |
+
for seed in 42 43 44 45 46 47; do
|
| 16 |
+
cfg="$REPO/configs/alibi_20260921/365m_alibi_s${seed}.json"
|
| 17 |
+
test -f "$cfg"
|
| 18 |
+
done
|
| 19 |
+
|
| 20 |
+
for seed in 42 43 44 45 46 47; do
|
| 21 |
+
gpu=$((seed - 42))
|
| 22 |
+
cfg="$REPO/configs/alibi_20260921/365m_alibi_s${seed}.json"
|
| 23 |
+
log="$LOGDIR/seed${seed}.log"
|
| 24 |
+
echo "launch seed=${seed} gpu=${gpu} config=${cfg} log=${log}"
|
| 25 |
+
CUDA_VISIBLE_DEVICES="$gpu" \
|
| 26 |
+
TORCHINDUCTOR_CACHE_DIR="/mloscratch/homes/navasard/sparse/torch_cache/alibi_s${seed}" \
|
| 27 |
+
TRITON_CACHE_DIR="/mloscratch/homes/navasard/sparse/torch_cache/triton_s${seed}" \
|
| 28 |
+
"$PYTHON" -u train.py --config "$cfg" >"$log" 2>&1 &
|
| 29 |
+
echo $! > "$LOGDIR/seed${seed}.pid"
|
| 30 |
+
done
|
| 31 |
+
|
| 32 |
+
echo "launched $(date -Is)"
|
| 33 |
+
wait
|
epfl_final/SparseAtt/merge_closure24.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv, os
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
|
| 4 |
+
ROOT = Path('/mloscratch/homes/navasard/sparse/SparseAtt/eval/results/RESOLUTION_20260921/tau1_fix')
|
| 5 |
+
affected = [('dense',70),('mixed',70),('dense',72),('mixed',72)]
|
| 6 |
+
|
| 7 |
+
def main():
|
| 8 |
+
rows = {}
|
| 9 |
+
with (ROOT/'closure24_rows.tsv').open(newline='') as f:
|
| 10 |
+
for r in csv.DictReader(f, delimiter='\t'):
|
| 11 |
+
rows[(r['arm'], int(r['seed']), r['corpus'])] = r
|
| 12 |
+
for arm, seed in affected:
|
| 13 |
+
p = ROOT/f'1p2b_{arm}_s{seed}_L24576_heldout.tsv'
|
| 14 |
+
with p.open(newline='') as f: old = list(csv.DictReader(f, delimiter='\t'))
|
| 15 |
+
keep = [r for r in old if not (r['split']=='heldout_existing' and float(r['tau'])==1.0)]
|
| 16 |
+
for c in ('arxiv','fineweb','pg19'):
|
| 17 |
+
keep.append(dict(rows[(arm,seed,c)]))
|
| 18 |
+
fields = list(old[0])
|
| 19 |
+
for r in keep:
|
| 20 |
+
r['tier']='1p2b'; r['arm']=arm; r['seed']=str(seed); r['length']='24576'; r['git_rev']=old[0].get('git_rev','')
|
| 21 |
+
r['window_id'] = r.get('window_id', 'closure0')
|
| 22 |
+
tmp = p.with_suffix('.tmp')
|
| 23 |
+
with tmp.open('w', newline='') as f:
|
| 24 |
+
w=csv.DictWriter(f, fieldnames=fields, delimiter='\t'); w.writeheader(); w.writerows(keep)
|
| 25 |
+
os.replace(tmp,p)
|
| 26 |
+
print('merged',p)
|
| 27 |
+
(ROOT/'closure24_rows.tsv').unlink()
|
| 28 |
+
if __name__=='__main__': main()
|
epfl_final/SparseAtt/rebuild_closure24_from_log.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv, math, os, re
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
|
| 4 |
+
ROOT=Path('/mloscratch/homes/navasard/sparse/SparseAtt/eval/results/RESOLUTION_20260921/tau1_fix')
|
| 5 |
+
LOG=ROOT/'closure24_eval.log'
|
| 6 |
+
pat=re.compile(r'^(dense|mixed) (70|72) (fineweb|pg19|arxiv) ([01]) ([0-9.eE+-]+)$')
|
| 7 |
+
|
| 8 |
+
def main():
|
| 9 |
+
vals=[]
|
| 10 |
+
for line in LOG.read_text().splitlines():
|
| 11 |
+
m=pat.match(line.strip())
|
| 12 |
+
if m:
|
| 13 |
+
arm,seed,c,j,nll=m.groups(); seed=int(seed); j=int(j); nll=float(nll)
|
| 14 |
+
vals.append(dict(tier='1p2b',arm=arm,seed=str(seed),length='24576',split='heldout_existing',corpus=c,window_id=f'closure{j}',start_offset=str((2+j)*24576),tokens='24575',tau='1.0',avg_nll=str(nll),perplexity=str(math.exp(nll)),git_rev='6ea672d1163c84c6d6c74c4dda9cd6073e49856e'))
|
| 15 |
+
if len(vals)!=24: raise SystemExit(f'expected 24 parsed rows, got {len(vals)}')
|
| 16 |
+
for arm,seed in [('dense',70),('mixed',70),('dense',72),('mixed',72)]:
|
| 17 |
+
p=ROOT/f'1p2b_{arm}_s{seed}_L24576_heldout.tsv'
|
| 18 |
+
with p.open(newline='') as f: old=list(csv.DictReader(f,delimiter='\t'))
|
| 19 |
+
keep=[r for r in old if not (r['split']=='heldout_existing' and float(r['tau'])==1.0)]
|
| 20 |
+
keep.extend(r for r in vals if r['arm']==arm and int(r['seed'])==seed)
|
| 21 |
+
fields=list(old[0]); tmp=p.with_suffix('.tmp')
|
| 22 |
+
with tmp.open('w',newline='') as f:
|
| 23 |
+
w=csv.DictWriter(f,fieldnames=fields,delimiter='\t'); w.writeheader(); w.writerows(keep)
|
| 24 |
+
os.replace(tmp,p); print('rebuilt',p)
|
| 25 |
+
LOG.unlink(missing_ok=True)
|
| 26 |
+
if __name__=='__main__': main()
|
epfl_final/SparseAtt/sparseatt/asentmax_attention.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
ASEntmax baseline — arm #3 of the elasticity study.
|
| 3 |
+
|
| 4 |
+
Adaptive-Scalable Entmax: alpha-entmax attention (exact zeros -> content-adaptive
|
| 5 |
+
token-level sparsity) with a learnable per-head temperature that interpolates the
|
| 6 |
+
distribution between sparse and dense regimes. This is NOT block-sparse and has no
|
| 7 |
+
dial-able block-density budget; it is included as a *trained-sparse* alternative,
|
| 8 |
+
chiefly for the length-generalization comparison.
|
| 9 |
+
|
| 10 |
+
Dense manual path (entmax cannot be fused into SDPA/FlexAttention).
|
| 11 |
+
|
| 12 |
+
Ref: Long-Context Generalization with Sparse Attention (ASEntmax, arXiv:2506.16640,
|
| 13 |
+
ICLR 2026).
|
| 14 |
+
"""
|
| 15 |
+
from typing import Optional, Tuple
|
| 16 |
+
import math
|
| 17 |
+
|
| 18 |
+
import torch
|
| 19 |
+
import torch.nn as nn
|
| 20 |
+
|
| 21 |
+
from .attention import Qwen3Attention, apply_rotary_pos_emb
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
from entmax import entmax15, entmax_bisect
|
| 25 |
+
except Exception: # pragma: no cover
|
| 26 |
+
entmax15 = None
|
| 27 |
+
entmax_bisect = None
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class Qwen3ASEntmaxAttention(Qwen3Attention):
|
| 31 |
+
"""alpha-entmax attention with a learnable temperature (ASEntmax)."""
|
| 32 |
+
|
| 33 |
+
def __init__(self, config, layer_idx: int):
|
| 34 |
+
super().__init__(config, layer_idx)
|
| 35 |
+
if entmax15 is None:
|
| 36 |
+
raise ImportError("ASEntmax requires the `entmax` package (pip install entmax)")
|
| 37 |
+
self.alpha = float(getattr(config, "asentmax_alpha", 1.5))
|
| 38 |
+
learn = bool(getattr(config, "asentmax_learn_temp", True))
|
| 39 |
+
init_temp = float(getattr(config, "asentmax_init_temp", 1.0))
|
| 40 |
+
log_t = torch.full((self.num_heads, 1, 1), math.log(init_temp), dtype=torch.float32)
|
| 41 |
+
if learn:
|
| 42 |
+
self.log_temp = nn.Parameter(log_t)
|
| 43 |
+
else:
|
| 44 |
+
self.register_buffer("log_temp", log_t, persistent=False)
|
| 45 |
+
self.dense_mode = False
|
| 46 |
+
|
| 47 |
+
def _entmax(self, scores: torch.Tensor) -> torch.Tensor:
|
| 48 |
+
if abs(self.alpha - 1.5) < 1e-6:
|
| 49 |
+
return entmax15(scores, dim=-1)
|
| 50 |
+
return entmax_bisect(scores, alpha=self.alpha, dim=-1)
|
| 51 |
+
|
| 52 |
+
def forward(
|
| 53 |
+
self,
|
| 54 |
+
hidden_states: torch.Tensor,
|
| 55 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 56 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 57 |
+
past_key_value: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
|
| 58 |
+
use_cache: bool = False,
|
| 59 |
+
output_attentions: bool = False,
|
| 60 |
+
):
|
| 61 |
+
B, T, _ = hidden_states.size()
|
| 62 |
+
|
| 63 |
+
q = self.q_proj(hidden_states).view(B, T, self.num_heads, self.head_dim).transpose(1, 2)
|
| 64 |
+
k = self.k_proj(hidden_states).view(B, T, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 65 |
+
v = self.v_proj(hidden_states).view(B, T, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 66 |
+
|
| 67 |
+
if self.qk_norm == "on":
|
| 68 |
+
q = self.q_norm(q)
|
| 69 |
+
k = self.k_norm(k)
|
| 70 |
+
if self.qk_norm == "off" or self._use_query_temperature:
|
| 71 |
+
q = q * self._query_temperature_scale.to(dtype=q.dtype)
|
| 72 |
+
cos, sin = self.rotary_emb(v, position_ids)
|
| 73 |
+
q, k = apply_rotary_pos_emb(q, k, cos, sin)
|
| 74 |
+
|
| 75 |
+
k = self._repeat_kv(k, self.num_key_value_groups)
|
| 76 |
+
v = self._repeat_kv(v, self.num_key_value_groups)
|
| 77 |
+
|
| 78 |
+
scale = 1.0 / math.sqrt(self.head_dim)
|
| 79 |
+
scores = torch.matmul(q, k.transpose(-2, -1)) * scale # [B,H,T,T]
|
| 80 |
+
temp = torch.exp(self.log_temp) # [H,1,1]
|
| 81 |
+
scores = scores * temp # learnable temperature
|
| 82 |
+
|
| 83 |
+
qpos = torch.arange(T, device=q.device)
|
| 84 |
+
causal = qpos[None, :] <= qpos[:, None] # [T,T]
|
| 85 |
+
# large finite negative (not -inf) so entmax stays numerically safe
|
| 86 |
+
scores = scores.float().masked_fill(~causal[None, None], -1e9)
|
| 87 |
+
|
| 88 |
+
p = self._entmax(scores).to(v.dtype) # exact zeros -> sparse
|
| 89 |
+
out = torch.matmul(p, v)
|
| 90 |
+
out = out.transpose(1, 2).contiguous().reshape(B, T, self.attention_hidden_size)
|
| 91 |
+
return self.o_proj(out), None, None
|
epfl_final/SparseAtt/sparseatt/attention.py
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Qwen3 Attention Module.
|
| 3 |
+
|
| 4 |
+
This file is kept separate for easy modification during token pruning experiments.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from typing import Optional, Tuple
|
| 8 |
+
import math
|
| 9 |
+
|
| 10 |
+
import torch
|
| 11 |
+
import torch.nn as nn
|
| 12 |
+
import torch.nn.functional as F
|
| 13 |
+
|
| 14 |
+
try:
|
| 15 |
+
from torch.nn.attention.flex_attention import create_block_mask, flex_attention
|
| 16 |
+
except ImportError:
|
| 17 |
+
create_block_mask = flex_attention = None
|
| 18 |
+
|
| 19 |
+
from .config import Qwen3Config
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def alibi_slopes(num_heads: int) -> torch.Tensor:
|
| 23 |
+
"""Press et al. slopes: 1/2, 1/4, ..., 2**(-8) for eight heads."""
|
| 24 |
+
return torch.pow(2.0, -8.0 * torch.arange(1, num_heads + 1, dtype=torch.float32) / num_heads)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _alibi_causal_mask(b, h, q_idx, kv_idx):
|
| 28 |
+
return q_idx >= kv_idx
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _alibi_score_mod(num_heads: int):
|
| 32 |
+
# q/k indices and h are scalar symbolic tensors under FlexAttention. This
|
| 33 |
+
# produces no LxL bias tensor; tau scales Q only and therefore never this term.
|
| 34 |
+
def score_mod(score, b, h, q_idx, kv_idx):
|
| 35 |
+
slope = 2.0 ** (-8.0 * (h + 1) / num_heads)
|
| 36 |
+
return score + slope * (kv_idx - q_idx)
|
| 37 |
+
return score_mod
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class Qwen3RMSNorm(nn.Module):
|
| 41 |
+
"""RMS Normalization used in Qwen3."""
|
| 42 |
+
|
| 43 |
+
def __init__(self, hidden_size: int, eps: float = 1e-6, weight_fp32: bool = False):
|
| 44 |
+
super().__init__()
|
| 45 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 46 |
+
self.eps = eps
|
| 47 |
+
self.weight_fp32 = weight_fp32
|
| 48 |
+
self._eval_temperature: Optional[float] = None
|
| 49 |
+
|
| 50 |
+
def set_eval_temperature(self, tau: float) -> None:
|
| 51 |
+
"""Apply an eval-only Q gain scale before its activation-dtype cast."""
|
| 52 |
+
self._eval_temperature = float(tau)
|
| 53 |
+
|
| 54 |
+
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
| 55 |
+
input_dtype = hidden_states.dtype
|
| 56 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 57 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 58 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.eps)
|
| 59 |
+
# QK gains can be deliberate FP32 master parameters while all model
|
| 60 |
+
# activations stay bf16. Casting here preserves fp32 optimizer updates
|
| 61 |
+
# without promoting the attention activations.
|
| 62 |
+
weight = self.weight if self._eval_temperature is None else self.weight / self._eval_temperature
|
| 63 |
+
return weight.to(input_dtype) * hidden_states.to(input_dtype)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class Qwen3RotaryEmbedding(nn.Module):
|
| 67 |
+
"""Rotary Position Embedding for Qwen3."""
|
| 68 |
+
|
| 69 |
+
def __init__(
|
| 70 |
+
self,
|
| 71 |
+
dim: int,
|
| 72 |
+
max_position_embeddings: int = 32768,
|
| 73 |
+
base: float = 1000000.0,
|
| 74 |
+
train_position_scale_set: Optional[list[float]] = None,
|
| 75 |
+
device: Optional[torch.device] = None,
|
| 76 |
+
):
|
| 77 |
+
super().__init__()
|
| 78 |
+
self.dim = dim
|
| 79 |
+
self.max_position_embeddings = max_position_embeddings
|
| 80 |
+
self.base = base
|
| 81 |
+
|
| 82 |
+
raw_scales = train_position_scale_set or []
|
| 83 |
+
scales = [float(scale) for scale in raw_scales]
|
| 84 |
+
if any(not torch.isfinite(torch.tensor(scale)) or scale <= 0.0 for scale in scales):
|
| 85 |
+
raise ValueError("rope_train_position_scale_set must contain finite positive values")
|
| 86 |
+
self.register_buffer(
|
| 87 |
+
"train_position_scales",
|
| 88 |
+
torch.tensor(scales, dtype=torch.float32, device=device),
|
| 89 |
+
persistent=False,
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
inv_freq = 1.0 / (
|
| 93 |
+
self.base ** (torch.arange(0, self.dim, 2, dtype=torch.float32, device=device) / self.dim)
|
| 94 |
+
)
|
| 95 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 96 |
+
|
| 97 |
+
@torch.no_grad()
|
| 98 |
+
def forward(
|
| 99 |
+
self, x: torch.Tensor, position_ids: torch.Tensor
|
| 100 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 101 |
+
# Mixed sparse training resamples a mask (and therefore its realised
|
| 102 |
+
# key-distance distribution) independently in every layer. This dense
|
| 103 |
+
# control mirrors only that positional exposure: each layer samples one
|
| 104 |
+
# scalar for the whole micro-batch, while all attention links remain
|
| 105 |
+
# present. Eval is deliberately untouched.
|
| 106 |
+
if self.training and self.train_position_scales.numel() > 0:
|
| 107 |
+
scale_idx = torch.randint(
|
| 108 |
+
self.train_position_scales.numel(),
|
| 109 |
+
(1,),
|
| 110 |
+
device=position_ids.device,
|
| 111 |
+
)
|
| 112 |
+
position_ids = position_ids.float() * self.train_position_scales[scale_idx]
|
| 113 |
+
inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
|
| 114 |
+
position_ids_expanded = position_ids[:, None, :].float()
|
| 115 |
+
|
| 116 |
+
device_type = x.device.type
|
| 117 |
+
with torch.autocast(device_type=device_type, enabled=False):
|
| 118 |
+
freqs = (inv_freq_expanded @ position_ids_expanded).transpose(1, 2)
|
| 119 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 120 |
+
cos = emb.cos()
|
| 121 |
+
sin = emb.sin()
|
| 122 |
+
|
| 123 |
+
return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
def rotate_half(x: torch.Tensor) -> torch.Tensor:
|
| 127 |
+
"""Rotates half the hidden dims of the input."""
|
| 128 |
+
x1 = x[..., : x.shape[-1] // 2]
|
| 129 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
| 130 |
+
return torch.cat((-x2, x1), dim=-1)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def apply_rotary_pos_emb(
|
| 134 |
+
q: torch.Tensor,
|
| 135 |
+
k: torch.Tensor,
|
| 136 |
+
cos: torch.Tensor,
|
| 137 |
+
sin: torch.Tensor,
|
| 138 |
+
unsqueeze_dim: int = 1,
|
| 139 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 140 |
+
"""Applies Rotary Position Embedding to the query and key tensors."""
|
| 141 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 142 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 143 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
| 144 |
+
k_embed = (k * cos) + (rotate_half(k) * sin)
|
| 145 |
+
return q_embed, k_embed
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
class Qwen3Attention(nn.Module):
|
| 149 |
+
"""Multi-head attention with Grouped Query Attention (GQA) support."""
|
| 150 |
+
|
| 151 |
+
def __init__(self, config: Qwen3Config, layer_idx: int):
|
| 152 |
+
super().__init__()
|
| 153 |
+
self.config = config
|
| 154 |
+
self.layer_idx = layer_idx
|
| 155 |
+
|
| 156 |
+
self.hidden_size = config.hidden_size
|
| 157 |
+
self.num_heads = config.num_attention_heads
|
| 158 |
+
self.head_dim = config.head_dim
|
| 159 |
+
self.num_key_value_heads = config.num_key_value_heads
|
| 160 |
+
self.num_key_value_groups = self.num_heads // self.num_key_value_heads
|
| 161 |
+
self.attention_dropout = config.attention_dropout
|
| 162 |
+
self.positional = config.positional
|
| 163 |
+
self.qk_norm = str(getattr(config, "qk_norm", "on")).lower()
|
| 164 |
+
self.qk_gain_fp32 = bool(getattr(config, "qk_gain_fp32", False))
|
| 165 |
+
if self.qk_norm not in ("on", "off"):
|
| 166 |
+
raise ValueError(f"unsupported qk_norm mode: {self.qk_norm}")
|
| 167 |
+
if self.positional not in ("rope", "alibi"):
|
| 168 |
+
raise ValueError(f"unsupported positional mode: {self.positional}")
|
| 169 |
+
|
| 170 |
+
# Attention output dimension is num_heads * head_dim
|
| 171 |
+
self.attention_hidden_size = self.num_heads * self.head_dim
|
| 172 |
+
|
| 173 |
+
self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=config.attention_bias)
|
| 174 |
+
self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
|
| 175 |
+
self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
|
| 176 |
+
self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=config.attention_bias)
|
| 177 |
+
|
| 178 |
+
self.rotary_emb = Qwen3RotaryEmbedding(
|
| 179 |
+
self.head_dim,
|
| 180 |
+
max_position_embeddings=config.max_position_embeddings,
|
| 181 |
+
base=config.rope_theta,
|
| 182 |
+
train_position_scale_set=config.rope_train_position_scale_set,
|
| 183 |
+
)
|
| 184 |
+
self.register_buffer("alibi_slopes", alibi_slopes(self.num_heads), persistent=False)
|
| 185 |
+
self._alibi_masks = {}
|
| 186 |
+
self._alibi_score_mod = _alibi_score_mod(self.num_heads) if self.positional == "alibi" else None
|
| 187 |
+
|
| 188 |
+
# For Qwen3, q_norm and k_norm are per layer. The explicit ``off``
|
| 189 |
+
# regime removes the modules entirely, rather than leaving identity
|
| 190 |
+
# modules in the state dict. The default remains the legacy path.
|
| 191 |
+
if self.qk_norm == "on":
|
| 192 |
+
self.q_norm = Qwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps, weight_fp32=self.qk_gain_fp32)
|
| 193 |
+
self.k_norm = Qwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps, weight_fp32=self.qk_gain_fp32)
|
| 194 |
+
# Evaluation-only temperature for qk_norm=off. It is a non-persistent
|
| 195 |
+
# buffer so no checkpoint weights are touched and compiled graphs can
|
| 196 |
+
# reuse the same shape/static graph across temperatures.
|
| 197 |
+
self.register_buffer("_query_temperature_scale", torch.ones((), dtype=torch.float32), persistent=False)
|
| 198 |
+
# Eval-only diagnostic. When positive, sample this many causal query
|
| 199 |
+
# positions and retain head-averaged attention entropy. The default is
|
| 200 |
+
# disabled and therefore leaves training/evaluation behavior unchanged.
|
| 201 |
+
self.entropy_probe_queries = 0
|
| 202 |
+
self.last_entropy_probe = None
|
| 203 |
+
self._use_query_temperature = False
|
| 204 |
+
|
| 205 |
+
@torch.no_grad()
|
| 206 |
+
def set_attention_temperature(self, tau: float) -> None:
|
| 207 |
+
"""Set the query-side temperature without changing learned weights.
|
| 208 |
+
|
| 209 |
+
This is the temperature path for qk_norm=off and is also exposed for
|
| 210 |
+
equivalence checks on qk_norm=on checkpoints.
|
| 211 |
+
"""
|
| 212 |
+
tau = float(tau)
|
| 213 |
+
if not math.isfinite(tau) or tau <= 0.0:
|
| 214 |
+
raise ValueError("attention temperature must be finite and > 0")
|
| 215 |
+
if self.qk_norm == "on":
|
| 216 |
+
# This is algebraically query-side scaling, but applying it before
|
| 217 |
+
# the bf16 activation cast matches the learned-gain division path
|
| 218 |
+
# exactly without mutating a checkpoint parameter.
|
| 219 |
+
self.q_norm.set_eval_temperature(tau)
|
| 220 |
+
self._use_query_temperature = False
|
| 221 |
+
else:
|
| 222 |
+
self._query_temperature_scale.fill_(1.0 / tau)
|
| 223 |
+
self._use_query_temperature = True
|
| 224 |
+
|
| 225 |
+
@torch.no_grad()
|
| 226 |
+
def _measure_attention_entropy(self, query_states, key_states):
|
| 227 |
+
seq_len = query_states.shape[2]
|
| 228 |
+
count = min(int(self.entropy_probe_queries), seq_len)
|
| 229 |
+
# Include short and long prefixes while avoiding the degenerate first token.
|
| 230 |
+
positions = torch.linspace(1, seq_len - 1, count, device=query_states.device).round().long().unique()
|
| 231 |
+
kt = key_states.transpose(-1, -2)
|
| 232 |
+
records = []
|
| 233 |
+
for chunk in positions.split(4):
|
| 234 |
+
q = query_states.index_select(2, chunk)
|
| 235 |
+
scores = torch.matmul(q, kt) / math.sqrt(self.head_dim)
|
| 236 |
+
keys = torch.arange(seq_len, device=scores.device)
|
| 237 |
+
allowed = keys[None, None, None, :] <= chunk[None, None, :, None]
|
| 238 |
+
scores = scores.float().masked_fill(~allowed, float('-inf'))
|
| 239 |
+
logz = torch.logsumexp(scores, dim=-1)
|
| 240 |
+
probs = torch.softmax(scores, dim=-1)
|
| 241 |
+
entropy = logz - torch.sum(probs * scores.masked_fill(~allowed, 0.0), dim=-1)
|
| 242 |
+
mean_heads = entropy.mean(dim=(0, 1)).cpu().tolist()
|
| 243 |
+
records.extend((int(pos), int(pos)+1, float(ent)) for pos,ent in zip(chunk.cpu().tolist(),mean_heads))
|
| 244 |
+
del q,scores,allowed,logz,probs,entropy
|
| 245 |
+
self.last_entropy_probe = records
|
| 246 |
+
|
| 247 |
+
def forward(
|
| 248 |
+
self,
|
| 249 |
+
hidden_states: torch.Tensor,
|
| 250 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 251 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 252 |
+
past_key_value: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
|
| 253 |
+
use_cache: bool = False,
|
| 254 |
+
output_attentions: bool = False,
|
| 255 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor, torch.Tensor]]]:
|
| 256 |
+
batch_size, seq_len, _ = hidden_states.size()
|
| 257 |
+
|
| 258 |
+
# Project Q, K, V
|
| 259 |
+
query_states = self.q_proj(hidden_states)
|
| 260 |
+
key_states = self.k_proj(hidden_states)
|
| 261 |
+
value_states = self.v_proj(hidden_states)
|
| 262 |
+
|
| 263 |
+
# Reshape for multi-head attention
|
| 264 |
+
query_states = query_states.view(batch_size, seq_len, self.num_heads, self.head_dim).transpose(1, 2)
|
| 265 |
+
key_states = key_states.view(batch_size, seq_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 266 |
+
value_states = value_states.view(batch_size, seq_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 267 |
+
|
| 268 |
+
# Apply Q/K normalisation when enabled. In the no-QK-norm regime the
|
| 269 |
+
# projections go straight to RoPE/logits, with only the evaluation-time
|
| 270 |
+
# query-side temperature scale below.
|
| 271 |
+
if self.qk_norm == "on":
|
| 272 |
+
query_states = self.q_norm(query_states)
|
| 273 |
+
key_states = self.k_norm(key_states)
|
| 274 |
+
if self.qk_norm == "off" or self._use_query_temperature:
|
| 275 |
+
query_states = query_states * self._query_temperature_scale.to(dtype=query_states.dtype)
|
| 276 |
+
|
| 277 |
+
# RoPE and ALiBi are mutually exclusive. ALiBi is added by FlexAttention
|
| 278 |
+
# after QK scaling, so changing q_norm for temperature rescales content only.
|
| 279 |
+
if self.positional == "rope":
|
| 280 |
+
cos, sin = self.rotary_emb(value_states, position_ids)
|
| 281 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
|
| 282 |
+
|
| 283 |
+
# Handle KV cache - store keys/values BEFORE repeating for GQA
|
| 284 |
+
if past_key_value is not None:
|
| 285 |
+
past_key, past_value = past_key_value
|
| 286 |
+
key_states = torch.cat([past_key, key_states], dim=2)
|
| 287 |
+
value_states = torch.cat([past_value, value_states], dim=2)
|
| 288 |
+
|
| 289 |
+
if use_cache:
|
| 290 |
+
present_key_value = (key_states, value_states)
|
| 291 |
+
else:
|
| 292 |
+
present_key_value = None
|
| 293 |
+
|
| 294 |
+
key_states = self._repeat_kv(key_states, self.num_key_value_groups)
|
| 295 |
+
value_states = self._repeat_kv(value_states, self.num_key_value_groups)
|
| 296 |
+
|
| 297 |
+
if self.entropy_probe_queries:
|
| 298 |
+
self._measure_attention_entropy(query_states, key_states)
|
| 299 |
+
|
| 300 |
+
if self.positional == "alibi":
|
| 301 |
+
if flex_attention is None or create_block_mask is None:
|
| 302 |
+
raise ImportError("ALiBi requires torch FlexAttention support")
|
| 303 |
+
if attention_mask is not None or past_key_value is not None:
|
| 304 |
+
raise ValueError("ALiBi currently requires packed causal batches without a KV cache")
|
| 305 |
+
key = (seq_len, query_states.device)
|
| 306 |
+
block_mask = self._alibi_masks.get(key)
|
| 307 |
+
if block_mask is None:
|
| 308 |
+
block_mask = create_block_mask(_alibi_causal_mask, B=None, H=None, Q_LEN=seq_len, KV_LEN=seq_len, device=query_states.device)
|
| 309 |
+
self._alibi_masks[key] = block_mask
|
| 310 |
+
attn_output = flex_attention(query_states, key_states, value_states, score_mod=self._alibi_score_mod, block_mask=block_mask, enable_gqa=False, kernel_options={"BACKEND": "TRITON"})
|
| 311 |
+
else:
|
| 312 |
+
attn_output = F.scaled_dot_product_attention(
|
| 313 |
+
query_states, key_states, value_states, attn_mask=attention_mask,
|
| 314 |
+
dropout_p=self.attention_dropout if self.training else 0.0,
|
| 315 |
+
is_causal=attention_mask is None)
|
| 316 |
+
|
| 317 |
+
attn_weights = None # SDPA doesn't materialize weights, saving massive memory
|
| 318 |
+
|
| 319 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 320 |
+
attn_output = attn_output.reshape(batch_size, seq_len, self.attention_hidden_size)
|
| 321 |
+
|
| 322 |
+
# Output projection
|
| 323 |
+
attn_output = self.o_proj(attn_output)
|
| 324 |
+
|
| 325 |
+
if not output_attentions:
|
| 326 |
+
attn_weights = None
|
| 327 |
+
|
| 328 |
+
return attn_output, attn_weights, present_key_value
|
| 329 |
+
|
| 330 |
+
@staticmethod
|
| 331 |
+
def _repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
| 332 |
+
"""Repeat KV heads to match the number of query heads for GQA."""
|
| 333 |
+
if n_rep == 1:
|
| 334 |
+
return hidden_states
|
| 335 |
+
batch, num_kv_heads, slen, head_dim = hidden_states.shape
|
| 336 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_kv_heads, n_rep, slen, head_dim)
|
| 337 |
+
return hidden_states.reshape(batch, num_kv_heads * n_rep, slen, head_dim)
|
| 338 |
+
|
epfl_final/SparseAtt/sparseatt/config.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Qwen3 Model Configuration.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from dataclasses import dataclass, field
|
| 6 |
+
from typing import List, Optional
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
@dataclass
|
| 10 |
+
class Qwen3Config:
|
| 11 |
+
"""Configuration class for Qwen3 model."""
|
| 12 |
+
vocab_size: int = 151936
|
| 13 |
+
hidden_size: int = 1024
|
| 14 |
+
intermediate_size: int = 3072
|
| 15 |
+
num_hidden_layers: int = 28
|
| 16 |
+
num_attention_heads: int = 16
|
| 17 |
+
num_key_value_heads: int = 8
|
| 18 |
+
head_dim: int = 128
|
| 19 |
+
hidden_act: str = "silu"
|
| 20 |
+
max_position_embeddings: int = 32768
|
| 21 |
+
initializer_range: float = 0.02
|
| 22 |
+
rms_norm_eps: float = 1e-6
|
| 23 |
+
use_cache: bool = True
|
| 24 |
+
tie_word_embeddings: bool = True
|
| 25 |
+
rope_theta: float = 1000000.0
|
| 26 |
+
rope_scaling: Optional[dict] = None
|
| 27 |
+
# ``rope`` (default) preserves legacy behavior; ``alibi`` disables RoPE
|
| 28 |
+
# and applies Press et al. head-specific causal distance biases.
|
| 29 |
+
positional: str = "rope"
|
| 30 |
+
# QK normalisation is part of the published Qwen3-style attention path.
|
| 31 |
+
# Keep it on by default so checkpoints/configs written before this flag are
|
| 32 |
+
# bit-identical; ``off`` removes both per-head RMSNorm modules.
|
| 33 |
+
qk_norm: str = "on"
|
| 34 |
+
# Keep Q/K RMSNorm gains and their AdamW state in FP32 during training.
|
| 35 |
+
qk_gain_fp32: bool = False
|
| 36 |
+
# Training-only RoPE position scales. When non-empty, every attention layer
|
| 37 |
+
# independently samples one scale per forward pass. Evaluation always uses
|
| 38 |
+
# the standard scale 1.0. This provides a dense positional-augmentation
|
| 39 |
+
# control without deleting attention links.
|
| 40 |
+
rope_train_position_scale_set: Optional[List[float]] = None
|
| 41 |
+
attention_bias: bool = False
|
| 42 |
+
attention_dropout: float = 0.0
|
| 43 |
+
bos_token_id: int = 151643
|
| 44 |
+
eos_token_id: int = 151643
|
| 45 |
+
checkpoint_activations: bool = False
|
| 46 |
+
attention_type: str = "dense"
|
| 47 |
+
sparse_block_size: int = 128
|
| 48 |
+
sparse_num_random_blocks: int = 1
|
| 49 |
+
sparse_mask_pool_size: int = 1000
|
| 50 |
+
sparse_max_seq_length: int = 1024
|
| 51 |
+
# When set, only the listed layer indices use sparse attention; all others use dense.
|
| 52 |
+
# When None (default), attention_type applies to all layers uniformly.
|
| 53 |
+
sparse_layer_indices: Optional[List[int]] = None
|
| 54 |
+
# Directory to cache pre-built block masks (one file per layer). If None, masks are rebuilt every run.
|
| 55 |
+
sparse_mask_cache_dir: Optional[str] = None
|
| 56 |
+
# Seed offset for the frozen (pool_size=1) fixed mask. 0 = legacy (layer-index only).
|
| 57 |
+
# Distinct values yield distinct fixed masks (fixed-mask seeds).
|
| 58 |
+
sparse_mask_seed: int = 0
|
| 59 |
+
# Mixed-sparsity training: if set to a non-empty list, each mask-pool entry draws its
|
| 60 |
+
# OWN num_random_blocks uniformly from this set, so the per-step mask (picked at random
|
| 61 |
+
# from the pool) also resamples the sparsity LEVEL. None/empty = legacy fixed-nrb pool.
|
| 62 |
+
# This is the "Mixed" training arm of the paper; without it the arm silently degenerates
|
| 63 |
+
# to a fixed-nrb model.
|
| 64 |
+
sparse_mixed_nrb_set: Optional[List[int]] = None
|
| 65 |
+
# --- deployment-time baselines (learned MoBA + ASEntmax) ---
|
| 66 |
+
# moba_top_k is the per-query block budget used by the top-k deployment ladder.
|
| 67 |
+
moba_block_size: int = 128
|
| 68 |
+
moba_top_k: int = 32
|
| 69 |
+
asentmax_alpha: float = 1.5
|
| 70 |
+
asentmax_learn_temp: bool = True
|
| 71 |
+
asentmax_init_temp: float = 1.0
|
| 72 |
+
|
| 73 |
+
def is_layer_sparse(self, layer_idx: int) -> bool:
|
| 74 |
+
"""Return True if this layer should use sparse stochastic attention."""
|
| 75 |
+
if self.attention_type != "sparse_stochastic":
|
| 76 |
+
return False
|
| 77 |
+
if self.sparse_layer_indices is None:
|
| 78 |
+
return True # all layers sparse (existing behaviour)
|
| 79 |
+
return layer_idx in self.sparse_layer_indices
|
| 80 |
+
|
| 81 |
+
@classmethod
|
| 82 |
+
def from_dict(cls, config_dict: dict) -> "Qwen3Config":
|
| 83 |
+
return cls(**{k: v for k, v in config_dict.items() if k in cls.__dataclass_fields__})
|
| 84 |
+
|
| 85 |
+
@classmethod
|
| 86 |
+
def from_json(cls, path: str) -> "Qwen3Config":
|
| 87 |
+
import json
|
| 88 |
+
with open(path, "r") as f:
|
| 89 |
+
config_dict = json.load(f)
|
| 90 |
+
return cls.from_dict(config_dict)
|