Repository navigation
[PTO] Port all quant, mHC and MoE ASC operators to T.Parallel - #36
Open
chenshengxin2026 wants to merge 2 commits into
Open
chenshengxin2026 wants to merge 2 commits into
chenshengxin2026 wants to merge 2 commits into
Conversation
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
Add PTO VMI implementations for every quant/mHC/MoE
*_asc.pymodule onvmi-impl: 12 quant + 9 mHC + 4 MoE, plus a scalar sqrt-softplus helper. Each counterpart is named*_parallel.pyand exposes*_parallelentry points. Existing CUDA/ASC files and public dispatch remain available.The SIMD bodies use CUDA-style scalar
T.Parallel, per-lane accumulators, serial reductions andT.reduce_*. ASC kernel launch, persistent scheduling, DMA, buffer versions, expert padding, SF layouts and inter-core reduction structure are retained. Necessary differences and the complete module-to-test mapping are documented intests/parallel/README.md.Notable details include exact division, bit-accurate stochastic rounding, FP4 midpoint handling, packed UE8M0 row/column layouts, RMSNorm Mega SF, SwigLU clamp counters and quantized backward, stable TopK ties, Sinkhorn forward/backward, and MoE auxiliary gradients crossing sequence boundaries. One-dimensional MoE backward uses
group_size=1; sequence division remains int32 before explicitly widening GM/UB address coordinates.Required compiler support
This PR depends on TileLang #36 and PTOAS #1703 + #1705. The latter is stacked on #1703. These are submitted support PRs, not features already merged into the upstream defaults.
Existing upstream work was checked before implementation: TileLang #11 supplies M2/sequential-loop support for #23 and is included as a dependency in #36. #16 and #28 are already in
pto-dev. The separate #31 clear/fill work is not duplicated; these examples initialize with Parallel loops.Validation
All 110 device cases passed: 44 mHC/core + 26 quantization + 23 remaining operator/compiler features + 17 MoE/batched-SF/atomic cases. All four task-submit jobs exited with code 0. Tested commits: TileLang
dec29c2f901e11fe2b82369533611e45274870a9, PTOAS81d9b3570f46a0b2616d4b00f38011c451409778(including #1703).The independent acceptance suite in
tests/parallel/checks CPU PyTorch references against actual Ascend 950 results. Every NPU command is wrapped intask-submit, including auxiliary compiler-feature tests. Tests assert generated VMI source, with the documented exception of the preserved generic SIMT pre-split path.The environment is CANN 9.3, Python 3.12, torch/torch_npu 2.14 and the support PR revisions above. Mixed FP4/FP8 layout search uses the existing
PTO_FLAGS='--vmi-layout-max-frontier-entries=4096 --vmi-layout-max-transitions=1000000'option. These are correctness tests, not performance claims or exhaustive coverage of every specialization.Compiler validation: 230 CPU tests passed (one unrelated CUDA compilation test excluded on the Ascend-only host); PTOAS focused suites passed 25 barrier tests and 17 mask tests. Scoped formatting and
git diff --checkpassed.