config: route parallel config-leaf reads through get_parallel() (#33170)

The parallel namespace joins the accessor migration: 106 config-leaf reads
(enable_dp_lm_head, enable_dp_attention, pp_async_batch_depth, dp_size,
ep_join_rank_offset, dwdp_size, ...) flip from get_server_args()/
self.server_args to get_parallel(), which serves config leaves from the
published parallel bag via __getattr__.

- ParallelContext.__getattr__ is restructured to stay dynamo-traceable
  (object.__getattribute__ graph-breaks): gate helpers such as
  enable_moe_dense_fully_dp() run inside compiled model forwards. A
  fullgraph regression test pins the pattern.
- The five live-shadowed topology sizes (tp/pp/dcp/attn_cp/moe_dp_size)
  keep their server_args reads: the live @property wins on the accessor,
  and conditionally-initialized groups would fail loud at unconditional
  call sites.
- Elastic-EP scale writers (ep_size/dp_size x4 in model_runner) reroute
  to get_context().override together with their remaining instance
  readers (expert_location gpus-per-node paths); the ServerArgs.override
  ratchet drops 39 -> 35.
- The expert placement helpers (compute_logical_to_rank_dispatch_
  physical_map, _compute_logical_to_all_physical_map,
  _prefer_same_node_experts) now read everything from the bags and drop
  their server_args parameter; their unit tests publish the config they
  need instead of stubbing it.
This commit is contained in:
Cheng Wan
2026-08-01 08:58:39 -07:00
committed by GitHub
parent df55e911d6
commit 47d8b5b749
81 changed files with 344 additions and 405 deletions
+13 -6
View File
@@ -125,12 +125,19 @@ class ParallelContext:
def __getattr__(self, name):
# Reached only for names that are neither a live @property nor a slot:
# serve parallel config leaves from the published bag.
try:
config = object.__getattribute__(self, "_config")
except AttributeError:
config = None
if config is not None and name in config:
# serve parallel config leaves from the published bag. The body must
# stay dynamo-traceable — config-leaf reads such as
# ``get_parallel().moe_dense_tp_size`` run inside compiled model
# forwards, and ``object.__getattribute__`` graph-breaks.
if name.startswith("_"):
# No config leaf is underscored; this also breaks the recursion
# when the ``_config`` slot itself is still unset (pickle/copy
# protocols probe attributes before __init__ runs).
raise AttributeError(name)
config = self._config
# ``_fields`` is a plain ``__dict__`` entry on the bag; ``in`` on the
# dict avoids ``_ConfigBag.__contains__`` (not traceable).
if config is not None and name in config._fields:
return getattr(config, name)
detail = (
"not a published parallel config leaf"