Repository navigation
delete --disable_loss_parallel flag - #3694
Conversation
[ghstack-poisoned]
| ) | ||
| self.train_context = dist_utils.get_train_context( | ||
| enable_loss_parallel=loss_parallel_enabled, | ||
| enable_loss_parallel=parallel_dims.tp_enabled, |
There was a problem hiding this comment.
remove this flag enable_loss_parallel globally -- it is always enabled
There was a problem hiding this comment.
uhhh reshuffling things a bit while I figure this out but...
- ended up keeping the top-level
disable_loss_parallelflag - require LP for TP trainer (torchft too)
- delete flag from dist_utils.train_context
- renamed sharding config flag to
gather_tp_logits- appears both RL policy trainer & generator expect full logits from lm_head, sois_inferenceis misleading - main blocker is graph trainer - unclear what they want, though no reliance on train_context
No immediate effect, just prepping for next commit. decided not to use `spmd.local_map` to avoid larger refactor Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0) (oldest at bottom): * #3690 * #3673 * #3655 * #3664 * #3654 * #3278 * #3694 * #3472 * __->__ #3632 * #3653
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
ghstack-source-id: ecff90f Pull Request resolved: pytorch/torchtitan#3694
| pred.device_mesh.get_group("tp"), | ||
| pred.shape[-1], | ||
| ) | ||
| else: |
There was a problem hiding this comment.
when would we hit this? We should delete loss_parallel flag.
ghstack-source-id: b026e2a Pull Request resolved: pytorch/torchtitan#3694
tianyu-l
left a comment
There was a problem hiding this comment.
Please remove tp_gather_logits and always do S(-1).
Please let me know if you disagree.
| loss_parallel_enabled = ( | ||
| parallel_dims.tp_enabled and not config.parallelism.disable_loss_parallel | ||
| ) | ||
| loss_parallel_ctx = ( |
There was a problem hiding this comment.
This ctx should be removed since we migrate to megatron-style loss parallel? Can leave a TODO. cc @bobrenjc93
| # model-agnostic `update_from_config` hook (RL's trainer bypasses | ||
| # `torchtitan.Trainer's` call, so we invoke it directly). | ||
| model_spec.model.update_from_config(config=config) | ||
| model_spec.model.update_from_config(config=config, tp_gather_logits=True) |
There was a problem hiding this comment.
instead of doing this, let's change this code to TP dim all-gather
| self.config.update_from_config(config=_InferenceConfig(parallelism=parallelism)) | ||
| self.config.update_from_config( | ||
| config=_InferenceConfig(parallelism=parallelism), | ||
| tp_gather_logits=True, |
There was a problem hiding this comment.
Instead of doing this, let's update the logits = logits.to_local() below to TP dim all-gather.
| else dense_activation_placement(tp=spmd.I) | ||
| ) | ||
| loss_tp = spmd.S(-1) if loss_parallel else spmd.I | ||
| loss_tp = spmd.I if tp_gather_logits else spmd.S(-1) |
There was a problem hiding this comment.
Let's not introduce tp_gather_logits. Instead, let's always do S(-1) and give the all-gather responsibility to RL trainer / generator.
- This matches our vocab parallel embedding behavior
- Even in RL trainer people may want to have complicated chunked loss [RL] - RFC chunked CE loss for RL #3477 (+ potentially loss paralle?)
I feel the scope of such all-gather is pretty limited (right after RL trainer / generator exits), so it's not worth spreading this config everywhere. Hope that makes sense.
ghstack-source-id: 1c8a02e Pull Request resolved: pytorch/torchtitan#3694
[ghstack-poisoned]
ghstack-source-id: b90b4e3 Pull Request resolved: pytorch/torchtitan#3694
…7th sync) Upstream b3b60da removed the --disable_loss_parallel flag: TP-on now always implies loss-parallel-on, with the LP autograd handling moved into cross_entropy_loss (vocab-sharded logits via tp_gather_logits= False). The ParallelismConfig.disable_loss_parallel field is gone, so every ezpz reference to it would TypeError at config construction. Replayed: - agpt/sharding.py + moe/sharding.py: drop loss_parallel kwarg from set_{agpt,moe}_sharding_config and the set_decoder_sharding_config call (matches upstream set_{llama3,deepseek_v3}_sharding_config). - agpt/model.py + moe/model.py: drop loss_parallel=not parallelism. disable_loss_parallel from the sharding-config call sites. - trainer.py: drop loss_parallel_enabled + enable_loss_parallel from get_train_context (upstream get_train_context no longer accepts it). Smoke (job 12469466, rl-monarch-torch213 venv, sunspot 1N, seed=42 --debug.deterministic): agpt_debugmodel loss 10.83863 -> 10.67256, moe_debugmodel loss 12.90956 -> 12.36751, both rc=0. agpt step-1 loss bitwise identical across two runs (12469465, 12469466).
loss migration: loss-parallel custom autograd handling, DTensor local_map / unwrapping, now lives under cross_entropy_loss fn
loss-parallel flag deletion:
loss_parallel()context. Sets model sharding configs to return vocab-sharded logits:tp_gather_logits=Falsetp_gather_logits=TrueStack from ghstack (oldest at bottom):