Greedy decoding (top_k=1) is not reproducible on NPU — identical request gives different output
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cpp
- Lĩnh vực
- backend, machine-learning
Hướng nghiên cứu
Start by reading server/rest_handler.cpp:491, common/AutoModel/automodel.cpp:624, and common/modules/sampler.cpp:447 to confirm the request reaches the greedy sampler as described. Then investigate where the NPU engine produces the logits passed to sample_greedy(); the report attributes variation to that closed-source path and provides repeatable requests for comparison. Done means identical requests produce identical outputs on one server instance, without the long-prompt collapse.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
With top_k: 1 and temperature: 0, /v1/chat/completions returns different
completions for byte-identical requests on a single unrestarted server
instance. Sampler::sample() short-circuits to sample_greedy() when
top_k == 1, so this is a pure argmax over the logits — there is no sampling
left to explain the variation. That points at the logits themselves not being
reproducible on the NPU path.
On longer prompts the same instability tips generation into an absorbing
degenerate state that runs to the token limit — measured at 5/10 runs on a
~5,300-token prompt, detailed below. That collapse resembles #611, but the
greedy case here is a much smaller and more tractable reproducer.
Environment
- FLM v1.0.9, Linux portable (Debian) build
- AMD Ryzen AI 9 HX 370 (Strix Point, XDNA2 NPU), PCI
1022:17F0 - Driver:
amdxdna(amd/xdna-driver), XRT runtime - Model:
qwen3:1.7b(Qwen3-1.7B-NPU2) flm serve qwen3:1.7b -p <port> -c 8192- Non-streaming, single client, no concurrent requests, no other load on the NPU
Reproduction
Start the server, then send the same request four times:
flm serve qwen3:1.7b -p 52629 -c 8192
for i in 1 2 3 4; do
curl -s localhost:52629/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{"model":"qwen3:1.7b",
"messages":[{"role":"user","content":"Summarize this log line in one sentence, keeping the exact numbers: 2026-10-18 09:41:03 WARN ingest latency_ms=842 queue_depth=1204 retries=3 dropped_events=12 node=ingest-07"}],
"max_tokens":150,
"temperature":0,
"top_k":1,
"chat_template_kwargs":{"enable_thinking":false}}' \
| jq -r '.choices[0].message.content' | sha256sum
done
Expected
Four identical hashes.
Actual
Three runs agree, one differs (output lengths 430 / 454 / 430 / 430):
ef105a7bc05c7a97...
8daee02ceb783861...
ef105a7bc05c7a97...
ef105a7bc05c7a97...
The flip rate is not fixed — a separate 4-run batch on a different instance
also gave 2 distinct outputs, and a 5-run batch at temperature: 0 without
top_k gave 5 distinct outputs.
The REST/plumbing layer is not at fault
Checked first, since the obvious explanation would be that client parameters
never reach the engine. They do. AutoModel's setters reject out-of-range
values with a printed warning, so deliberately invalid values are a probe for
whether the setter was reached. All three fire:
| request | server log |
|---|---|
"top_k": 0 |
Top-k must be greater than 0 |
"temperature": -1.0 |
Temperature must be greater than 0.0 |
"top_p": 5.0 |
Top-p must be between 0.0 and 1.0 |
So the path below is live and correct as written:
server/rest_handler.cpp:491configure_chat_engine_parameters()→set_topk(top_k)common/AutoModel/automodel.cpp:624AutoModel::set_topk()→sampler->top_k = topkcommon/modules/sampler.cpp:447Sampler::sample()→if (this->top_k == 1) return sample_greedy(x);
sample_greedy() is a plain max-and-index over x with a deterministic
tie-break, and sampler_topk_apply() has the documented lowest-token-id
tie-break for bf16 ties. Nothing in the OSS sampler can produce this.
That leaves the buffer x handed to the sampler — i.e. the logits produced by
the closed-source qwen3_npu engine — as the only remaining source of
variation.
The same instability produces a hard failure on longer prompts
On a ~5,300-token summarisation prompt (temperature: 0, thinking disabled,
max_tokens: 900), 10 runs across two different prompts and two server
instances:
| runs | outcome |
|---|---|
| 5/10 | normal summary, 590-800 tokens |
| 5/10 | output collapses, runs to the full 900-token cap |
Every one of the five collapsed runs returned the byte-identical output
(sha256 prefix da9963d3d87625d9) despite coming from different prompts and
different seeds — a single absorbing state, not input-dependent noise.
It is also sticky within an instance: on the second instance, run 0 was
normal and runs 1-4 all collapsed, with no recovery until the server was
restarted.
Controls run to rule out the obvious alternatives:
- Not the prompt. The fixture is real varied prose with a measured
self-similarity of 0.048 (a deliberately repetitive earlier fixture scored
0.335). A 4B model served by llama.cpp on the iGPU, given byte-identical
prompts, produced 0/12 collapses and recalled 100% of the planted facts. - Not sampling. Same behaviour at
temperature: 0, and see the greedy
(top_k=1) result above. - Not the load-time warning from #611.
Still some invalid buffer, last try!did not appear in the logs of the instances that collapsed.
Why it matters
It is not just a reproducibility nicety. It makes benchmarking and regression
testing on NPU unsound: any single-sample A/B comparison is measuring noise,
and the occasional tip into the degenerate attractor turns it into a
correctness problem for long or repetitive prompts.
Questions
- Is greedy decoding expected to be bit-reproducible on the NPU backend, or is
some nondeterminism (scheduling, buffer reuse, accumulation order)
inherent to the current engine? - Is this the same underlying defect as #611, or a separate one?
- Is there a flag or build that forces a reproducible decode path, even at a
throughput cost?
- Ngôn ngữ chính
- C++
- Star
- 2.1k
- Fork
- 184
- Merge trung bình
- 12 giờ 22 phút
- Pull request đã merge (30 ngày)
- 239
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ROCm/FastFlowLM
-
Update Gemma tokenizer.json after Google's recent fixCó thể đã có người làm @four1er đã nhận 6 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ROCm/FastFlowLM#1057 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ROCm/FastFlowLM#757 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
No valid checkpoint to restore + Max length reached on multi-turn tool calls (Qwen3.6-MoE, NPU)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
ROCm/FastFlowLM#744 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Truncated tool call is emitted as a complete one (unterminated heredoc reaches the client)Có thể đã có người làm @Javinator9889 đã nhận 72 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ROCm/FastFlowLM#741 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Download timeoutCó thể đã có người làm @stdevPavelmc đã nhận 200 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
ROCm/FastFlowLM#520 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ROCm/FastFlowLM
Issue tương tự
-
bug good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
difficulty:easy func:gui prio:normal type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NatronGitHub/Natron#2118 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
-
bug difficulty:easy prio:low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
NatronGitHub/openfx-io#523 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
ArduPilot/ardupilot_gazebo#195 ·