Skip to content

Fix (Qronos): Align G matrix convention with GPFQ - #1501

Draft
JP-Amboage wants to merge 1 commit into
Xilinx:devfrom
JP-Amboage:G_for_gpfq_qronos
Draft

Fix (Qronos): Align G matrix convention with GPFQ#1501
JP-Amboage wants to merge 1 commit into
Xilinx:devfrom
JP-Amboage:G_for_gpfq_qronos

Conversation

@JP-Amboage

@JP-Amboage JP-Amboage commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

Reason for this PR

The G covariance matrix in Qronos is computed as the transpose of the G matrix in GPFQ (G = X_f @ X_q^T vs G = 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 G matrix convention with GPFQ's so that G = X_q @ X_f^T consistently across all algorithms.

Three changes in src/brevitas/graph/qronos.py:

  1. update_batch: Swapped bmm operands from inp_processed.bmm(self.quant_input.transpose(2, 1)) to self.quant_input.bmm(inp_processed.transpose(2, 1)), matching GPFQ.
  2. single_layer_update (first loop of step step 1): Changed self.G[group_index, :, 0] (column access) to self.G[group_index, 0, :] (row access) to account for the transposed storage.
  3. single_layer_update (third loop of step 1): Changed self.G[group_index] + Ih to self.G[group_index].mT + Ih, explicitly transposing where the original math requires the old convention.

All other self.G accesses (scaling, permutation, NaN checks, device moves, cleanup) are convention-agnostic and required no changes. No changes were needed in GPFQ or A2GPFQ.

Testing Summary

  • Tests run locally.
  • Ran an experiment for both the previous and updated Qronos versions quantizing a Llama 1B model to int4. Both achieved the same result, a quantized perplexity of 16.625.

@JP-Amboage
JP-Amboage requested a review from Giuseppe5 March 31, 2026 13:22
@JP-Amboage
JP-Amboage marked this pull request as ready for review March 31, 2026 15:09
@nickfraser nickfraser added the next release PRs which should be merged for the next release label Apr 13, 2026
@nickfraser

Copy link
Copy Markdown
Collaborator

Needs retesting after #1504 is merged.

@nickfraser nickfraser removed the next release PRs which should be merged for the next release label Apr 20, 2026
@Giuseppe5
Giuseppe5 marked this pull request as draft June 17, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants