Files
sglang/python/sglang/srt/utils/torch_npu_patch_utils.py
T
4e14b50c48 [NPU]Support torch_npu profiler patch API drift (#26356)
Co-authored-by: leland17 <lileliao@foxmail.com>
Co-authored-by: OmX <omx@oh-my-codex.dev>
Co-authored-by: ronnie_zheng <zl19940307@163.com>
2026-06-06 16:27:51 +03:00

18 lines
540 B
Python

from collections.abc import Sequence
from typing import Any
def apply_torch_npu_patches(torch_npu: Any, patches: Sequence[Sequence[Any]]) -> None:
"""Apply torch_npu patches across old and new torch_npu patch APIs."""
if hasattr(torch_npu, "_apply_patches"):
torch_npu._apply_patches(patches)
return
if hasattr(torch_npu, "_apply_all_patches"):
torch_npu._apply_all_patches()
return
raise AttributeError(
"torch_npu must provide either _apply_patches or _apply_all_patches"
)