Skip to content
المشاريع

حول

SGLang kernel library for NPU

أدوات التطوير

كيف تُقاس هذه الأرقام

210 نجمة271 التفرعات +2 خلال 24 ساعة

النمو المقاس للنجوم

خلال 24 ساعة
+٢
خلال 7 أيام
+٤
خلال 15 يومًا
+٧
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

SGLang-Kernel-NPU

中文 · Operator API · Build guide · Contributing

SGLang-Kernel-NPU provides NPU inference operators for SGLang, including attention, mixture-of-experts routing, normalization and sampling. In Python, import a public operator from sgl_kernel_npu.operators by domain. Each operator documents its arguments, supported architectures and the implementation that impl="auto" selects.

Build and install the operator wheel

Use the repository-root setup.py to build sgl-kernel-npu. Start in the repository root on Linux with the CANN development toolkit, a C++17 compiler, CMake 3.20 or newer, and a Python build environment with matching PyTorch and torch_npu. The example uses a common toolkit location and targets arch 2201. For arch 3510, use --arch-version 3510.

source /usr/local/Ascend/ascend-toolkit/set_env.sh
python3 setup.py --arch-version 2201
python3 -m pip install --force-reinstall --no-deps output/sgl_kernel_npu-*.whl

By default the wheel includes the Python package, all registered native operators supported on the target architecture and the third-party libraries configured for that CANN version and architecture. To compile a single operator while developing it, select its ID with --ops. For prerequisites, third-party selection, standalone CANN installers and a public API test, see the build and installation guide.

The default arch 2201 main wheel includes all five operators from the original attentions plugin. Use the public APIs in sgl_kernel_npu.operators. Applications that still call torch.ops.attentions.* can use the separate plugin wheel. See the API mapping and compatibility build.

Prebuilt packages are available on the releases page. Match the archive to your NPU, CPU architecture, CANN, PyTorch and Python versions.

Deprecated kernel packaging. bash build.sh -a kernels builds the legacy sgl-kernel-npu wheel. Running bash build.sh without arguments selects all. On arch 2201 this builds the legacy wheel alongside the independent packages. Arch 3510 does not support all. Installing the legacy wheel replaces the current sgl-kernel-npu installation in the same Python environment. Use the repository-root setup.py for new operators. The legacy build still includes catlass_matmul_basic when BUILD_CATLASS_MODULE=ON.

Other packages in this repository

These components produce separate wheels in output/. Run the command for the component you need from the repository root.

Package Purpose Build command
DeepEP Token dispatch and combine across experts for MoE models. See the component guide for its build prerequisites and target selection. bash build.sh -a deepep
Torch Memory Saver Pause and resume NPU allocations made inside a PyTorch region. bash build.sh -a memory-saver

See the DeepEP performance tables for the benchmark results and test conditions.

Develop an operator

Start with the contribution guide for API registration, an independent reference and public API tests. The documentation index maps those steps to source directories and includes a worked ELU example. The refactor roadmap tracks the wider migration.

For an AI-generated guide to the source code, see DeepWiki.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…