From 0133a62df6eec2d2a3c908a5309639609cdd0687 Mon Sep 17 00:00:00 2001 From: LHXuuu Date: Thu, 20 Nov 2025 16:42:02 +0800 Subject: [PATCH 1/2] support npu platform Signed-off-by: LHXuuu --- src/llmcompressor/pipelines/sequential/helpers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/llmcompressor/pipelines/sequential/helpers.py b/src/llmcompressor/pipelines/sequential/helpers.py index e13144689..261538dd9 100644 --- a/src/llmcompressor/pipelines/sequential/helpers.py +++ b/src/llmcompressor/pipelines/sequential/helpers.py @@ -538,6 +538,8 @@ def dispatch_for_sequential(model: PreTrainedModel) -> PreTrainedModel: if torch.cuda.is_available(): offloaded_dispatch(model, execution_device=torch.device("cuda:0")) + elif torch.npu.is_available(): + offloaded_dispatch(model, execution_device=torch.device("npu:0")) elif hasattr(torch, "xpu") and torch.xpu.is_available(): offloaded_dispatch(model, execution_device=torch.device("xpu:0")) else: From f5edf05400938ba7f1411784866517e1c9ade7ec Mon Sep 17 00:00:00 2001 From: LHXuuu Date: Thu, 20 Nov 2025 16:47:03 +0800 Subject: [PATCH 2/2] clean code Signed-off-by: LHXuuu --- src/llmcompressor/pipelines/sequential/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llmcompressor/pipelines/sequential/helpers.py b/src/llmcompressor/pipelines/sequential/helpers.py index 261538dd9..273ed76d4 100644 --- a/src/llmcompressor/pipelines/sequential/helpers.py +++ b/src/llmcompressor/pipelines/sequential/helpers.py @@ -538,7 +538,7 @@ def dispatch_for_sequential(model: PreTrainedModel) -> PreTrainedModel: if torch.cuda.is_available(): offloaded_dispatch(model, execution_device=torch.device("cuda:0")) - elif torch.npu.is_available(): + elif hasattr(torch, "npu") and torch.npu.is_available(): offloaded_dispatch(model, execution_device=torch.device("npu:0")) elif hasattr(torch, "xpu") and torch.xpu.is_available(): offloaded_dispatch(model, execution_device=torch.device("xpu:0"))