Why every prefill/decode engine fails to build at the pinned Megatron-LM

PR #4912 (2 of 6) ยท RL head 1cb4fef4 (cited code unchanged at 44035e16) ยท Megatron-LM pinned at e0a4bfed (through Megatron-Bridge ae0a1b02)

Before
No Megatron engine passes a role to Megatron-LM's inference config.
This PR
Each prefill/decode engine adds disaggregation_role to that config. The field exists only in a Megatron-LM commit newer than the one the repo installs.
Status
Open โ€” not fixed in this PR, and no later PR in the stack moves the pin. Review comment C3 asks for a clear startup error (a guard), not a Megatron-LM bump in this PR. Nothing has run on a GPU yet, which is why no test has caught it.

Two pages on this PR, one question each โ€” this one: why the engine build fails, and what fixes it.

The Dynamo worker adds two fields to Megatron-LM's engine config through _inference_config_overrides(). The worker merges them in and calls InferenceConfig(**kwargs). At the pinned Megatron-LM, InferenceConfig is a plain dataclass with kv_transport_backend but no disaggregation_role. A dataclass refuses unknown keyword arguments, so the call raises before the engine exists.

What the engine build sees

prefill-0 worker, first refit _inference_config_overrides() {kv_transport_backend: "nixl", disaggregation_role: "prefill"} InferenceConfig(**kwargs) Megatron-LM e0a4bfed TypeError: InferenceConfig.__init__() got an unexpected keyword argument 'disaggregation_role' every engine, both roles, before any weight moves InferenceConfig fields at the pin config.py L761-L767 โ€ฆ disaggregation_shards โœ“ kv_transport_backend โœ“ "nixl" disaggregation_role โœ• missing The field arrives in upstream commit 84c7f168 ("decode engines skip the Mamba prefix cache by role") Megatron-LM commits, oldest to newest e0a4bfed RL installs this (Bridge ae0a1b02) +185 commits fbc9562e Bridge main pins this still no field +4 84c7f168 adds the field needed Red dot = what runs today. Green dot = the first commit that works. Underlined names link to the code. So a plain Bridge bump to its main is not enough: Bridge has to move its Megatron-LM pin first.

The tests miss it because the mixin test only compares the returned dict. It never hands that dict to a real InferenceConfig. The "is the Dynamo integration installed" check also passes at the pin, because the module it imports does exist there.

๐Ÿ’ฌ review comment C3 โ€” dynamo_worker_mixin.py:80

The fix โ€” a startup guard, proposed, not in the PR

Where the fix lands: RL only, in this PR. The existing check require_megatron_dynamo_integration() already runs in the worker's constructor, before the model loads. It also checks for the field, so an old Megatron-LM gets a clear error at startup instead of a TypeError at the first refit. No Megatron-LM bump in this PR: a bump is a large change with convergence risk, so it lands on its own. The feature just needs to say plainly which Megatron-LM it requires.

Nothing below is implemented.

The guard, as pseudocode (proposed, not run)

# dynamo worker constructor, every rank, before the model loads
def require_megatron_dynamo_integration():
    import megatron.inference.integrations.dynamo.dynamic_engine   # today's only check: passes at the pin
    if "disaggregation_role" not in fields(InferenceConfig):      # the field 84c7f168 adds
        raise RuntimeError("needs Megatron-LM with InferenceConfig.disaggregation_role "
                           "(84c7f168, #9534); use a newer one or drop dynamo")

Plus a CPU test that swaps in a fake InferenceConfig without the field and expects that error. A second Megatron-LM gap later in the stack (ChatRenderer, used by #5097's render workers) gets the same kind of check on #5097.

Do not just delete the field. Without it, a decode engine of a hybrid (Mamba) model keeps the prefix-cache budget that prefix_caching_mamba_gb gives, and the pinned Megatron-LM then refuses the KV handoff at the first refit. The field is what turns that budget off for decode.

So what. As written, the whole six-PR stack ships an engine that cannot be built: the error moves from setup to the first refit, but it always fires. The fix in this PR is a guard plus one small test, so anyone on today's Megatron-LM gets a plain "this needs a newer Megatron-LM" at startup. The Megatron-LM bump that makes the feature run is a separate change, and needs Bridge to move its pin first.