[Bugfix][DSv3.2] Skip indexer weights for index-cache-skipped layers (#46600)

Signed-off-by: Frida Andersson <fanderss@amd.com>
Co-authored-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
frida-andersson
2026-06-28 01:37:44 -07:00
committed by GitHub
co-authored by Andreas Karatzas
parent 09841ae705
commit 6eb63a1da6
+10
View File
@@ -1451,6 +1451,11 @@ class DeepseekV2Model(nn.Module):
pp_missing_layer_names = get_pp_missing_layer_names(self)
params_dict = dict(self.named_parameters())
loaded_params: set[str] = set()
# With index_topk_freq>1 only some layers build an indexer, yet the
# checkpoint ships indexer weights for all of them; track the built ones.
indexer_present_prefixes = {
n.rsplit(".indexer.", 1)[0] for n in params_dict if ".indexer." in n
}
for name, loaded_weight in weights:
if "rotary_emb.inv_freq" in name:
continue
@@ -1459,6 +1464,11 @@ class DeepseekV2Model(nn.Module):
if spec_layer is not None:
continue # skip spec decode layers for main model
if ".indexer." in name and (
name.rsplit(".indexer.", 1)[0] not in indexer_present_prefixes
):
continue # this layer has no indexer; drop its checkpoint weights
is_fusion_moe_shared_experts_layer = (
rocm_aiter_moe_shared_expert_enabled and ("mlp.shared_experts" in name)
)