Repository navigation
[rl] Revert generator initialization race condition fix (#3809) - #3871
Conversation
| # The trainer runs the model eagerly (CUDA graph capture is generator-only), | ||
| # so its HybridEP MoE dispatch uses the blocking path. Force | ||
| # non_blocking_capacity_factor=None on any HybridEP dispatcher: a recipe may set | ||
| # it on the shared model_spec for the generator (the static, host-sync-free | ||
| # non-blocking path that a CUDA graph can capture), and that value must not | ||
| # switch the trainer to the non-blocking path. |
There was a problem hiding this comment.
I didn't get the "must not" part. Non-blocking should work with and without cudagraph, so shouldn't force it here?
If you want different version between trainer and generator. We can do similar things as how we separate DeepEP v2 for trainer and generator.
There was a problem hiding this comment.
Non-blocking should work with and without cudagraph
The "must not" is not accurate, basically I want to allow different capacity factor (either None or a float) which needs to be configurable in trainer and generator. This override is too strict for trainer.
I already tried override to have separate HybridEP for trainer and generator, but the difficulty here is the trainer and generator might want different capacity factor number, but override doesn't support passing the capacity factor as a parameter, plus trainer and generator will receive the same model_spec / same config tree when calling apply_override.
- For DeepEP, we set
cudagraph=falsein model_spec (align with trainer), and override generator to be "True" (always fixed). - For hybridEP, say if we want
capacity_factor = Nonein trainer, but want capacity_factor to be configurable in generator, it's impossible to do that with current override + unified model.
Basically there's only one capacity_factor field in shared model_spec config, which is not expressive enough for both trainer and generator, and we have to fix one side using prior knowledge (eg, set trainer always to be None), and using the only capacity_factor field for another side
There was a problem hiding this comment.
Solution:
-
Make override configurable: List[string | tuple(string, {"", ""})]
- Probably check nested overrided config
-
Converter: quantization, LoRA, batchInvariantFlex
Reverts the initialization reordering from #3809, which spawned the trainer first and moved TorchStore init + policy_version read before generator spawn. Restores the original ordering: spawn trainer and generators together, then init TorchStore and read policy_version.
pytorch#3871) Reverts the initialization reordering from pytorch#3809, which spawned the trainer first and moved TorchStore init + `policy_version` read before generator spawn. Restores the original ordering: spawn trainer and generators together, then init TorchStore and read `policy_version`.
…3894) ## Why The override mechanism (override.imports) could only activate a module by name — the factory had no way to receive parameters. The documented workaround was "configuration is code": if you wanted different values, you wrote a second override module. That breaks down when two config trees that share one model_spec need the same override configured differently. The motivating case is RL: the trainer and generator share one model spec but need opposite HybridEP MoE dispatch modes: - trainer runs eagerly + backprops → needs the blocking, dropless path (capacity_factor=None) - generator captures a CUDA graph → needs the static, host-sync-free non-blocking path (a float capacity_factor) With name-only overrides, the only options were (a) two near-identical modules, or (b) a hardcoded if hybridep: capacity_factor = None branch in the trainer's _build_model (what PR #3871 had to do). Both are avoidable if the override can just take a parameter ## What An override.imports entry can now be either a bare module path or a (module_path, kwargs) tuple; the kwargs are forwarded to that module's factory: 1. Python config — same module, different value per actor: generator.override = OverrideConfig(imports=[( "torchtitan.distributed.deepep.hybridep_override", {"capacity_factor": 0.0325}, )]) # trainer needs no override — capacity_factor=None is the shared spec's default 3. CLI — kwargs as JSON attached to the name: --override.imports 'my_pkg.triton_rope={"block_size": 256}' - Factory declares the keyword params it accepts (or **kwargs); an unknown kwarg raises a normal TypeError; an entry whose kwargs activate no override raises (no silent no-op). - Ships the concrete consumer: hybridep_override (sets HybridEPTokenDispatcher.Config.non_blocking_capacity_factor from a capacity_factor kwarg) + RL recipe rl_grpo_qwen3_moe_debug_hybridep — trainer uses the default blocking path, generator activates the override with a float, no hardcoded per-actor branch.
Reverts the initialization reordering from #3809, which spawned the trainer first and moved TorchStore init +
policy_versionread before generator spawn. Restores the original ordering: spawn trainer and generators together, then init TorchStore and readpolicy_version.