Repository navigation
spacemit: fix partial output tiles for dense Q8_0 and Q6_K matmul - #98
Merged
alex-spacemit merged 1 commit intoDec 4, 2026
Merged
Conversation
Assisted-by: Codex
alex-spacemit
merged commit Dec 4, 2026
a926ebd
into
spacemit-com:mtmd-backend
13 of 20 checks passed
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.
Problem and behavior
Correctness fix, not a quantization-accuracy or performance optimization. Dense Q8_0/Q6_K MUL_MAT can stage incomplete packed weights into TCM when the final output tile has fewer than 32 columns. The packed tile still contains all 32 rows. The IME2 M4 kernel can also store past the logical output width.
Copy complete physical N32 weight blocks while retaining the logical output count, then bound M4 vector stores by the remaining columns.
Change and design
ime.cpp: round TCM weight-copy extents to full packed blocks, including initial and subsequent staged tiles; keep actual output counts for computation.ime2_kernels.cpp: set output-store VL to the remaining width in the four-row I8 kernel.Related open work: #78 contains an overlapping M4 tail-store fix among its broader CPY/Q8/MTP changes. This PR additionally fixes dense Q8_0/Q6_K physical TCM staging and is independently based on current mtmd-backend. The shared store hunk should be reconciled if both are merged; this is not a claim that the hunk is unique to this PR.
Scope is limited to
ggml/src/ggml-spacemit/. Impact classification: execution-path change. No changes to the retired CPU backend, model code, public API or test sources. Local validation fixtures are excluded. This independently based module commit preserves the target branch's common MTP graph/rollback paths; experimental noMTP-wide reversions are not submitted. No new external dependency is added.Validation
Base:
mtmd-backendat3f5ce5fd84f4dc6e7e621642cfef0143d49e7c24. Candidate:8fae2acc369ea14ba4315229d703a5d0a7d662f4; source treeb6d4493f2bbdc5b164b76b40cbb36f2d63e54247.The exact submitted production source passed a RISC-V Release cross-build of
ggml-spacemitusing the SpacemiT v1.1.2 toolchain (GCC 14.3),cmake/riscv64-spacemit-linux-gnu-gcc.cmake,GGML_SPACEMIT=ON,GGML_RV_ZBA=ON,GGML_OPENMP=OFF, Spert 0.6.3 and SpacemiT ORT 2.0.6. Build target:cmake --build <build> --target ggml-spacemit --parallel 24. Backend DSO SHA-256:2a892969db4eb878d3e3b49c615207a07a8349db5b7b6751a4df5eb4a0255c90. Source hashes were checked before/after the build and against the committed files.Reproduce with SPACEMIT0/TCM, Q6_K weights [K=256,N=65], F32 activations [256,M=1], and an independent CPU-only reference. The earlier backend returned NaN at column 64. Repeat at M=4 to exercise the last-tile store boundary. Numerical acceptance: NMSE <= 5e-4 over the complete output.
Archived K3-179 results:
Cases include N=33/65/513/1025 and aligned controls, including M2/M4. Run labels:
i8-tail-baseline-v38-board179-r1andi8-gemv-tiles-v41-board179-r1. The archived corrected package contains the same two fixes; these results are carried forward, not fresh execution of the PR head.git diff --check, UTF-8/LF and added-line whitespacePerformance
No speedup is claimed. This fixes incomplete reads and out-of-bounds writes; copying physical padding may increase bytes transferred for a partial tile. A final-head model performance comparison is NOT RUN. The archived evidence is operator correctness evidence, not end-to-end model validation.
Risks and limits
The old 20-case and new 24-case totals are different suites, so they are not a same-denominator pass-rate comparison. Exact final-head target execution and affected model coverage remain pending. Coordinate the overlapping M4 store fix with #78.
The historical module comparisons used the common noMTP experimental baseline on top of
3f5ce5fd; this PR instead preserves upstream common MTP behavior. Historical results are not claimed as new measurements of the final independent head. Raw build/test/benchmark archives are retained privately and are not publicly attached; the cases, results, artifact identities and limits above are the reviewable record here. Exact-input model replay is not provided by these summaries. Required final-head target evidence remains pending; this submission requests review, not a waiver or a claim of merge readiness. No maintainer exception has been granted. CI status is separate from the local results above.AI assistance and contributor responsibility
Codex assisted with source preparation, static review, local build/check execution, historical evidence analysis and this PR description. The contributor discussed the module design and explicitly requested publication. No unrecorded personal review, maintainer approval or target execution is asserted. The contributor remains responsible for reviewing the submitted code and claims and addressing review feedback.