This is an Ascend NPU-adapted deployment for hmellor/tiny-random-LlamaForCausalLM (LlamaForCausalLM, text-generation).
npu:0 with synchronized timing and CPU consistency validationModel and tensors are explicitly placed on npu:0 and verified:
next(model.parameters()).device == npu:0input_ids.device == npu:0output token ids device == npu:0Synchronization uses torch.npu.synchronize() before/after timing.
Validated on Ascend 910 (2x NPU, 61 GiB free per card, torch_npu 2.9.0.post1).
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch, torch_npu
model_dir = "./model" # or local path
tokenizer = AutoTokenizer.from_pretrained(model_dir)
model = AutoModelForCausalLM.from_pretrained(model_dir, torch_dtype=torch.float32).to("npu:0")
inputs = tokenizer(["Hello, my name is"], return_tensors="pt").to("npu:0")
outputs = model.generate(**inputs, max_new_tokens=32, do_sample=False)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))See inference.py for full synchronized example.

inference.py - NPU inference with device proof and perfrequirements.txt - dependenciesassets/*.png - xterm.js evidence screenshots