From 0b463d5b929ef1b083a352b60b63536b864f5c81 Mon Sep 17 00:00:00 2001 From: botbikamordehai2-sketch Date: Tue, 21 Jul 2026 11:12:22 +0000 Subject: [PATCH] fix: avoid in-place mutation of param in MTP weight conversion (related to #2131) --- slime/backends/megatron_utils/megatron_to_hf/mimo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slime/backends/megatron_utils/megatron_to_hf/mimo.py b/slime/backends/megatron_utils/megatron_to_hf/mimo.py index 3d9c6c4917..8796321689 100644 --- a/slime/backends/megatron_utils/megatron_to_hf/mimo.py +++ b/slime/backends/megatron_utils/megatron_to_hf/mimo.py @@ -45,8 +45,9 @@ def convert_mimo_mtp_param(args, name, param): "final_layernorm.weight": f"model.mtp_layers.{layer_idx}.final_layernorm.weight", } if component == "eh_proj.weight": + # chunk and reorder halves; create new tensor to avoid mutating input first_half, second_half = param.chunk(2, dim=1) - param = torch.cat([second_half, first_half], dim=1) + param = torch.cat([second_half, first_half], dim=1).contiguous() # Check direct mappings first if component in direct_mappings: