Skip to content
Snippets Groups Projects

Real quantization cast for PTQ

Merged Noam Zerah requested to merge noamzerah/aidge_quantization:quantization_cast into dev

Related to Issue:#59

This MR aims to bring real quantization and Graph Integer Execution in AIDGE quantization module (Solving this issue [aidge_backend_cpu#35]):

Changes for now:

  • PTQ.cpp: Creation of a CastNetwork Routine that directly cast the network into the target type. The routine differentiates between normal mode and single-shift mode, inserting either BitShift or IntQuantizer accordingly. IntQuantizer is a modified version of the quantizer operator that allows execution within a fully integer network, as this new meta-operator enables casting the input to Float and the output to Int.

Also, I added the foldGraph flag in the quantizeNetwork() function. When this flag is set to true, the pipeline will now apply the constant folding recipe to the graph, making it much simpler and more readable by 'removing' all the intermediate PTQ nodes inserted, from the user's perspective.

  • PTQMetaOps.(h/c)pp Adding the new metaoperator IntQuantizer and BitShiftQuantizer

Results: We obtain exactly the same results for MiniResNet as when using the fake quantization pipeline (with and without SingleShift). For ResNet18, we observe a slight drop in accuracy from 68.7% to 67.6% in Int32 with SingleShift, due to the approximation of the Global Average Pooling operator in integer arithmetic.

Also there is now a functional testsuite to prevent regression in the PTQ pipeline (aidge_quantization/aidge_quantization/unit_tests/test_ptq.py) [#64 (closed)\]

Quick fix to solve this issue: #19 (comment 3112773)

What remains to be done:

  • Add support for Int8
Edited by Noam Zerah

Merge request reports

Approval is optional
Code Quality is loading
Test summary results are being parsed

Merged by Noam ZerahNoam Zerah 2 weeks ago (Mar 25, 2025 3:26pm UTC)

Merge details

  • Changes merged into dev with 1553e9ef (commits were squashed).
  • Did not delete the source branch.

Pipeline failed for 1553e9ef on dev

Test coverage 0.00% (0.00%) from 2 jobs

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading