p0c: pass attn_implementation via config (transformers 5.0 break)
Browse files- probes/p0c_fp16_ddp_probe.py +11 -4
probes/p0c_fp16_ddp_probe.py
CHANGED
|
@@ -55,8 +55,14 @@ CFG = LlamaConfig(
|
|
| 55 |
|
| 56 |
|
| 57 |
def make_model(attn="sdpa"):
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
def n_params(m):
|
|
@@ -211,9 +217,10 @@ torch.cuda.set_device(rank)
|
|
| 211 |
H, NL, NH, NKV, FF, VOCAB, SEQ = 768, 12, 12, 3, 2048, 50257, 1024
|
| 212 |
cfg = LlamaConfig(hidden_size=H, num_hidden_layers=NL, num_attention_heads=NH,
|
| 213 |
num_key_value_heads=NKV, intermediate_size=FF, vocab_size=VOCAB,
|
| 214 |
-
max_position_embeddings=SEQ, tie_word_embeddings=True
|
|
|
|
| 215 |
torch.manual_seed(1234)
|
| 216 |
-
model = LlamaForCausalLM(cfg
|
| 217 |
model = DDP(model, device_ids=[rank])
|
| 218 |
opt = torch.optim.AdamW(model.parameters(), lr=3e-4)
|
| 219 |
scaler = torch.amp.GradScaler("cuda")
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
def make_model(attn="sdpa"):
|
| 58 |
+
# transformers 5.0 removed `attn_implementation` from PreTrainedModel.__init__ -- passing it
|
| 59 |
+
# there raises TypeError (this is what killed probe C's first attempt). It is a config field.
|
| 60 |
+
cfg = LlamaConfig(
|
| 61 |
+
hidden_size=H, num_hidden_layers=NL, num_attention_heads=NH, num_key_value_heads=NKV,
|
| 62 |
+
intermediate_size=FF, vocab_size=VOCAB, max_position_embeddings=SEQ,
|
| 63 |
+
tie_word_embeddings=True, attn_implementation=attn,
|
| 64 |
+
)
|
| 65 |
+
return LlamaForCausalLM(cfg).cuda()
|
| 66 |
|
| 67 |
|
| 68 |
def n_params(m):
|
|
|
|
| 217 |
H, NL, NH, NKV, FF, VOCAB, SEQ = 768, 12, 12, 3, 2048, 50257, 1024
|
| 218 |
cfg = LlamaConfig(hidden_size=H, num_hidden_layers=NL, num_attention_heads=NH,
|
| 219 |
num_key_value_heads=NKV, intermediate_size=FF, vocab_size=VOCAB,
|
| 220 |
+
max_position_embeddings=SEQ, tie_word_embeddings=True,
|
| 221 |
+
attn_implementation="sdpa")
|
| 222 |
torch.manual_seed(1234)
|
| 223 |
+
model = LlamaForCausalLM(cfg).cuda().to(torch.float32)
|
| 224 |
model = DDP(model, device_ids=[rank])
|
| 225 |
opt = torch.optim.AdamW(model.parameters(), lr=3e-4)
|
| 226 |
scaler = torch.amp.GradScaler("cuda")
|