Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
prefill: decide STRATA_MMQ_GROUP_SORT per layer once, in the MMQ plan
havok2-htwobec9edf1e026
diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cppindex 4c39f4b90..e52d0f050 100644--- a/src/prefill/prefill.cpp+++ b/src/prefill/prefill.cpp@@ -1019,6 +1019,9 @@ struct MmqPlan {// and the bytes the down product reads past its matrix there (zeroed in the slot's guard before each group)std::vector<char> direct;std::vector<uint32_t> d_over;+ // STRATA_MMQ_GROUP_SORT=1 (without STRATA_MMQ_RESIDENT_SORT_NE): per MMQ layer, whether both products' 16-expert+ // launches run whole tiles on every visible GPU (mmq::whole_tiles), so its full groups may be taken in row-count order+ std::vector<char> group_sort;};const MmqPlan& mmq_plan() {static const MmqPlan plan = [] {@@ -1066,6 +1069,19 @@ const MmqPlan& mmq_plan() {std::fprintf(stderr, "strata: prompt MMQ reads resident experts in place (STRATA_MMQ_DIRECT=1): %lld of %lld ""layers\n", (long long) nd, (long long) layers);}+ // the verdict depends only on the layer's formats and the visible GPUs: taken once here, not per chunk+ p.group_sort.assign(p.layer.size(), 0);+ if (on && detail::mmq_group_sort_requested() && !detail::mmq_resident_sort_requested()) {+ int64_t ns = 0;+ for (int64_t l = 0; l < layers; ++l) {+ if (!p.layer[(size_t) l]) continue;+ const int gt = lay.native ? lay.fmt[(size_t) l].gu_type : 42, dt = lay.native ? lay.fmt[(size_t) l].d_type : 42;+ p.group_sort[(size_t) l] = mmq::whole_tiles(gt, 1280, MMQ_GROUP) && mmq::whole_tiles(dt, N, MMQ_GROUP);+ ns += p.group_sort[(size_t) l];+ }+ std::fprintf(stderr, "strata: prompt MMQ sorts the full expert groups (STRATA_MMQ_GROUP_SORT=1): %lld of %lld "+ "layers\n", (long long) ns, (long long) layers);+ }return p;}();return plan;@@ -3379,12 +3395,11 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri// (its padded tile rows) is close to its experts' own; slot/src/off are rebuilt coherently// before the upload, the routed ids, weights and the within-expert row order stay as they are.// STRATA_MMQ_GROUP_SORT=1 (opt-in, exact): the same order for the full groups only, where each- // tile is one block's whole K (mmq::whole_tiles); the partial group keeps its ID order and bits.+ // tile is one block's whole K (MmqPlan::group_sort); the partial group keeps its ID order and bits.// STRATA_MMQ_RESIDENT_SORT_NE=1 takes precedence (it sorts the partial group too).const bool sort_all = detail::mmq_resident_sort_requested();- const bool sort_full = !sort_all && detail::mmq_group_sort_requested() && use_mmq &&- order.size() >= (size_t) MMQ_GROUP && mmq::whole_tiles(mmq_gt, 1280, MMQ_GROUP) &&- mmq::whole_tiles(mmq_dt, N, MMQ_GROUP);+ const bool sort_full = !sort_all && use_mmq && mmq_plan().group_sort[(size_t) l] &&+ order.size() >= (size_t) MMQ_GROUP;if (detail::mmq_resident_sort_eligible((sort_all || sort_full) && on_peer.empty(), use_mmq, lay.native,m.cache != nullptr, m.host_res ? m.host_res + (size_t) l * m.g->n_expert : nullptr,m.g->n_expert, stream_all, !stream_all || seq_start[(size_t) l] == seq_start[(size_t) l + 1]))