[NPU] Fix Ascend JSD UT failures and register LayerNorm dispatch - #1452
Merged
Merged
Conversation
Contributor
Author
|
@Tcc0403 This pr is ready for review. Could you please review this PR? Thanks! |
Tcc0403
reviewed
Sep 13, 2026
Collaborator
|
Just saw an update, is ci good now? |
Contributor
Author
The update only rebases the code from the |
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
Unit tests for JSD / FusedLinearJSD on Ascend failed, mainly due to signature misalignment with the NVIDIA frontend, and invalid kernel launches when all samples are ignored. The ascend-triton dispatcher registration for LayerNorm is also added so that the NPU can automatically select the UB-aware implementation.
JSD / FusedLinearJSD signature alignment: NVIDIA's LigerJSDFunction / LigerFusedLinearJSDFunction accepts jsd_impl / jsd_mode (apply(..., None, None) is used in tests). The Ascend kernel is self-contained and does not use the inner dispatcher, so it simply accepts and ignores these two parameters, and the number of backward return values is supplemented accordingly; supports_inner_impl_dispatch is set to False for JSD.
Short-circuit for all-ignored case: When n_non_ignore == 0, skip kernel launch and directly return zero loss and zero gradients. This covers cases such as test_correctness_all_ignored to prevent division-by-zero / invalid grid.
LayerNorm registration: Add ops/backends/_ascend/layer_norm.py and register it in declare_op_locations("layer_norm") within functional.py. Otherwise, auto-selection only detects the NVIDIA-triton implementation for CUDA and cannot use _ascend.ops.layer_norm.
Testing Done
pytest tests/transformers

make testto ensure correctnessmake checkstyleto ensure code stylemake test-convergenceto ensure convergence