[Fix] GigaChat 3.5: build the stage boundaries once (#42480)

This commit is contained in:
Cheng Wan
2026-10-04 16:39:34 -07:00
committed by GitHub
parent 5c8fb9e938
commit a99567ab74
3 changed files with 176 additions and 5 deletions
+8 -5
View File
@@ -2614,6 +2614,7 @@ class DeepseekV2DecoderLayer(nn.Module):
prefix: str = "",
alt_stream: Optional[torch.cuda.Stream] = None,
skip_rope: bool = False,
build_stages: bool = True,
) -> None:
super().__init__()
self.hidden_size = config.hidden_size
@@ -2709,11 +2710,13 @@ class DeepseekV2DecoderLayer(nn.Module):
self._gfx95_quant_format = self._detect_gfx95_quant_format()
self.attn_boundary, self.ffn_boundary = self._build_stages(
input_layernorm=self.input_layernorm,
post_attention_layernorm=self.post_attention_layernorm,
qkv_latent_func=self.self_attn.prepare_qkv_latent,
)
# A subclass that brings its own norms builds the stages after them.
if build_stages:
self.attn_boundary, self.ffn_boundary = self._build_stages(
input_layernorm=self.input_layernorm,
post_attention_layernorm=self.post_attention_layernorm,
qkv_latent_func=self.self_attn.prepare_qkv_latent,
)
def _build_stages(
self,
+1
View File
@@ -365,6 +365,7 @@ class GigaChat35DecoderLayer(deepseek_v2.DeepseekV2DecoderLayer):
is_nextn=is_nextn,
prefix=prefix,
alt_stream=alt_stream,
build_stages=False,
)
attn_layer_id = config.num_hidden_layers if is_nextn else layer_id