[Bugfix][Model Loader] Support reload_weights with runai_streamer load format (#58124)
Signed-off-by: Viktor Koukouliev <vkoukouliev@nvidia.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
Isotr0py
parent
5281e49908
commit
c83935b300
@@ -134,11 +134,16 @@ class RunaiModelStreamerLoader(BaseModelLoader):
|
||||
"""Download model if necessary."""
|
||||
self._prepare_weights(model_config.model, model_config.revision)
|
||||
|
||||
def load_weights(self, model: nn.Module, model_config: ModelConfig) -> None:
|
||||
"""Load weights into a model."""
|
||||
def get_all_weights(
|
||||
self,
|
||||
model_config: ModelConfig,
|
||||
model: nn.Module,
|
||||
) -> Generator[tuple[str, torch.Tensor], None, None]:
|
||||
model_weights = model_config.model
|
||||
if model_weights_override := model_config.model_weights:
|
||||
model_weights = model_weights_override
|
||||
model.load_weights(
|
||||
self._get_weights_iterator(model_weights, model_config.revision)
|
||||
)
|
||||
yield from self._get_weights_iterator(model_weights, model_config.revision)
|
||||
|
||||
def load_weights(self, model: nn.Module, model_config: ModelConfig) -> None:
|
||||
"""Load weights into a model."""
|
||||
model.load_weights(self.get_all_weights(model_config, model))
|
||||
|
||||
@@ -5534,9 +5534,11 @@ class GPUModelRunner(
|
||||
)
|
||||
|
||||
if weights_path is not None:
|
||||
# The revision belongs to the model we are reloading away from,
|
||||
# so it must not be carried over to the new path.
|
||||
# The revision and any object-storage `model_weights` source
|
||||
# belong to the model we are reloading away from, so they must
|
||||
# not be carried over to the new path.
|
||||
self.model_config.model = weights_path
|
||||
self.model_config.model_weights = ""
|
||||
self.model_config.revision = None
|
||||
weights_iterator = model_loader.get_all_weights(self.model_config, model)
|
||||
weights_iterator = cast(
|
||||
|
||||
Reference in New Issue
Block a user