Repository navigation
Conversation
| const int32_t p = top_k_row[t*sk0]; | ||
|
|
||
| // the picks in index order: the order of top_k is arbitrary, the attention over the list depends on it | ||
| slot = top_k_rows_rank(top_k_row, sk0, n_top, t)*n_blk + e % n_blk; |
There was a problem hiding this comment.
We can add a dedicated kernel to sort this separately (78e1c9a), but that adds complexity for no good reason. At least for the current inputs.
|
Checked the ungrouped index-order behavior with a small native CPU harness at With the same explicit expected row lists and masks in both arms:
The cases cover all six permutations of three picks, two rows, I32/F16/F32 outputs, live/dead scores, two-cell block maps, implicit cells, negative picks, out-of-range cells, extras and padding. They execute the real This checks Harness, literal expectations, source/library hashes and logs: https://gist.github.com/mercant1982/6a9598800dd4622fe7bbad0165849fe7 |
…gml-org#32247 + ggml-org#32297) Port of the remaining commits of ggml-org#32247 (648c950, b46da3e, cabf968, 5444082) and the top-k order fix ggml-org#32297 (7d8eaa6..34fb50d): - GGML_OP_TOP_K_ROWS: the cells that ggml_top_k_mask keeps as a list per row or per group of rows (I32), or the matching mask. CPU and CUDA, picks listed in index order. - qwen4exp attends through the row lists with ggml_flash_attn_ext_rows, one list per token for decode and drafts, one per 8 tokens for prompts. - the CUDA vec FA kernel reads quantized, BF16 and F8 K/V in place through kv_rows. - the row lists are probed together with the row-list attention, a backend without TOP_K_ROWS keeps the mask path. Fabric adaptations: build_qsa_sel keeps the fabric sections argument, RPC major 119 (temp-12032 is at 118 with TOP_K_MASK already in the enum). Assisted-by: Claude Opus 5.5
…gml-org#32247 + ggml-org#32297) Port of the remaining commits of ggml-org#32247 (648c950, b46da3e, cabf968, 5444082) and the top-k order fix ggml-org#32297 (7d8eaa6..34fb50d): - GGML_OP_TOP_K_ROWS: the cells that ggml_top_k_mask keeps as a list per row or per group of rows (I32), or the matching mask. CPU and CUDA, picks listed in index order. - qwen4exp attends through the row lists with ggml_flash_attn_ext_rows, one list per token for decode and drafts, one per 8 tokens for prompts. - the CUDA vec FA kernel reads quantized, BF16 and F8 K/V in place through kv_rows. - the row lists are probed together with the row-list attention, a backend without TOP_K_ROWS keeps the mask path. Fabric adaptations: build_qsa_sel keeps the fabric sections argument, RPC major 119 (temp-12032 is at 118 with TOP_K_MASK already in the enum). Assisted-by: Claude Opus 5.5
qwen4exp : faster QSA sparse attention (ports of ggml-org#32247, ggml-org#32297, ggml-org#31084 + row-list indexer)
…gml-org#32247 + ggml-org#32297) Port of the remaining commits of ggml-org#32247 (648c950, b46da3e, cabf968, 5444082) and the top-k order fix ggml-org#32297 (7d8eaa6..34fb50d): - GGML_OP_TOP_K_ROWS: the cells that ggml_top_k_mask keeps as a list per row or per group of rows (I32), or the matching mask. CPU and CUDA, picks listed in index order. - qwen4exp attends through the row lists with ggml_flash_attn_ext_rows, one list per token for decode and drafts, one per 8 tokens for prompts. - the CUDA vec FA kernel reads quantized, BF16 and F8 K/V in place through kv_rows. - the row lists are probed together with the row-list attention, a backend without TOP_K_ROWS keeps the mask path. Fabric adaptations: build_qsa_sel keeps the fabric sections argument, RPC major 119 (temp-12032 is at 118 with TOP_K_MASK already in the enum). b12429 adaptation: b12429's build_qsa_sel has no fabric sections argument, so only sel_rows is added to it. RPC goes to major 121 with GGML_OP_COUNT 131 instead of 119/134: qvac-b12429 was at 120 with 130 ops (upstream's prune, ggml-org#29801, removed ADD1, DIAG_MASK_INF and DIAG_MASK_ZERO, and ROPE_FLUX took 120), and TOP_K_ROWS goes in right after TOP_K_MASK, which moves every later op id. Assisted-by: Claude Opus 5.5 (cherry picked from commit ea7ee93)
Against #32247
Overview
Updates both kernels to list the picks in index order (smallest pool index first) so that attention always sums it in the same order.
Additional information
Reproducer for the ungrouped path:
Reports here:
Without the fix:
The grouped path (
n_group > 1) already lists picks in index order.Graph-level alternative: #32299
Requirements