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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Register a None optimizer seems weird, maybe we should skip registering the optimizer if it does not exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
_optim
isNone
, the result ofinspect.isclass(_optim)
isFalse
and the registering will be skippedmmengine/mmengine/optim/optimizer/builder.py
Lines 149 to 153 in 2135d37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the perspective of code readability, explicitly skipping registration is preferable to implicitly skipping it by passing in
None
.BTW, I'm not familiar with the optimizer in bitsandbytes, why don't we refer to the implementation here
mmengine/mmengine/optim/optimizer/builder.py
Line 120 in 2135d37
to register the optimizer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me neither. I just attempted to fix the bug with minimal changes. I'm uncertain if modifying the builder function for
bitsandbytes
to resembleSophia
's could cause any issue