Skip to content

fix: replace bare except clauses with except Exception#1981

Open
ramkrishs wants to merge 2 commits into
intel:mainfrom
ramkrishs:fix/bare-except-clauses
Open

fix: replace bare except clauses with except Exception#1981
ramkrishs wants to merge 2 commits into
intel:mainfrom
ramkrishs:fix/bare-except-clauses

Conversation

@ramkrishs

@ramkrishs ramkrishs commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

Bare except: clauses catch BaseException — which includes KeyboardInterrupt and SystemExit. 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

  • Bug fix

Files Changed

File Count
auto_round/calib_dataset.py 3
auto_round/inference/convert_model.py 3
auto_round/utils/model.py 4
auto_round/inference/backend.py 1
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

Related Issues

No dedicated issue — identified during codebase review.

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.

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>
@ramkrishs ramkrishs marked this pull request as ready for review July 1, 2026 23:45
@chensuyue chensuyue requested a review from xin3he July 2, 2026 02:15
@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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants