feat(quantization): add activation export handler hook - #82
Open
dengqiaoyu wants to merge 1 commit into
Open
Conversation
- Let an out-of-tree package register a per-granularity activation export handler for graph or eager mode, so a granularity the built-in Core AI path cannot express (per-block, dynamic qparams) can be exported without patching this repo. - Allow an e8m0 `scale_dtype` on integer dtypes, gated in `QuantizationSpec.validate_scale_dtype` to `PerBlockGranularity` + `SYMMETRIC` + `ZP`, with `E8M0_TARGET_MAX_POW2` as the single source of truth for which dtypes have an e8m0 target exponent. - Extract the export test workflow into `export_utils.run_export_test`, a common function now shared by the eager-MIL, eager-MLIR and graph-mode-MLIR test files; it reads the execution mode from the config, so one helper covers both modes. - Also reject an e8m0 scale on integer weights in `finalize`, and share the qparam extraction and activation validation between the eager and graph export paths.
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.
feat(quantization): add activation export handler hook
In order to support the export handler, I need to make the following refactor so that handler insertion and testing shares more code and is more clean.
finalizefrom rejecting a dynamic qparams calculator when a handler covers it._validate_no_persistent_observer_calculatorsnow askscan_export_stateless_fake_quantfirst, so the restriction applies only where no handler is registered.extract_export_qparams,dequant_output_dtypeandvalidate_activation_export_supportedin_export_utils. Both paths previously carried their own copy.FP_DTYPE_TO_MAX_POW2toE8M0_TARGET_MAX_POW2and make it the source of truth inQuantizationSpec.validate_scale_dtype. The validator now rejects any dtype with no e8m0 target exponent, so fp16, fp32 and bf16 with an e8m0 scale fail at spec construction rather than later inside_compute_e8m0_scale.export_utils.run_export_test, a common function now shared by the eager-MIL, eager-MLIR and graph-mode-MLIR test files; it reads the execution mode from the config, so one helper covers both modes.