Conversation
CyCle1024
force-pushed
the
ccy/npu/intern_s2_preview_support
branch
2 times, most recently
from
August 28, 2026 06:59
f30f490 to
95043dc
Compare
CyCle1024
commented
Aug 28, 2026
CyCle1024
commented
Aug 28, 2026
CyCle1024
commented
Aug 28, 2026
CyCle1024
commented
Aug 28, 2026
CyCle1024
commented
Aug 28, 2026
CyCle1024
commented
Aug 28, 2026
CyCle1024
commented
Aug 28, 2026
CyCle1024
commented
Aug 28, 2026
| layer_hidden_states = hidden_states | ||
| hidden_states = self.norm(hidden_states) | ||
|
|
||
| # Get LM loss context from dict |
CyCle1024
commented
Aug 28, 2026
CyCle1024
commented
Aug 28, 2026
| # leave the first post-MTP LM-head call to unshard on demand for now. A future | ||
| # optimization can explicitly prefetch the LM head in MTPBlock only after its final | ||
| # logical depth finishes. | ||
| if not mtp_config.share_weights: |
CyCle1024
commented
Aug 28, 2026
CyCle1024
commented
Aug 28, 2026
| nonpad_indices = seq_ctx.nonpad_indices | ||
| non_pad_token = nonpad_indices.numel() | ||
| num_tokens_global, z_world_size = self._z_loss_dist_token_count(z_ctx, non_pad_token, seq_ctx.mask.device) | ||
| num_tokens_global, z_world_size = self._z_loss_dist_token_count(z_ctx, non_pad_token, nonpad_indices.device) |
CyCle1024
commented
Aug 28, 2026
CyCle1024
force-pushed
the
ccy/npu/intern_s2_preview_support
branch
from
August 30, 2026 09:59
83a2861 to
c64718d
Compare
CyCle1024
force-pushed
the
ccy/npu/intern_s2_preview_support
branch
from
August 30, 2026 10:53
c64718d to
a0381c6
Compare
CyCle1024
pushed a commit
to CyCle1024/xtuner
that referenced
this pull request
Sep 20, 2026
…w PR InternLM#2052 Resolved 5 files: - data_proto/__init__.py: merge DSATopKCacheState/GatedDeltaNetMetadata exports - data_proto/sequence_context.py: keep PR's two new dataclasses - model/moe/moe.py: MTP checkpoint toggle — reentrant branch adapted to main's apply_activation_checkpointing (its _checkpoint_pytree subsumes PR's pytree_reentrant_checkpoint + adds reuse_during_recompute frame); non-reentrant fallback uses torch checkpoint_wrapper(NO_REENTRANT); add CheckpointImpl/ checkpoint_wrapper imports; add fsdp.mtp_checkpoint_use_reentrant config field - module/decoder_layer/moe_decoder_layer.py: keep PR's pad-scatter logic, return via main's structured _build_output - module/mtp/mtp_block.py: keep PR's always-list contract + shared return tail + _reshard_shared_layer
CyCle1024
added a commit
to CyCle1024/xtuner
that referenced
this pull request
Sep 20, 2026
[Merge] Resolve conflicts with upstream/main for PR InternLM#2052
ejunered
added a commit
to ejunered/xtuner
that referenced
this pull request
Sep 21, 2026
…w PR InternLM#2052 Resolved 5 files: - data_proto/__init__.py: merge DSATopKCacheState/GatedDeltaNetMetadata exports - data_proto/sequence_context.py: keep PR's two new dataclasses - model/moe/moe.py: MTP checkpoint toggle — reentrant branch adapted to main's apply_activation_checkpointing (its _checkpoint_pytree subsumes PR's pytree_reentrant_checkpoint + adds reuse_during_recompute frame); non-reentrant fallback uses torch checkpoint_wrapper(NO_REENTRANT); add CheckpointImpl/ checkpoint_wrapper imports; add fsdp.mtp_checkpoint_use_reentrant config field - module/decoder_layer/moe_decoder_layer.py: keep PR's pad-scatter logic, return via main's structured _build_output - module/mtp/mtp_block.py: keep PR's always-list contract + shared return tail + _reshard_shared_layer
jayhenry
force-pushed
the
ccy/npu/intern_s2_preview_support
branch
from
September 23, 2026 14:15
921b763 to
31d86fe
Compare
jayhenry
approved these changes
Sep 23, 2026
Co-authored-by: CyCle1024 <cycle1024@gmail.com>
Co-authored-by: houyufeng4@huawei.com <houyufeng4@huawei.com> Co-authored-by: CyCle1024 <cycle1024@gmail.com>
Co-authored-by: CyCle1024 <cycle1024@gmail.com>
Co-authored-by: CyCle1024 <cycle1024@gmail.com>
Co-authored-by: CyCle1024 <cycle1024@gmail.com>
Co-authored-by: CyCle1024 <cycle1024@gmail.com>
…totune patch triton-ascend 3.2.0's autotune signature has no cache_results parameter, so the unconditional kwargs["cache_results"] = False raised TypeError when XTUNER_DETERMINISTIC=true. Probe original_autotune's signature and only forward cache_results when the parameter exists.
jayhenry
force-pushed
the
ccy/npu/intern_s2_preview_support
branch
from
September 24, 2026 13:48
31d86fe to
ad11739
Compare
The main LM branch (norm + lm_head) now runs after MTP, so the e2e TV loss must normalize the main hidden states itself. The test compares the model's mtp_loss with an lm_head TV call on norm(main hidden states) and fails when the un-normalized states are used as the TV target.
This branch has not been deployed
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
This PR adds NPU training support for Intern-S2-Preview while keeping the shared model and CUDA operator contracts stable.
Design notes
[B, T, H, D]as its public layout. The NPU wrappers preserve native head-first storage with transpose views where possible and materialize only when required by a fixed-layout kernel.xtuner/v1/ops; model modules keep device-independent logical interfaces.Known limitations
skip_dispatch_pad_tokenscurrently covers the standard single-context MoE forward, not the intra-layer multi-microbatch/domino-EP path.B == 1,num_value_headsdivisible bynum_key_heads, and equal key/value head dimensions.export_bind_config(). Trainerrun()uses the packaged binding configuration; host IRQ setup remains an explicit launch-script operation.History cleanup (2026-09-23)
The branch was rebuilt on top of the latest
upstream/main(fb51baeb) to replace the repeatedmainmerges with a linear history. The previous branch head (921b7637) is backed up at https://github.com/jayhenry/xtuner/tree/backup/pr2052.a18595ae) is folded intoImprove MTP compatibility and scheduling, so that commit is correct on its own.cache_resultsguard is kept as a separate final commit.upstream/main: every MTP layer usesapply_activation_checkpointing. The PR-onlyFSDPConfig.mtp_checkpoint_use_reentrantoption and thecheckpoint_wrappernon-reentrant branch are removed.Rebase onto
e7299bbc(2026-09-24)Rebased again onto the latest
upstream/main(e7299bbc). The previous head (31d86fe4) is backed up at https://github.com/jayhenry/xtuner/tree/backup/pr2052-31d86fe4.MTPConfig: kept main'sloss_type/tv_loss_chunk_sizealongside this PR'sdisable_lm_head_prefetch.MoE.forward: this PR runs the main LM branch (norm+lm_head) after MTP, so the new e2e TV loss ([Feature] Add end-to-end TV loss for MTP SFT #2070) would have received un-normalized target states. The TV target is nowself.norm(layer_hidden_states), matching the intra-layer micro-batch path.Added
tests/model/test_moe_mtp_e2e_tv.pyas a regression test: it comparesmtp_losswith anlm_headTV call onnorm(main hidden states)and fails without the fix above.