[MM][CG] Enable encoder Cudagraph for Step3VL (#42224)

Signed-off-by: JisoLya <523420504@qq.com>
Signed-off-by: Soyaazz <523420504@qq.com>
This commit is contained in:
Soyaazz
2026-05-17 20:19:13 -07:00
committed by GitHub
parent 107210442d
commit 990f49bdcb
8 changed files with 384 additions and 22 deletions
+16
View File
@@ -884,3 +884,19 @@ def get_layer_index(feature_layer_index: int, num_hidden_layers: int) -> int:
if feature_layer_index < 0:
return num_hidden_layers + feature_layer_index + 1
return feature_layer_index
def scatter_output_slices(
output: torch.Tensor,
indices: list[int],
per_item_out_tokens: list[int],
dest: dict[int, torch.Tensor] | list[torch.Tensor | None],
clone: bool = False,
) -> None:
"""Slice a concatenated output tensor and scatter into dest by index."""
offset = 0
for idx in indices:
n_tok = per_item_out_tokens[idx]
sliced = output[offset : offset + n_tok]
dest[idx] = sliced.clone() if clone else sliced
offset += n_tok