1 Commits

Author SHA1 Message Date
xvxuopop
1fded918ac [docs] add security notes to NPU Docker overviews (#10883) 2026-10-10 15:29:22 +08:00
3 changed files with 21 additions and 5 deletions

View File

@@ -184,6 +184,15 @@ To build an image with Docker Compose without starting a container, use `docker
- Legacy NPU tags are replaced by the `latest-<910b|a3|950>-<ubuntu|openeuler>` format.
- Validate the exact driver, firmware, CANN, and SoC combination before production deployment.
## Security Risks
When running containers with these images, be aware of the following security risks:
- Running as the `root` user: Containers run as the `root` user by default, which can introduce security risks. In production environments, it is recommended to create a non-privileged user to run the application.
- Lack of CPU and memory resource limits: Not setting resource limits may cause a container to consume excessive system resources and affect host performance. It is recommended to use the `--cpus` and `--memory` parameters to limit resource usage.
- Device use with `rwm` permissions: The NPU device is assigned read, write, and `mknod` permissions. Although these are required for functionality, the scope of permissions should be carefully evaluated in security-sensitive environments.
## License and Disclaimer
LlamaFactory is distributed under the [Apache License 2.0](../../LICENSE).

View File

@@ -184,6 +184,16 @@ docker compose --profile 950-openeuler up -d
- 旧式 NPU tag 已由 `latest-<910b|a3|950>-<ubuntu|openeuler>` 格式取代。
- 正式部署前,请验证具体驱动、固件、CANN 和 SoC 组合的兼容性。
## 安全风险
在运行容器时,需要注意以下安全风险:
- 使用 `root` 用户运行:容器默认以 `root` 用户身份运行,可能带来安全隐患。建议在生产环境中创建非特权用户来运行应用程序。
- 缺少 CPU 和内存资源限制:未设置资源限制可能导致容器消耗过多系统资源,影响宿主机性能。建议使用 `--cpus` 和 `--memory` 参数限制资源使用。
- 设备使用 `rwm` 权限:为 NPU 设备分配了读写和 `mknod` 权限,虽然功能运行需要,但在安全敏感环境中应谨慎评估权限范围。
## 许可证与免责声明
LlamaFactory 基于 [Apache License 2.0](../../LICENSE) 发布。

View File

@@ -86,12 +86,9 @@ def _check_fla_dependencies() -> None:
def patch_qwen3_5_forward_npu(model: "PreTrainedModel") -> None:
"""Patch for Qwen3.5 models on NPU by importing torch_npu to enable torch.cuda compatibility.
"""Replace the Qwen3.5 gated delta rule kernel with the NPU-compatible implementation.
On NPU, torch.cuda operations will fail unless torch_npu is imported.
torch_npu provides compatibility layer that maps torch.cuda calls to NPU operations.
Also replaces chunk_gated_delta_rule with NPU-compatible implementation.
Skip the patch unless an Ascend910-series device is detected and triton_ascend is installed.
"""
import importlib.metadata