Skip to content

fix: avoid cleanup errors for partially initialized LlamaModel#2173

Merged
abetlen merged 3 commits into
abetlen:mainfrom
usernames122:main
May 31, 2026
Merged

fix: avoid cleanup errors for partially initialized LlamaModel#2173
abetlen merged 3 commits into
abetlen:mainfrom
usernames122:main

Conversation

@usernames122

@usernames122 usernames122 commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

This solves a bug I uncovered, that causes an AttributeError if constantly re-initializing a model in a loop and Python garbage collects it, such as testing the highest GPU layer count you can go before CUDA OOMs.
Specifically, it solves:

    if self.sampler is not None:
       ^^^^^^^^^^^^
AttributeError: 'LlamaModel' object has no attribute 'sampler'

Fixes #2104

usernames122 and others added 3 commits April 4, 2026 19:47
This solves a bug I uncovered, that causes an AttributeError if constantly re-initializing a model in a loop and Python garbage collects it, such as testing the highest GPU layer count you can go before CUDA OOMs.
@abetlen abetlen changed the title fix: Add attribute check for sampler in close method fix: avoid cleanup errors for partially initialized LlamaModel May 31, 2026
@abetlen abetlen merged commit fdf38b3 into abetlen:main May 31, 2026
15 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.

LLM Loading Failure — AttributeError in LlamaModel.__del__

2 participants