Qwen2 On NPU 910B Error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 39.5k
- Forks
- 4.8k
- PR merge metrics
- No merged PRs in 30d
Description
When I use the Qwen2 series of models for inference in Ascend 910B 。 There are some things that are not normal
When I set the top_p = 1.0, it gets garbled, which is obvious.
But when I set it to 0.9, it looks normal.
At first, I thought it was some problem with the NPU, but when I used the official code like
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "npu" # the device to load the model onto
max_memory = {0:"60GiB"}
model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen1.5-14B-Chat",
torch_dtype="auto",
device_map="auto",
max_memory = max_memory,
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen1.5-14B-Chat")
prompt = "你好,你叫什么"
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)
generated_ids = model.generate(
model_inputs.input_ids,
max_new_tokens=512,
temperature=0.7,
top_p = 1.0,
repetition_penalty=1.0
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
the result is right when i set top_p = 1.0 , the result is :
both ways are run in same env .
Fastchat = 0.2.36
Transformers = 4.37.0
So I've ruled out the issue of the environment for now.
why is this happening?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing Qwen2 inference on Ascend 910B using the FastChat path and the provided Transformers example, comparing top_p=1.0 with top_p=0.9. Check where generation differs between the two paths and verify the result against the reported FastChat 0.2.36 and Transformers 4.37.0 environment. Done means identifying the cause of the garbled output or documenting the required fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100