Repository navigation
Conversation
Collaborator
|
No caller produces repeated active ids after #823, so there's no workload for this fix. Closing this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #671; follows #823.
Problem
For
ggml.mul_mat_idwith MMQ and repeated nonnegative expert IDs in one token,mm_ids_helperpacked only one row per(token, expert)but counted every route when computing expert offsets. The resulting holes inids_src1/ids_dstcould produce wrong output or an illegal GPU memory access. A direct call with 9 tokens, top-k 3 and IDs[0, 0, 2]for the first token reproduced the fault on an R9700.#823 fixed the known hybrid-decode trigger by preserving inactive routes as
-1. Normal model top-k produces distinct active IDs. This PR makes the lower-level operator safe for callers that supply repeated active IDs; it does not claim an observed production model regression after #823.Change
Pack one record for every matching route and derive expert bounds from the same route count. The common fixed top-k path uses shared memory when it fits; larger inputs and generic top-k use a direct two-pass mapping. Document the per-route contract and add four CPU-reference regression cases for Q4_0 / IQ1_M and top-k 3 / 8.
Validation
FREETOKEN_DISABLE_KERNEL_CACHE=1 python -m pytest tests/kernels/test_ggml.py -q-> 65 passed. An external qualification also passed 65 combinations, including repeated active IDs, inactive-1, per-route activations and a large shared-memory fallback.sm_120-> 65 passed, 0 skipped. The original 9-token IQ1_M shape also matched a CPU reference with shared and per-route activations (3,456 elements each; max absolute errors 4.29e-6 and 5.25e-6).All tests used synthetic packed GGUF expert tensors; no model checkpoint or end-to-end serving run is claimed.