-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dtype casting issue with numpy in LlamaTune adapter #945
Fix dtype casting issue with numpy in LlamaTune adapter #945
Conversation
Thanks for digging into this. Adjusting slightly to also remove the numpy version pinning. |
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.
Made a few small tweaks, but LGTM. Thanks for tracking this down!
Actually, it looks like this is still failing a test:
That doesn't happen with numpy<2.0, but with numpy 2.2.2 it does happen whether I use the version check or the try/except. @kkanellis can you please take another look? Thanks! |
@kkanellis were you able to track the source of this down at all? |
I will try to track this down tomorrow. In any case, since this look like a different bug/issue with SMAC, I propose merging this (w/o the change on the numpy version), and open a new issue just for this. |
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.
As discussed, merging as is since we are fairly confident this fixes one issue.
Will lift the numpy 2.0 restriction later once the SMAC issue is tracked down.
Pull Request
Description
This PR addresses a breaking change in NumPy's universal function (ufunc) behavior in version 2.0, specifically affecting
np.clip
in the LlamaTune adapter code.Key Changes:
np.clip
output from NumPy data type (e.g.,int64
) to native Python type (e.g.,int
)Problem Context:
In NumPy 2.0+, when ufuncs receive Python scalars as input, the output is no longer automatically cast to Python scalars. This prevents retrieving previously suggested configurations stored in
self._suggested_configs
dict duringself.inverse_transform
method calls.Technical Solution:
Implement explicit type casting to ensure consistent configuration representation in
self._suggested_configs
acrossself.transform
andself.inverse_transform
method calls.Type of Change
Testing