Fix (Qronos): Align G matrix convention with GPFQ - #1501
Draft
JP-Amboage wants to merge 1 commit into
Draft
Conversation
JP-Amboage
marked this pull request as ready for review
March 31, 2026 15:09
Collaborator
|
Needs retesting after #1504 is merged. |
Giuseppe5
marked this pull request as draft
June 17, 2026 15:20
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.
Reason for this PR
The
Gcovariance matrix in Qronos is computed as the transpose of theGmatrix in GPFQ (G = X_f @ X_q^TvsG = X_q @ X_f^T), despite both being the same conceptual quantity. Since GPFQ is the base class and its convention is shared by A2GPFQ, this inconsistency hurts readability and makes it harder to reason about the code across algorithms.Changes Made in this PR
Aligned Qronos's
Gmatrix convention with GPFQ's so thatG = X_q @ X_f^Tconsistently across all algorithms.Three changes in
src/brevitas/graph/qronos.py:update_batch: Swappedbmmoperands frominp_processed.bmm(self.quant_input.transpose(2, 1))toself.quant_input.bmm(inp_processed.transpose(2, 1)), matching GPFQ.single_layer_update(first loop of step step 1): Changedself.G[group_index, :, 0](column access) toself.G[group_index, 0, :](row access) to account for the transposed storage.single_layer_update(third loop of step 1): Changedself.G[group_index] + Ihtoself.G[group_index].mT + Ih, explicitly transposing where the original math requires the old convention.All other
self.Gaccesses (scaling, permutation, NaN checks, device moves, cleanup) are convention-agnostic and required no changes. No changes were needed in GPFQ or A2GPFQ.Testing Summary