Skip to content

Commit

Permalink
Use numpy._core instead of numpy.core (#3247)
Browse files Browse the repository at this point in the history
* Update other.py

* Update other.py

* add missing import

* use Version instead of version.parse

* Update np_core import in save function
  • Loading branch information
qgallouedec authored Nov 21, 2024
1 parent 5f96369 commit 08101b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/accelerate/utils/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ def save(obj, f, save_on_each_node: bool = False, safe_serialization: bool = Fal

# The following are considered "safe" globals to reconstruct various types of objects when using `weights_only=True`
# These should be added and then removed after loading in the file
np_core = np._core if is_numpy_available("2.0.0") else np.core
TORCH_SAFE_GLOBALS = [
# numpy arrays are just numbers, not objects, so we can reconstruct them safely
np.core.multiarray._reconstruct,
np_core.multiarray._reconstruct,
np.ndarray,
# The following are needed for the RNG states
encode,
Expand Down

0 comments on commit 08101b9

Please sign in to comment.