Skip to content

feat(megatron): specialize fused TopK scoring for Ascend - #162

Draft
lukatao wants to merge 1 commit into
flagos-ai:mainfrom
lukatao:kernelgen/ascend-fused-topk-score
Draft

lukatao wants to merge 1 commit into
flagos-ai:mainfrom
lukatao:kernelgen/ascend-fused-topk-score

Conversation

@lukatao

@lukatao lukatao commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an Ascend Triton implementation for fused TopK scoring. The sqrt-softplus path uses a stable device-side log1p calculation that preserves the ordering of very small scores without relying on the unavailable backend libdevice primitive.

Validation

  • Ascend 910B, CANN 9.2.1, Torch NPU 2.13.0 and Triton 3.5.1.
  • Verified the public FlagTrain dispatcher selects the Ascend implementation.
  • 51/51 correctness cases passed, including the sqrt-softplus tail regression. All 24 benchmark workloads matched the existing Optest H800 native data, with a 5.05× geometric mean of per-workload normalized speedups.
GEMS_VENDOR=ascend pytest -q tests/megatron/test_fused_topk_with_score_function.py
GEMS_VENDOR=ascend pytest -q -s benchmark/megatron/test_fused_topk_with_score_function.py \
  --mode kernel --base-data "$H800_JSON" --warmup 3 --iter 12

Signed-off-by: taooo <gumptao2997@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant