Pull in the upstream FLM sampler fast path and the prefill-length shift fix
Upstream FLM (ROCm/FastFlowLM) has moved on since we forked, and a couple of the changes are worth having. Most are not.
Where we stand
We were cut from upstream 6002e0f3 (2026-09-01, "feat: update qwen3.5/3.6 dll/so" — just after v1.0.4). Upstream main is now at dae4c754 (2026-09-03), 20 commits ahead.
There is no shared history between the two repos — the fork started from a squashed import — so nothing here is a merge. To get the commits locally:
git fetch https://github.com/ROCm/FastFlowLM.git 'refs/heads/*:refs/remotes/rocm/*'
Then cherry-pick by hash.
What to take
1. The sampler greedy fast path — 704cbad7 (the one that actually matters)
When top_k == 1, today's Sampler::sample() does a startling amount of work for an answer that is just "which logit is biggest":
- copies the whole vocabulary of bf16 logits into an fp32 buffer,
- builds a vocab-sized array of
{logit, token_id, prob}triples, partial_sorts it,- runs three full-vocabulary softmax passes (top-k, top-p, min-p),
- then picks the single top element and throws the rest away.
Softmax, temperature, top-p and min-p are all order-preserving, so with k == 1 none of it can change the winner.
Upstream adds Sampler::sample_greedy(), which scans the bf16 logits where they already are with an AVX2 running argmax — no fp32 vocabulary buffer is written at all. That second part matters more than it looks: the logits come back in device-mapped memory, where reading one element at a time is punishing, so the new scan pulls eight at a time.
This is on our hot path. src/open_qwen36/engine.hpp goes through the same Sampler, the Qwen3.6 vocabulary is ~151k entries, and the open engine runs at roughly 7 tok/s — the work being skipped is per-token and not small.
The same change also fixes a real correctness wart. bf16 logits tie exactly often enough to matter over a 151k vocabulary, and partial_sort is not stable, so which token won a tie was decided by the sort's internals — it could disagree with sample_greedy()'s argmax and could vary between builds. The tiebreak is now "lowest token id wins", which is reproducible and consistent between the two paths.
Files: src/common/modules/sampler.cpp, src/include/modules/sampler.hpp. Both are byte-identical to our fork point, so they apply clean.
2. _chunked_insert shift on a non-positive prefill length — also 704cbad7
src/common/AutoModel/automodel.cpp:227:
max_prefill_len = 1 << static_cast<int>(std::ceil(std::log2(max_prefill_len)));
If max_prefill_len is zero or negative — an unset or degenerate limit — log2 is not a number you can shift by, and the result is undefined behaviour before the < 512 branch below ever gets a chance to handle it. Upstream guards the rounding with if (max_prefill_len > 0) and lets the existing < 512 path mean "no chunking", which is what it already meant.
The same commit adds three things worth having for our own harness work:
log_raw_output— lets a caller suppress theModel RAW Output:dump at end of turn.forward_on_eos— lets a caller skip the extra forward on the EOS token. That forward exists to keep the KV cache aligned withtoken_historyfor a following turn; a model that rewinds or clears between turns is paying for state it discards.get_profiler_ms(slot)plus aprofiler_slot_tenum, so a benchmark can break a turn down into prefill / decode / sampling / tokenize instead of only reading TTFT.
Note: 704cbad7 is one commit covering both items above and a pile of Hunyuan-MT2 work we do not want. This needs a partial pick, not a straight cherry-pick.
3. HRX wrapper error handling — 7505ef7b (low priority)
run::record() and run::start() in src/include/hrx_cpp/hrx_cpp.hpp currently log a dispatch failure and then carry on as if it had succeeded. Upstream makes them return a status and stop.
We build XRT by default (FLM_USE_HRX=OFF), so this changes nothing for our builds today — but we carry the header, and it is strictly better than what is there. One small loss: it also deletes the HRX_NOCACHE environment escape hatch that let you bypass the executable cache while debugging.
4. .github/workflows/windows-build.yml — 5d47f15d (reference only)
We have no .github/ directory at all. Upstream's portable Windows build workflow is worth reading before we write our own, whether or not we adopt it as-is.
What to skip, and why
6a79009c"fix: 32k bench length" — a no-op for us.66999399dropped the benchmark default from 32768 to 4096 and this puts it back. Net change since our fork point is a trailing newline.- Hunyuan MT2 (
66999399,d5b598c6,9cce19b6,fffcbe40,10df85a3) — new closed model family:modeling_hunyuan.*,src/test/hunyuan_npu/, new xclbins, newmodel_list/model_infoentries. - Rebuilt closed engine binaries (
631da43d,ac54bca0,5370949f,1e6981b1,d0de2294,af31bd98,34c6fc39,06163416) — ~45.dll/.lib/.soblobs undersrc/lib/. 13fbf0de/82c1abe9v1.0.5 bump and model list updates — version strings, installer manifests, and entries for models we do not ship.
Suggested shape of the work
- Branch off
main. - Take
sampler.cpp+sampler.hppwholesale from704cbad7— they apply clean. - Hand-apply the
automodel.cpp/automodel.hpphunks from the same commit, leaving the Hunyuan include and members out. - Confirm the open Qwen3.6 path still produces identical output, and measure tok/s before and after — greedy decode is the default there, so the win should be visible.
- Optionally take
7505ef7bforhrx_cpp.hppas a separate commit, so it can be reverted on its own if the HRX build ever comes back into use.