Repository navigation
Conversation
1. Canonicalize every A5 spelling (950, Ascend950, Ascend950PR_*, Ascend950DT_*) onto Ascend950; they were accepted then discarded, since the C++ bundle compiles against the 910C compatibility target either way 2. Drop the is_a5_soc_version helper for a plain equality check and merge the two adjacent identical if-blocks 3. Document the four aliases the script actually accepts (910B/910/910C/950) 4. Rename gemma_rmsnorm.py to _gemma_rmsnorm_native.py so the source tree ships no staged provider; a source or editable install now fails loudly instead of silently defaulting to the 910 operator on A5 5. Record the bf16 1.0+weight trade-off in both provider docstrings 6. Drop the guard asserting absence of never-shipped draft symbols, and the A5-vacuous npu_rms_norm equivalence test 7. Run the two mock-only build-target suites in lint CI; they needed no NPU but nothing executed them
1. normalize_soc_version only folds the documented shorthands and now lets any other value through, so -a kernels Ascend910B2 / Ascend910B4 / Ascend910_9391 / ascend910_93 reach the AscendC compiler exactly as they did before; the allow-list introduced with the alias table silently turned this pass-through into a hard error 2. Restore the deepep three-SoC check that the allow-list had been standing in for, and apply it to 'all' as well since that target builds deep_ep too 3. Document in the help text that kernels accepts concrete compiler targets while all/deepep do not
1. all/kernels now call detect_soc_version instead of hardcoding Ascend910_9382, so an A5 host builds the ACLNN Gemma wheel without anyone remembering to pass 950; deepep already did this 2. Rename detect_deepep_soc_version and its messages, which are no longer deepep-specific 3. Hosts without npu-smi keep falling back to Ascend910_9382, so release containers produce byte-identical artifacts 4. Fall back rather than abort when npu-smi reports an unrecognized chip: all/kernels never had a failure path here. deepep still aborts via a strict flag, since it picks its ops variant from the SoC and guessing wrong is worse than stopping 5. Cover detection per chip by running build.sh against a faked npu-smi; skipped on Windows, where bash resolves to WSL and cannot see the repo path
1. Restore the deepep usage line and the Chip mapping block to their upstream wording; both were already accurate and my rewrites carried no new information 2. Keep the kernels usage line updated, since that target genuinely gained auto-detection and the old text no longer describes it 3. Condense the alias block to what the new behaviour actually requires
Replace the Gemma-specific GEMMA_PROVIDERS staging in setup.py with a generic target_providers/<target>/ tree staged by build_tools. The relative module path is the registration key, so the build system knows targets but not operators: adding a cross-generation operator is now just two provider files plus tests, with no build-framework changes.
This was referenced Aug 20, 2026
This was referenced Aug 24, 2026
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.
Motivation
Ascend generations may expose different low-level implementations for the same semantic operator.
PR #638 introduces build-time provider selection for Gemma RMSNorm, keeping SoC-specific operator selection inside
sgl-kernel-npuwhile exposing a stable API to SGLang. However, the current staging logic is specific to Gemma RMSNorm:setup.pyexplicitly knows its provider files and how to select them.As more cross-generation operator differences are introduced, repeating this pattern would make the build system increasingly operator-aware.
This PR generalizes the existing mechanism into a lightweight target-specific provider staging layer. Provider implementations are organized by target and stable module path. The build system selects one target provider tree while building the wheel, so adding another portable cross-generation operator does not require changes to
setup.pyor runtime SoC dispatch.Design
The core principle: Build system knows targets, but does not know operators.
target_providers/<target>/<module>.py— the relative module path after the target directory is the registration key. NoPROVIDERSdict, no explicitregister()call:Both become
sgl_kernel_npu/norm/gemma_rmsnorm.pyin the wheel — the stable public API SGLang already consumes ((output, rstd)contract unchanged).Provider selection is a build-time decision.
build.shkeeps normalizing the SoC intoSGL_KERNEL_NPU_BUILD_TARGET(Ascend910/Ascend950, unchanged from ✨ [NPU] Add portable Gemma RMSNorm API #638).build_tools/target_provider.py(~70 lines) validates the target, scans the provider tree, and stages every.pyintobuild_lib/sgl_kernel_npu/by relative path. It does exactly three things: validate target → find provider files → stage files.Fail loudly, never fall back. Unknown target, missing provider directory, or a provider colliding with an existing common module all fail the build instead of silently falling back at runtime. There is no runtime dispatch, no registry, no fallback — if the wheel target is decided, a missing provider is a build configuration error.
Source tree ships no provider module. As in ✨ [NPU] Add portable Gemma RMSNorm API #638,
norm/gemma_rmsnorm.pyonly exists inside a built wheel; a source checkout (orpip install -e .) raisesImportErrorrather than silently defaulting to one target's operator.Key changes
build_tools/target_provider.py: genericstage_target_providers()+collect_provider_modules(); no operator names anywhere in the build frameworknorm/_gemma_rmsnorm_native.py→target_providers/Ascend910/norm/gemma_rmsnorm.py,norm/_gemma_rmsnorm_aclnn.py→target_providers/Ascend950/norm/gemma_rmsnorm.py(git detects both as renames; implementations unchanged)TargetBuildPyinsetup.py: dropGEMMA_PROVIDERSand all Gemma-specific copy/unlink logic; it now only readsSGL_KERNEL_NPU_BUILD_TARGETand callsstage_target_providers()target_providersfromfind_namespace_packagesso provider sources stay build input and never land in the wheelSGL_KERNEL_NPU_BUILD_TARGETis now required when building a wheel (previously defaulted toAscend910);build.shalways exports it, so the standard build flow is unaffectedtarget_providers/Ascend910/andtarget_providers/Ascend950/must expose the identical module setAdding a new cross-generation operator
No build-framework changes needed — just:
target_providers/Ascend910/<module>.pyandtarget_providers/Ascend950/<module>.pywith identical public signatures/returnstorch_npu) and the symmetry test picks up the new paths automaticallyTesting
tests/python/sgl_kernel_npu/test_target_provider.py: real-tree staging per target (910 →npu_gemma_rms_norm, 950 →npu_rms_normwith1.0 + weight), unknown target / missing directory / common-module conflict all rejected, provider symmetry enforcedtest_build_targets.py:TargetBuildPystaging end-to-end, wheel content (hasnorm/gemma_rmsnorm.py, notarget_providers/), missing env var rejected, package exclusion verified; build.sh SoC tests untouchedtest_gemma_rmsnorm_provider.py: provider paths now undertarget_providers/, mock contract unchanged