fix: promote None-initialized kwarg to list in forward_capture#1979
Merged
wenhuach21 merged 1 commit intoJul 2, 2026
Merged
Conversation
When an optional kwarg (e.g. a sparse-attention mask) is absent on the
first calibration sample, the initialization branch stores it as None.
If a later sample delivers a real Tensor for the same key, the append
branch called None.append() / None.extend(), raising:
AttributeError: 'NoneType' object has no attribute 'extend'
Fix: before calling .append()/.extend(), check whether the stored value
is None and promote it to an empty list first.
Fixes: intel#1950
Signed-off-by: Ram Sathyavageeswaran <ramkrishs@outlook.com>
Contributor
Author
|
/azp run Unit-Test-CUDA-AutoRound |
|
Commenter does not have sufficient privileges for PR 1979 in repo intel/auto-round |
n1ck-guo
approved these changes
Jul 2, 2026
n1ck-guo
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Thanks for your effor.
Contributor
|
/azp run Unit-Test-CUDA-AutoRound |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Description
forward_captureinauto_round/calibration/hooks.pyraised anAttributeErrorduring calibration when an optional kwarg (e.g. a sparse-attention mask in MoE
models) was
Noneon the first calibration sample but a realTensoron a laterone.
Root cause: The initialization branch stores
Nonedirectly when a kwarg'svalue is
None:On the next sample, the append branch assumed the stored value was always a list
and called
.append()or.extend()on it, raising:Fix: One guard before the append/extend calls promotes a stored
Noneto anempty list, covering both
batch_size <= 1(.append) andbatch_size > 1(
.extend) paths.Type of Change
Related Issues
Fixes #1950
Testing
Added three regression tests in
test/test_cpu/core/test_forward_capture_none_kwarg.py:test_none_then_tensor_kwarg_batch_size_1batch_size=1(.appendpath)test_none_then_tensor_kwarg_batch_size_gt1batch_size>1(.extendpath)test_normal_tensor_kwarg_unaffectedAll three pass locally against the fix.
Checklist Before Submitting
/azp run Unit-Test-CUDA-AutoRound.