Skip to content

[NPU] Fix Ascend JSD UT failures and register LayerNorm dispatch - #1452

Merged
Tcc0403 merged 1 commit into
linkedin:mainfrom
sunyi0505:main
Sep 14, 2026
Merged

Tcc0403 merged 1 commit into
linkedin:mainfrom
sunyi0505:main

Conversation

@sunyi0505

Copy link
Copy Markdown
Contributor

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
aa9edfdb912726cb88d8905e1b40f870

  • Hardware Type: Atlas 800T A3(X86)
  • run make test to ensure correctness
  • run make checkstyle to ensure code style
  • run make test-convergence to ensure convergence

@sunyi0505

Copy link
Copy Markdown
Contributor Author

@Tcc0403 This pr is ready for review. Could you please review this PR? Thanks!

Comment thread src/liger_kernel/ops/backends/_ascend/ops/fused_linear_jsd.py
Comment thread src/liger_kernel/ops/backends/_ascend/ops/jsd.py
@Tcc0403

Tcc0403 commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Just saw an update, is ci good now?

@sunyi0505

Copy link
Copy Markdown
Contributor Author

Just saw an update, is ci good now?

The update only rebases the code from the main branch, with no other changes. CI passes.

@Tcc0403 Tcc0403 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Tcc0403
Tcc0403 added this pull request to the merge queue Sep 14, 2026
Merged via the queue into linkedin:main with commit bcb5962 Sep 14, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants