Skip to content

Adding Scaling Nodes (Tagged Mul) below Producers / Removing Unitary MetaOp

Merge Request: Enhancements to the PTQ Pipeline

This merge request introduces significant improvements to the PTQ pipeline, focusing on better handling of Producer nodes (constant value nodes) for weight and bias quantization. These changes aim to improve the pipeline's transparency and modularity while maintaining equivalent results. Additionally, it introduces the use of dynamicAttribute as a tag to identify PTQ-related nodes.


Key Changes

1. Replacement of Meta-Operators with Tagged Nodes

  • Meta-operators containing only a single operation (e.g., scaling meta-operator) have been replaced with tagged multiplicative nodes.
  • The same approach has been applied to Compensation and Residual nodes.
  • For more details, see the related issue: Issue #55.

2. File Organization Improvements and minor fix

  • Moved PTQMetaOps.* files to the operator folder for better structure.
  • Removed all occurrences of std::cout (now deprecated in Aidge core) and replaced them with Log::debug() for improved logging practices.
  • Added multiple AIDGE_ASSERT statements to enhance code safety and ensure robust error checking.
  • Created the insertRoundBelowProducer function to easily insert a node in the graph

3. Replacement of rescaleTensor() and roundTensor()

Scaling Nodes
  • Direct multiplication of tensors by a scaling factor (using rescaleTensor()) has been replaced with the insertion of dedicated Scaling nodes.
  • These nodes are represented as Mul operations with the tag isProducerScaling and apply the scaling factor during graph execution.
Round Nodes
  • The previous tensor element rounding (via roundTensor()) is now handled by inserting Round nodes directly below Producer nodes.
  • This ensures structured and visible rounding transformations within the graph.

For more information see issue:Issue #42

4. Improved Handling of Constant Nodes

  • Producer nodes now explicitly incorporate scaling and rounding operations through the newly added Scaling and Round nodes, resulting in:
    • Improved transparency about the PTQ operations for the user
    • Easier debugging and maintenance.
    • This operation can be reversed at any moment by calling the Constant Folding Recipe
Edited by Noam Zerah

Merge request reports

Loading