PR #4912 (2 of 6:
#4801 โ #4912 โ
#5023 โ
#5024 โ
#5025 โ
#5097) ยท
permalinks pinned to head 1cb4fef4 (cited code unchanged at 44035e16) ยท Megatron-LM at the repo's pin e0a4bfed
backend: megatron builds one MegatronGeneration: one inference policy over the whole inference cluster, joined to the weight refit as one block.dynamo: true, a new sibling class builds one MegatronGeneration per prefill or decode engine, each on its own one-node cluster, and fans every refit call out to them. Rollouts stay refused until #5025.Two pages on this PR, one question each โ this one: what the new class does next to the old one. The stack's first PR has its own page: where the Dynamo switch sits.
The new class, MegatronDynamoGeneration, is not a subclass of MegatronGeneration. It holds several of them. megatron_generation_cls picks it when dynamo: true. The example below uses 16 trainer ranks and one inference node of 8 GPUs, split as 1 prefill engine at TP 4 and 2 decode engines at TP 2.
Where they meet: each Dynamo engine is a plain MegatronGeneration built from a copied config, so the worker code is the same. They split in exactly three
hooks on the worker โ
extra config fields, which engine class to build, and where the coordinator listens. The plain worker returns the old answers; MegatronDynamoGenerationMixin returns the Dynamo ones.
๐ฌ review comment C3 โ dynamo_worker_mixin.py:80 C10 โ one worker class C13 โ names
Before (MegatronGeneration) | This PR (MegatronDynamoGeneration) | |
|---|---|---|
| Inference worlds | 1, over the whole inference cluster | 1 per engine, each on one node; engines may differ in TP |
| Weights at start | loaded at build | none until the first refit (skip_weight_load=True) |
| Refit ranks | one block after the trainers | engine i starts after the trainers plus the widths of engines before it |
| Failed suspend | the error goes up | tries to resume every engine, then the error goes up |
| Pickled copy (sent to the controller) | the whole object | records and worker handles only; it can drive a refit but cannot shut an engine down |
Before: one block
# driver / controller, one call def init_collective(ip, port, world_size=24): policy.init_collective(ip, port, world_size) # all 8 workers, ranks 16..23
This PR: one call per engine
# driver / controller, one call each, in engine order def init_collective(ip, port, world_size=24, train_world_size=16): offsets = engine_rank_offsets(16) # [16, 20, 22] from widths (4, 2, 2) for engine, off in zip(engines, offsets): engine.workers.init_collective(..., rank_offset=off) # prefill-0: 16..19, decode-0: 20..21, decode-1: 22..23