Skip to content

Commit 0627776

Browse files
committed
Revert experiment batch size changes
1 parent 0801877 commit 0627776

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

torchtitan/experiments/forge/engine.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ def __init__(self, config: Config):
133133
dp_degree, dp_rank = 1, 0
134134
self.dp_degree, self.dp_rank = dp_degree, dp_rank
135135

136-
if config.training.global_batch_size < 0:
137-
config.training.global_batch_size = (
138-
config.training.local_batch_size * dp_degree
139-
)
140-
141136
# take control of garbage collection to avoid stragglers
142137
self.gc_handler = utils.GarbageCollection(
143138
gc_freq=config.training.gc_freq, debug=config.training.gc_debug
@@ -186,6 +181,10 @@ def __init__(self, config: Config):
186181

187182
# verify batch sizes
188183
global_batch_size = config.training.global_batch_size
184+
if global_batch_size < 0:
185+
# This global batch size results in 1 gradient accumulation
186+
# step.
187+
global_batch_size = config.training.local_batch_size * dp_degree
189188
assert global_batch_size > 0
190189
assert (
191190
global_batch_size % (config.training.local_batch_size * dp_degree) == 0

torchtitan/experiments/graph_trainer/deepseek_v3/parallelize_autoparallel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ def parallelize_autoparallel_deepseekv3(
161161

162162
def input_fn():
163163
global_batch_size = training.global_batch_size
164+
if global_batch_size < 0:
165+
dp_degree = parallel_dims.dp_replicate * parallel_dims.dp_shard
166+
global_batch_size = training.local_batch_size * dp_degree
164167
tokens = torch.randint(
165168
0,
166169
ap_model.model_args.vocab_size,

torchtitan/experiments/graph_trainer/llama3/parallelize_autoparallel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ def parallelize_autoparallel_llama(
6868

6969
def input_fn():
7070
global_batch_size = training.global_batch_size
71+
if global_batch_size < 0:
72+
dp_degree = parallel_dims.dp_replicate * parallel_dims.dp_shard
73+
global_batch_size = training.local_batch_size * dp_degree
7174
tokens = torch.randint(
7275
0,
7376
model.config.vocab_size,

torchtitan/experiments/torchft/trainer.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ def __init__(self, config: Config):
6969
# FT addition: adjust dp info via ft_manager
7070
batch_degree, batch_rank = self.ft_manager.get_dp_info(batch_degree, batch_rank)
7171

72-
if config.training.global_batch_size < 0:
73-
config.training.global_batch_size = (
74-
config.training.local_batch_size * batch_degree
75-
)
76-
7772
# take control of garbage collection to avoid stragglers
7873
self.gc_handler = utils.GarbageCollection(
7974
gc_freq=config.training.gc_freq, debug=config.training.gc_debug
@@ -165,6 +160,10 @@ def __init__(self, config: Config):
165160

166161
# verify batch sizes
167162
global_batch_size = config.training.global_batch_size
163+
if global_batch_size < 0:
164+
# This global batch size results in 1 gradient accumulation
165+
# step.
166+
global_batch_size = config.training.local_batch_size * batch_degree
168167
assert global_batch_size > 0
169168
assert (
170169
global_batch_size % (config.training.local_batch_size * batch_degree) == 0

0 commit comments

Comments
 (0)