Skip to content

Commit 432d9c2

Browse files
committed
fix
1 parent 1599573 commit 432d9c2

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

swift/pipelines/infer/rollout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def process_weights_after_loading(self) -> None:
295295
*model_config* and *target_device* are available (same as verl);
296296
falls back to FusedMoE-only path otherwise.
297297
"""
298-
model_config = getattr(getattr(self, 'model_runner', None), 'model_config', None)
298+
model_config = getattr(self.model_runner, 'model_config', None)
299299
if model_config is None:
300300
model_config = getattr(getattr(self, 'vllm_config', None), 'model_config', None)
301301
finish_vllm_weight_reload(self.model_runner.model, model_config=model_config, target_device=self.device)

swift/ray/megatron/megatron_worker.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,14 +597,12 @@ def _pad_or_trim_routed_experts(routed: torch.Tensor, target_len: int, *, paddin
597597
return routed[:target_len] if padding_right else routed[-target_len:]
598598

599599
pad_len = target_len - current_len
600-
last_entry = routed[-1:].expand(pad_len, *routed.shape[1:])
601-
padded = torch.cat([routed, last_entry], dim=0)
602-
600+
pad = [0] * (2 * routed.dim())
603601
if padding_right:
604-
return padded
602+
pad[2 * (routed.dim() - 1) + 1] = pad_len
605603
else:
606-
left_pad = torch.zeros(pad_len, *routed.shape[1:], dtype=routed.dtype)
607-
return torch.cat([left_pad, padded], dim=0)
604+
pad[2 * (routed.dim() - 1)] = pad_len
605+
return torch.nn.functional.pad(routed, tuple(pad), 'constant', 0)
608606

609607
def _build_routed_experts_batch(
610608
self,

0 commit comments

Comments
 (0)