Skip to content

fix(optim): replace bare except with Exception in Lion optimizer#2666

Merged
rwightman merged 1 commit intohuggingface:mainfrom
llukito:fix/lion-optimizer-bare-except
Feb 11, 2026
Merged

fix(optim): replace bare except with Exception in Lion optimizer#2666
rwightman merged 1 commit intohuggingface:mainfrom
llukito:fix/lion-optimizer-bare-except

Conversation

@llukito
Copy link
Copy Markdown
Contributor

@llukito llukito commented Feb 11, 2026

Description

This PR replaces a bare except: clause with except Exception: in timm/optim/lion.py.

The previous implementation caught BaseException, which includes SystemExit and KeyboardInterrupt. This prevented the user from interrupting the process (Ctrl+C) during the foreach capability check.

Verification

Verified via code inspection. This ensures standard runtime errors (like AttributeError or RuntimeError from torch.ops) are caught, while allowing system control signals to propagate correctly.

Replaces a bare `except:` clause with `except Exception:` in `timm/optim/lion.py`.

The previous bare except caught `BaseException`, which includes `SystemExit` and `KeyboardInterrupt`. This ensures that system control signals (like Ctrl+C) propagate correctly while still handling runtime errors during the capability check.
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@rwightman rwightman merged commit 56467ad into huggingface:main Feb 11, 2026
22 checks passed
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.

3 participants