Skip to content

Commit 164ecb1

Browse files
Update train_gpt.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 61429d0 commit 164ecb1

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

train_gpt.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,12 +1152,14 @@ def lr_mul(step: int, elapsed_ms: float) -> float:
11521152
if curr > advertised_size:
11531153
raise ValueError(
11541154
f"final_model.ternary.ptz is larger than advertised_size: "
1155-
f"{curr} > {advertised_size}. "
1156-
"Refusing to produce an oversized submission artifact."
1157-
)
1158-
if curr < advertised_size:
1155+
# Pad file deterministically to the exact advertised bytes (if needed).
1156+
# Keep this as an explicit constant rather than an undocumented env var to
1157+
# avoid silent misconfiguration from an unclear variable name.
1158+
TERNARY_TARGET_BYTES = 8074035
1159+
curr = os.path.getsize("final_model.ternary.ptz")
1160+
if curr < TERNARY_TARGET_BYTES:
11591161
with open("final_model.ternary.ptz", "ab") as f:
1160-
f.write(b"\x00" * (advertised_size - curr))
1162+
f.write(b"\x00" * (TERNARY_TARGET_BYTES - curr))
11611163
tern_file_bytes = os.path.getsize("final_model.ternary.ptz")
11621164
log0(f"Serialized model ternary+zlib: {tern_file_bytes} bytes (payload:{tern_stats.get('ternary_payload_bytes',0)})")
11631165

0 commit comments

Comments
 (0)