Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix dtype casting issue with numpy in LlamaTune adapter (#945)
# Pull Request ## Description This PR addresses a breaking change in NumPy's [universal function](https://numpy.org/doc/stable/reference/ufuncs.html) (ufunc) behavior in version 2.0, specifically affecting `np.clip` in the LlamaTune adapter code. **Key Changes**: - Resolves an issue where configuration retrieval fails due to type casting differences - Explicitly casts `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](https://numpy.org/doc/stable/reference/generated/numpy.can_cast.html#numpy.can_cast) automatically cast to Python scalars. This prevents retrieving previously suggested configurations stored in `self._suggested_configs` dict during `self.inverse_transform` method calls. **Technical Solution:** Implement explicit type casting to ensure consistent configuration representation in `self._suggested_configs` across `self.transform` and `self.inverse_transform` method calls. - **Closes #935** ______________________________________________________________________ ## Type of Change - 🛠️ Bug fix ______________________________________________________________________ ## Testing - **Environment**: Ubuntu 22.04 with Python 3.13 - **NumPy Versions Tested**: 1.26.4 and 2.2.2 - **Verification**: Existing test suite passed across both versions ______________________________________________________________________ --------- Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com> Co-authored-by: Brian Kroth <bpkroth@microsoft.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information