[Ascend]support xgrammar backend for ascend npu (#12310)

Co-authored-by: ronnie_zheng <zl19940307@163.com>
This commit is contained in:
ash-sigh
2025-11-16 11:39:24 +08:00
committed by GitHub
parent 597d416070
commit 12c789ebd1

View File

@@ -104,7 +104,7 @@ class XGrammarGrammar(BaseGrammarObject):
return vocab_mask.to(device, non_blocking=True)
def apply_vocab_mask(self, logits: torch.Tensor, vocab_mask: torch.Tensor) -> None:
if logits.device.type == "cuda":
if logits.device.type == "cuda" or logits.device.type == "npu":
if _is_hip:
apply_token_bitmask_inplace_cuda(logits, vocab_mask)
else: