diff options
| author | Void Agent <void@jayrup.hermes> | 2026-08-14 13:21:03 +0100 |
|---|---|---|
| committer | Void Agent <void@jayrup.hermes> | 2026-08-14 13:21:03 +0100 |
| commit | 9fecbe58cc0750e9e39b261a672b0c6e85e6ed4e (patch) | |
| tree | cfcf24545a0249b7b206a66eaae7f44c587f9709 /src/model_api.py | |
| parent | 9c50f31c66e788ff08eeac83f84e90e9bc1a921e (diff) | |
fix codex BLOCKERs: global fixed layout invariance, min_steps off-by-one, integers EOS alias, rerun guard, eval prereg-literal codes + dual-checkpoint honesty; +7 regression tests
Diffstat (limited to 'src/model_api.py')
| -rw-r--r-- | src/model_api.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/model_api.py b/src/model_api.py index 66c2ace..31ffe31 100644 --- a/src/model_api.py +++ b/src/model_api.py @@ -3,6 +3,7 @@ import torch import torch.nn as nn from src.config import Config +from src.data import pad_inputs class PrimeModel(nn.Module): @@ -27,7 +28,11 @@ def build_model(cfg: Config) -> PrimeModel: @torch.no_grad() def greedy_decode(model: PrimeModel, x: torch.Tensor, cfg: Config, max_len: int | None = None) -> torch.Tensor: - """Autoregressive greedy decode of output digits. Returns (B, max_len) tokens (BOS stripped).""" + """Autoregressive greedy decode of output digits. Returns (B, max_len) tokens (BOS stripped). + + Inputs are LEFT-padded to the global layout so positions match training exactly + (batch/singleton invariance — codex BLOCKER fix).""" + x = pad_inputs(x, cfg) max_len = max_len or cfg.max_out_len B = x.shape[0] y_in = torch.full((B, 1), cfg.eos_id, dtype=torch.long, device=x.device) |
