[BUG]AttributeError: module 'numpy' has no attribute 'product'
Describe the bug When calling
File "~/megatron/core/dist_checkpointing/validation.py", line 460, in _validate_sharding_for_key_flattened
[rank0]: or stops[-1] != np.product(local_shape)
it will release an error AttributeError: module 'numpy' has no attribute 'product' whereas my numpy version is 2.2.5(stable)
To Reproduce Using numpy==2.2.5 will reproduce.
Expected behavior Assert error
Stack trace/logs
[rank0]: Traceback (most recent call last):
[rank0]: File "~/myprojct/scripts/../sft_gpt.py", line 311, in
Environment (please complete the following information):
- Megatron-LM commit ID, I don't know which commit ID my env using, but I check current version of megatron still using
np.product - PyTorch version '2.4.1+cu124'
- CUDA version 12.4
- NCCL version 2.20.5
Proposed fix
Change the np.product method to np.prod method. Or at the beginning of the file, write:
# Define np.product if it doesn’t exist
if not hasattr(np, "product"):
np.product = np.prod
If there’s a specific reason to retain np.product, please let me know and I’ll take a closer look—thanks!
Run into the same issue!
Numpy only has the function as np.prod instead of np.product.
Which version of numpy is the np.product available in?
np.product is deprecated since v1.25 (https://github.com/numpy/numpy/pull/23314) and is removed in v2.0. Downgrading to numpy<2 solves the issue.
np.productis deprecated since v1.25 (numpy/numpy#23314) and is removed in v2.0. Downgrading tonumpy<2solves the issue.
Thank you, this worked for me!
Marking as stale. No activity in 60 days.
+1 same issue, will we support np 2.0?
same issue
same issue
same
Hey all, sorry for the late response. Mcore is heavily tied to the NGC PyTorch container, which is currently compiled with numpy 1.2.6. The benefit of that container is that it comes with libraries like FlashAttention and TransformerEngine. We might extend compatibility beyond PyT with future releases, but for now we recommend using that container for highest compatibility.
Please also have a look at our pyproject.toml for supported dependency versions.
Let me know if there’s more I can help with!
@ko3n1g NGC PyTorch 25.10 includes numpy==2.1.0. We should reconsider numpy 2.0 support