[bugfix] support MTP-only pipeline stages - #155
Open
taking-lying-flat wants to merge 2 commits into
Open
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
HowardZorn
reviewed
Aug 4, 2026
| for layer_type in stage | ||
| ] | ||
|
|
||
| self.config.pipeline_model_parallel_layout = fallback_layout |
There was a problem hiding this comment.
我看了看Megatron-LM的情况,这里他们用的是一个不切vp_stage的layout(但是mcore-bridge这里没有这样的函数get_gpt_decoder_layer_specs()),这里您的选择是去找第一个decoder layers,我觉得也可以。不过后续可能需要对齐一下
if args.mtp_num_layers is not None:
assert not (config.transformer_impl == "inference_optimized")
if (
hasattr(transformer_layer_spec, 'layer_specs')
and len(transformer_layer_spec.layer_specs) == 0
):
# Get the decoder layer spec explicitly if no decoder layer in the last stage,
# Only happens with block spec (TransformerBlockSubmodules) when using MoE.
transformer_layer_spec_for_mtp = _get_transformer_layer_spec(use_te, config)
else:
# Define the decoder block spec
if args.experimental_attention_variant is not None:
decoder_layer_specs = (
get_transformer_layer_with_experimental_attention_variant_spec(config=config)
)
else:
decoder_layer_specs = get_gpt_decoder_layer_specs(
config,
use_transformer_engine=use_te,
normalization=args.normalization,
qk_l2_norm=args.qk_l2_norm,
vp_stage=vp_stage,
)
transformer_layer_spec_for_mtp = decoder_layer_specs[-1]
# Use spec of the last layer in decoder block as spec of the transformer layer in MTP
mtp_block_spec = get_gpt_mtp_block_spec(
config, transformer_layer_spec_for_mtp, use_transformer_engine=use_te, vp_stage=vp_stage
)|
@taking-lying-flat 我逐渐理解这个工程其实会变成每个experiment attention模型的loader都需要加料的情况,这样工程量可能有点大 |
Author
|
@HowardZorn。 确实 不敢大重构 按照 Megatron-LM. 出现bug 就修复吧 |
@taking-lying-flat 感觉我们需要 @Jintao-Huang 来看看怎么样处理了。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
The Qwen3.5 397B pipeline layout can place MTP on a stage with no local decoder layers. Passing that empty local decoder block to Megatron's MTP builder causes it to index an empty
layer_specslist.Using Megatron's generic decoder helper directly would lose Qwen3.5's heterogeneous GDN/attention layer structure. The loader now generates its complete experimental-attention specs, applies the same Qwen-specific replacements used for local layers, and passes the final global decoder layer spec to the existing MTP builder.
Validation
flake8andyapfon the changed file