Andrej Karpathy commited on
Commit ·
aba30cb
1
Parent(s): 83dccc2
tune logit softcap?
Browse files- dev/LOG.md +4 -0
- nanochat/gpt.py +1 -1
dev/LOG.md
CHANGED
|
@@ -4,6 +4,10 @@ A running summary documenting some experiments and findings. Started ~Jan 7 2026
|
|
| 4 |
|
| 5 |
---
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
## 2026-02-19: Mixture of Experts (negative)
|
| 8 |
|
| 9 |
Implemented a DeepSeekV3-style Mixture of Experts layer as a drop-in replacement for the dense MLP. The MoE branch works and improves per-step validation loss, but is not a net improvement on wall clock time due to MoE overhead (at least for our scale of interest of approx GPT-2 capability).
|
|
|
|
| 4 |
|
| 5 |
---
|
| 6 |
|
| 7 |
+
## 2026-03-02: SoftCap tuning
|
| 8 |
+
|
| 9 |
+
Quick experiment to tune logit softcap on d24 scale. Tried 5..30. 5 was terrible, the rest of them were all about equal with the exception of 20, which was the best. Minor but solid improvement: val loss improved by ~1e-3 (0.716 -> 0.715). Setting as default.
|
| 10 |
+
|
| 11 |
## 2026-02-19: Mixture of Experts (negative)
|
| 12 |
|
| 13 |
Implemented a DeepSeekV3-style Mixture of Experts layer as a drop-in replacement for the dense MLP. The MoE branch works and improves per-step validation loss, but is not a net improvement on wall clock time due to MoE overhead (at least for our scale of interest of approx GPT-2 capability).
|
nanochat/gpt.py
CHANGED
|
@@ -407,7 +407,7 @@ class GPT(nn.Module):
|
|
| 407 |
x = norm(x)
|
| 408 |
|
| 409 |
# Forward the lm_head (compute logits)
|
| 410 |
-
softcap =
|
| 411 |
logits = self.lm_head(x) # (B, T, padded_vocab_size) <- very big tensor, large amount of memory
|
| 412 |
logits = logits[..., :self.config.vocab_size] # slice to remove padding
|
| 413 |
logits = logits.float() # switch to fp32 for logit softcap and loss computation
|
|
|
|
| 407 |
x = norm(x)
|
| 408 |
|
| 409 |
# Forward the lm_head (compute logits)
|
| 410 |
+
softcap = 20 # smoothly cap the logits to the range [-softcap, softcap]
|
| 411 |
logits = self.lm_head(x) # (B, T, padded_vocab_size) <- very big tensor, large amount of memory
|
| 412 |
logits = logits[..., :self.config.vocab_size] # slice to remove padding
|
| 413 |
logits = logits.float() # switch to fp32 for logit softcap and loss computation
|