fix: replace bare except clauses with except Exception#1981
Open
ramkrishs wants to merge 2 commits into
Open
Conversation
Bare `except:` catches BaseException — including KeyboardInterrupt and SystemExit — which prevents users from interrupting long-running quantization jobs with Ctrl-C and masks unrelated crashes. Replace all 15 occurrences across the codebase with `except Exception:`, which preserves the intended fallback behaviour while allowing signals and interpreter exit to propagate normally. Files changed: - auto_round/calib_dataset.py (3) - auto_round/inference/backend.py (1) - auto_round/inference/convert_model.py (3) - auto_round/modeling/unfused_moe/__init__.py (1) - auto_round/utils/common.py (1) - auto_round/utils/device.py (1) - auto_round/utils/device_manager.py (1) - auto_round/utils/model.py (4) Signed-off-by: Ram Sathyavageeswaran <ramkrishs@outlook.com>
chensuyue
approved these changes
Jul 2, 2026
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
Bare
except:clauses catchBaseException— which includesKeyboardInterruptandSystemExit. This means users cannot interrupt a long-running quantization job with Ctrl-C if the interrupt lands inside one of these blocks, and unrelated crashes (e.g. out-of-memory, assertion errors) get silently swallowed.Replace all 15 occurrences with
except Exception:, which preserves the intended fallback behaviour while allowing signals and interpreter exit to propagate normally.Type of Change
Files Changed
auto_round/calib_dataset.pyauto_round/inference/convert_model.pyauto_round/utils/model.pyauto_round/inference/backend.pyauto_round/modeling/unfused_moe/__init__.pyauto_round/utils/common.pyauto_round/utils/device.pyauto_round/utils/device_manager.pyRelated Issues
No dedicated issue — identified during codebase review.
Checklist Before Submitting
/azp run Unit-Test-CUDA-AutoRound.