config: delete the redundant full stamp in initialize_model_parallel (#39202)
This commit is contained in:
@@ -164,7 +164,7 @@ def derive_parallel_widths(
|
||||
|
||||
`world_size` is not among them: it is not a quotient, and `get_world_size()`
|
||||
answers with the live WORLD group, which stays right through an elastic
|
||||
scale-up that a stamp taken at group build would not survive.
|
||||
scale-up that a value fixed at group build would not survive.
|
||||
"""
|
||||
return {
|
||||
"attn_dp_size": attn_dp_size,
|
||||
@@ -268,7 +268,7 @@ class ParallelContext:
|
||||
def __init__(self):
|
||||
self._overrides = {}
|
||||
self._config = None # parallel config bag, wired at publish
|
||||
self._derived = {} # widths stamped when the groups are built
|
||||
self._derived = {} # widths overridden permanently, as the groups are built
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name.startswith("_"):
|
||||
@@ -291,14 +291,17 @@ class ParallelContext:
|
||||
overrides = self._overrides
|
||||
return overrides[name] if name in overrides else getter()
|
||||
|
||||
def stamp_derived_widths(self, **widths) -> None:
|
||||
"""Record the widths derived from the leaves, as the groups are built.
|
||||
def override_permanently(self, **widths) -> None:
|
||||
"""Permanently correct a derived width the published bag can't answer
|
||||
or no longer answers correctly -- not `RuntimeContext.override`,
|
||||
because a derived width is not a resolved config leaf and this must
|
||||
work with no config published at all (`multimodal_gen` lends a TP
|
||||
group to `srt` layers with no `srt` config to publish against).
|
||||
|
||||
`initialize_model_parallel` computes the set through
|
||||
`derive_parallel_widths` and hands it here; `initialize_dp_attention`
|
||||
stamps `attn_dp_size` again once it knows the effective width, and
|
||||
elastic EP restamps it where it already updates the live one. A stamped
|
||||
width is what the readers answer with.
|
||||
Lives beside, not inside, the `@contextmanager` `override` above -- a
|
||||
name it cannot also have on this class -- because these are permanent
|
||||
for the process, not scoped to a `with` block: none of the real
|
||||
callers ever restore the value they set here.
|
||||
"""
|
||||
self._derived.update(widths)
|
||||
|
||||
@@ -306,13 +309,13 @@ class ParallelContext:
|
||||
self._derived.clear()
|
||||
|
||||
def _derived_width(self, name):
|
||||
"""A width the configuration implies: override, else stamp, else the
|
||||
published leaf.
|
||||
"""A width the configuration implies: scoped override, else permanent
|
||||
override, else the published leaf.
|
||||
|
||||
The leaf is computed at publish by `parallel_widths_of`; the stamp sits
|
||||
above it because an elastic scale-up restamps `attn_dp_size` after
|
||||
publish, and a scope that swaps in another TP group states the quotients
|
||||
through `override`.
|
||||
The leaf is computed at publish by `parallel_widths_of`; the permanent
|
||||
override sits above it because an elastic scale-up corrects
|
||||
`attn_dp_size` after publish, and a scope that swaps in another TP
|
||||
group states the quotients through the scoped `override` above that.
|
||||
|
||||
Nothing is recomputed on read, so overriding `tp_size` does not move
|
||||
`attn_tp_size`: name the width, or publish a config.
|
||||
@@ -328,10 +331,10 @@ class ParallelContext:
|
||||
return getattr(config, name)
|
||||
raise RuntimeError(
|
||||
f"derived parallel width {name!r} is not available: it is computed "
|
||||
"from the configured leaves at publish, and restamped when the "
|
||||
"process groups are built. Nothing is published and nothing has "
|
||||
"been stamped -- publish a parallel config, or state the width "
|
||||
f"with get_parallel().override({name}=...)"
|
||||
"from the configured leaves at publish, and permanently corrected "
|
||||
"when the process groups are built. Nothing is published and "
|
||||
"nothing has been set with override_permanently -- publish a "
|
||||
f"parallel config, or state the width with get_parallel().override({name}=...)"
|
||||
)
|
||||
|
||||
@contextmanager
|
||||
@@ -1754,9 +1757,10 @@ def reset_context() -> None:
|
||||
"""Clear the context-owned store (unit-test teardown): drop the published
|
||||
``server_args`` and install fresh ``Flags`` and ``Resources``.
|
||||
|
||||
``parallel`` holds the stamped derived widths, which go with the lifecycle
|
||||
that stamped them: `_derived_width` prefers the stamp over the leaves, so
|
||||
leaving one behind lets the next test read the previous topology.
|
||||
``parallel`` holds the permanently-overridden derived widths, which go
|
||||
with the lifecycle that set them: `_derived_width` prefers them over the
|
||||
published leaves, so leaving one behind lets the next test read the
|
||||
previous topology.
|
||||
"""
|
||||
_CONTEXT._server_args = None
|
||||
_CONTEXT._config_bags = None
|
||||
|
||||
Reference in New Issue
Block a user