Skip to content

add other non-integer scheme support for awq#1892

Merged
WeiweiZhang1 merged 142 commits into
mainfrom
weiwei/mxfp_exp
Jun 26, 2026
Merged

add other non-integer scheme support for awq#1892
WeiweiZhang1 merged 142 commits into
mainfrom
weiwei/mxfp_exp

Conversation

@WeiweiZhang1

@WeiweiZhang1 WeiweiZhang1 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Description

Please briefly describe your main changes, the motivation.

Type of Change

Exprimental Feature and Bugfix
docs and example will be updated in the next PR

Related Issues

Fixes or relates to #

Checklist Before Submitting

  • My code has been tested locally.
  • Documentation has been updated as needed.
  • New or updated tests are included where applicable.
  • The CUDA CI has passed. You can trigger it by commenting /azp run Unit-Test-CUDA-AutoRound.

#1834

n1ck-guo and others added 30 commits May 22, 2026 17:14
Signed-off-by: n1ck-guo <heng.guo@intel.com>
Signed-off-by: n1ck-guo <heng.guo@intel.com>
Signed-off-by: n1ck-guo <heng.guo@intel.com>
Signed-off-by: n1ck-guo <heng.guo@intel.com>
Signed-off-by: Xin He <xin3.he@intel.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: WeiweiZhang1 <weiwei1.zhang@intel.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Liang Lv <liang1.lv@intel.com>
Signed-off-by: n1ck-guo <heng.guo@intel.com>
Signed-off-by: n1ck-guo <heng.guo@intel.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: n1ck-guo <heng.guo@intel.com>
Signed-off-by: lkk12014402 <kakao.lv@intel.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: chensuyue <suyue.chen@intel.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: lvliang-intel <liang1.lv@intel.com>
Signed-off-by: n1ck-guo <heng.guo@intel.com>
Signed-off-by: n1ck-guo <heng.guo@intel.com>
Signed-off-by: yiliu30 <yi4.liu@intel.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: lvliang-intel <liang1.lv@intel.com>
…ent in tests (#1857)

Signed-off-by: Xin He <xin3.he@intel.com>
Comment thread auto_round/wrapper.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates AutoRound’s AWQ pipeline so AWQ’s internal “reference QDQ” path can track the downstream block-quantizer scheme for non-integer data types (e.g., MXFP/NVFP), addressing the linked request for AWQ smoothing compatibility beyond INT schemes. It also expands AWQ with optional post-smoothing weight clipping and refactors AWQ naming to clarify it is a transform/preprocessor.

Changes:

  • Introduces QDQTool as a reusable, scheme-aware quantize-dequantize utility and composes it into AWQTransform for loss evaluation and optimized init-scale dispatch.
  • Adds AWQ clip options (apply_clip, clip_as_init, and related search knobs) and propagates clip values via model context / wrapper initialization paths.
  • Renames/aliases AWQQuantizerAWQTransform throughout the pipeline/registry and extends tests for V2 detection/init-scale dispatch (plus new clip tests).

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
auto_round/algorithms/quantization/qdq_tool.py New centralized QDQ primitive for scheme-aware loss evaluation.
auto_round/algorithms/transforms/awq/base.py AWQ refactor to AWQTransform, integrates QDQTool, adds smooth_iters + optional clip search/apply.
auto_round/algorithms/transforms/awq/config.py Adds AWQ clip/smooth iteration config and scheme-finalization hook.
auto_round/algorithms/transforms/awq/__init__.py Exposes AWQTransform and keeps AWQQuantizer as a deprecated alias.
auto_round/algorithms/transforms/__init__.py Updates lazy exports for AWQ transform/alias.
auto_round/algorithms/registry.py Updates registration import path for AWQ pipeline member.
auto_round/algorithms/pipeline.py Updates docstring references from AWQQuantizer to AWQTransform.
auto_round/compressors/base.py Adds finalize_scheme() hook invocation for alg configs after scheme resolution.
auto_round/context/model.py Adds awq_clip_values storage on model context for downstream quantizers.
auto_round/wrapper.py Uses AWQ clip-as-init values to cap SignRound tunable min/max range.
auto_round/algorithms/quantization/sign_roundv2/quantizer.py Refactors optimized init-scale path to use shared utils; adds AWQ clip-as-init integration for V2.
auto_round/data_type/utils.py Adds shared optimized init-scale / quant-func dispatch helpers and imatrix reshaping utility.
auto_round/data_type/int.py Makes quant_tensor_sym tolerant of scalar max_scale when reusing init_scale in one-shot QDQ.
auto_round/cli/algorithms.py Adds CLI flags for AWQ clipping/clip-as-init.
auto_round/eval/evaluation.py Passes device into lm-eval HF model wrappers and prepares torch.nn.Module models for eval device/dtype.
test/test_cpu/algorithms/test_awq.py Adds CPU tests for AWQ clip behavior and V2 scale-search detection/dispatch.
test/test_cuda/algorithms/test_awq.py Adds CUDA unit tests for V2 detection + init-scale dispatch helper behavior.
test/test_cpu/core/test_pipeline_fail_fast.py Updates pipeline expectation to AWQTransform.
test/test_cpu/core/test_hpu_clear_memory.py Adds unit test for ClearMemory’s HPU path using mocking.
AGENTS.md Deleted (agent guidance removed).
.gitignore Adds .codegraph/ ignore entry.
Comments suppressed due to low confidence (5)

auto_round/algorithms/transforms/awq/base.py:505

  • _normalize_group_size() assumes group_size is an int and does group_size > 0. If a tuple group size is ever passed (supported elsewhere via reshape_pad_tensor_by_group_size(..., group_size=(M,N))), this will raise TypeError. Either explicitly reject tuple group sizes for AWQ, or treat them as “no 1-D grouping” and fall back.
    auto_round/algorithms/transforms/awq/base.py:547
  • prepare_layer_funcs() can raise (e.g., if the layer’s resolved scheme has no registered quant func). Previously AWQ would typically skip/penalize that mapping; now this will abort the entire AWQ run. Consider catching resolution failures here and skipping smoothing for that mapping instead of crashing the quantization run.
    auto_round/algorithms/transforms/awq/base.py:789
  • The clip search step count does not actually reach clip_max_shrink as documented. With clip_max_shrink=0.5, clip_n_grid=20, n_steps=int(0.5*20)=10 and the loop only reaches 1 - 9/20 = 0.55 (55%), not 50%. Adjust the step calculation / loop bounds so the search includes the intended shrink limit.
    auto_round/algorithms/transforms/awq/base.py:821
  • _apply_clip() rebinds layer.weight.data to a new tensor. Using copy_ avoids replacing the underlying storage/metadata and is safer with optimizers / hooks (even though this runs under no_grad).
    auto_round/algorithms/transforms/awq/base.py:749
  • Docstring says the clip search returns a [out_channels, n_group] tensor, but the implementation returns best_max_val.squeeze(1) which is [out_channels, n_group, 1] (as also noted in the inline comment). Please align the docstring with the actual shape to avoid confusion for downstream callers.

Comment thread test/test_cpu/algorithms/test_awq.py
Comment thread test/test_cpu/algorithms/test_awq.py
Comment thread auto_round/algorithms/transforms/awq/config.py
Comment thread test/test_cpu/algorithms/test_awq.py
WeiweiZhang1 and others added 2 commits June 25, 2026 11:39
Signed-off-by: WeiweiZhang1 <weiwei1.zhang@intel.com>
@chensuyue

Copy link
Copy Markdown
Contributor

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

WeiweiZhang1 and others added 5 commits June 25, 2026 13:22
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: WeiweiZhang1 <weiwei1.zhang@intel.com>
@WeiweiZhang1

Copy link
Copy Markdown
Contributor Author

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@n1ck-guo n1ck-guo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
There have been some design and architectural modifications, and I will work with Weiwei to make some improvements later.

Comment thread auto_round/data_type/utils.py
Comment thread auto_round/data_type/utils.py
Comment thread auto_round/data_type/utils.py
Comment thread auto_round/eval/evaluation.py Outdated
Signed-off-by: WeiweiZhang1 <weiwei1.zhang@intel.com>
@WeiweiZhang1

Copy link
Copy Markdown
Contributor Author

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: WeiweiZhang1 <weiwei1.zhang@intel.com>
Signed-off-by: WeiweiZhang1 <weiwei1.zhang@intel.com>
@WeiweiZhang1

Copy link
Copy Markdown
Contributor Author

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@WeiweiZhang1 WeiweiZhang1 merged commit 5a3ade8 into main Jun 26, 2026
47 checks passed
@WeiweiZhang1 WeiweiZhang1 deleted the weiwei/mxfp_exp branch June 26, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.