Fix reduction axis and column scaling in the transposed projection - #74
Merged
Conversation
projection_asm already uses blen * mlen for the matrix operand's column index in its main loop, matching the row-granular projection ABI the emulator documents in matrix_machine.rs. Two sibling call sites, _emit_projection_chunk and projection_T_asm, were never updated and still scale by blen, so they address the wrong column group at any geometry with more than one tile per MLEN. projection_T_asm also reduces over the wrong axis. The weight tile is stored (out_features, in_features), so the reduction runs down its columns and needs M_TMM with the operands swapped; M_MM pairs the activation's hidden dimension with out_features instead. With M_MM the logits correlate 0.003 with the reference, and 0.998 with M_TMM.
There was a problem hiding this comment.
Pull request overview
Fixes incorrect addressing and reduction behavior in the transposed projection ASM template so that weight tiles are indexed with the correct per-MLEN column stride and the dot-product reduction runs over the intended axis (weight columns).
Changes:
- Correct matrix-SRAM within-group column offset scaling from
* blento* blen * mlenin_emit_projection_chunkandprojection_T_asm. - Switch the transposed projection inner loop from
M_MMtoM_TMMand swap operand order to match theVector @ Matrix^Tsemantics.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Bug: Incorrect column indexing and reduction axis in projection ASM
projection_asmalready usesblen * mlenfor the matrix operand's column index in its main loop, matching the row-granular projection ABI documented by the emulator inmatrix_machine.rs. Two sibling call sites,_emit_projection_chunkandprojection_T_asm, were never updated and still scale byblenalone, so they address the wrong column group at any geometry with more than one tile perMLEN.projection_T_asmalso reduces over the wrong axis. The weight tile is stored as(out_features, in_features), so the reduction must run down its columns, which requiresM_TMMwith the operands swapped. UsingM_MMinstead pairs the activation's hidden dimension without_features, which is incorrect.With
M_MM, the logits correlate 0.003 with the reference. WithM_TMM, the correlation is 0.998.