Skip to content

Commit a95f88f

Browse files
committed
refactor(args): validate the page-cache cap inside the Megatron stream branch
The cap's checks ran before the block that still allows torchtitan streaming. The non-negative check now sits in the Adam branch, and one assert after the Megatron branch rejects the cap everywhere else.
1 parent e7c731c commit a95f88f

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

‎miles/utils/arguments.py‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,17 +1375,6 @@ def miles_validate_args(args):
13751375
f"chunk={args.offload_train_disk_chunk_mb}MB"
13761376
)
13771377

1378-
if args.stream_optimizer_state_page_cache_mb is not None:
1379-
assert args.stream_optimizer_state_to_disk, (
1380-
"--stream-optimizer-state-page-cache-mb caps the page cache of the streamed optimizer state; "
1381-
"it needs --stream-optimizer-state-to-disk"
1382-
)
1383-
assert args.stream_optimizer_state_page_cache_mb >= 0, "--stream-optimizer-state-page-cache-mb must be >= 0"
1384-
assert args.train_backend == "megatron", (
1385-
"--stream-optimizer-state-page-cache-mb caps the Megatron Adam bucket store; "
1386-
"it is not supported on other backends"
1387-
)
1388-
13891378
if args.stream_optimizer_state_to_disk:
13901379
assert args.train_backend in (
13911380
"megatron",
@@ -1421,6 +1410,9 @@ def miles_validate_args(args):
14211410
"file-backed mappings the chunked offloader owns"
14221411
)
14231412
else:
1413+
assert (
1414+
args.stream_optimizer_state_page_cache_mb is None or args.stream_optimizer_state_page_cache_mb >= 0
1415+
), "--stream-optimizer-state-page-cache-mb must be >= 0"
14241416
assert (
14251417
args.use_distributed_optimizer
14261418
), "--stream-optimizer-state-to-disk requires the distributed optimizer"
@@ -1469,6 +1461,11 @@ def miles_validate_args(args):
14691461
f"chunk={args.offload_train_disk_chunk_mb}MB, moments={args.stream_optimizer_state_moment_dtype}, "
14701462
f"page cache {'left to the kernel' if page_cache_mb is None else f'capped at {page_cache_mb}MB'}"
14711463
)
1464+
else:
1465+
assert args.stream_optimizer_state_page_cache_mb is None, (
1466+
"--stream-optimizer-state-page-cache-mb caps the Megatron Adam bucket store; it needs "
1467+
"--stream-optimizer-state-to-disk and is not supported on other backends"
1468+
)
14721469

14731470
if args.async_max_concurrent_samples is not None:
14741471
assert args.async_max_concurrent_samples >= args.n_samples_per_prompt, (

0 commit comments

Comments
 (0)