Skip to content

Migrate to NumPy 2.x.x and raise minimum Python version to 3.10 - #403

Open
muhammad-fiaz wants to merge 15 commits into
facebookresearch:mainfrom
muhammad-fiaz:main
Open

Migrate to NumPy 2.x.x and raise minimum Python version to 3.10#403
muhammad-fiaz wants to merge 15 commits into
facebookresearch:mainfrom
muhammad-fiaz:main

Conversation

@muhammad-fiaz

@muhammad-fiaz muhammad-fiaz commented Jan 12, 2026

Copy link
Copy Markdown

Hello!

I have updated the project to be compatible with NumPy 2.0 (minimum supported version) and raised the minimum required Python version to 3.10 to ensure consistent dependency resolution when using uv.

NumPy Compatibility

Python Version Requirement

* I raised the minimum supported Python version to 3.10

  • Python versions below 3.10 cannot satisfy NumPy’s dependency constraints when resolving environments with uv.
  × No solution found when resolving dependencies for split (markers: python_full_version == '3.8.*'):
  ╰─▶ Because the requested Python version (>=3.8) does not satisfy Python>=3.9.0 and numpy>=1.26.0,<=1.26.1 depends on     
      Python>=3.9,<3.13, we can conclude that numpy>=1.26.0,<=1.26.1 cannot be used.
      And because only the following versions of numpy are available:
          numpy<=1.26.0
          numpy==1.26.1
          numpy==1.26.2
          numpy==1.26.3
          numpy==1.26.4
          numpy==2.0.0
          numpy==2.0.1
          numpy==2.0.2
          numpy==2.1.0
          numpy==2.1.1
          numpy==2.1.2
          numpy==2.1.3
          numpy==2.2.0
          numpy==2.2.1
          numpy==2.2.2
          numpy==2.2.3
          numpy==2.2.4
          numpy==2.2.5
          numpy==2.2.6
          numpy==2.3.0
          numpy==2.3.1
          numpy==2.3.2
          numpy==2.3.3
          numpy==2.3.4
          numpy==2.3.5
          numpy==2.4.0
          numpy==2.4.1
      we can conclude that numpy>=1.26.0,<1.26.2 cannot be used. (1)

      Because the requested Python version (>=3.8) does not satisfy Python>=3.9.0 and numpy>=1.26.2,<=2.0.2 depends on      
      Python>=3.9, we can conclude that numpy>=1.26.2,<=2.0.2 cannot be used.
      And because we know from (1) that numpy>=1.26.0,<1.26.2 cannot be used, we can conclude that numpy>=1.26.0,<2.1.0     
      cannot be used. (2)

      Because the requested Python version (>=3.8) does not satisfy Python>=3.9.0 and numpy>=2.1.0,<=2.2.6 depends on       
      Python>=3.10, we can conclude that numpy>=2.1.0,<=2.2.6 cannot be used.
      And because we know from (2) that numpy>=1.26.0,<2.1.0 cannot be used, we can conclude that numpy>=1.26.0,<2.3.0      
      cannot be used. (3)

      Because the requested Python version (>=3.8) does not satisfy Python>=3.9.0 and all of:
          numpy>=2.3.0,<=2.3.5
          numpy>=2.4.1
      depend on Python>=3.11, we can conclude that all of:
          numpy>=2.3.0,<=2.3.5
          numpy>=2.4.1
       cannot be used.
      And because we know from (3) that numpy>=1.26.0,<2.3.0 cannot be used, we can conclude that all of:
          numpy>=1.26.0,<2.4.0
          numpy>2.4.0
       cannot be used.
      And because numpy==2.4.0 was yanked (reason: Backward compatibility bug), we can conclude that numpy>=1.26.0 cannot   
      be used.
      And because your project depends on numpy>=1.26 and your project requires sam3[dev], we can conclude that your        
      project's requirements are unsatisfiable.

      hint: Pre-releases are available for `numpy` in the requested range (e.g., 2.4.0rc1), but pre-releases weren't        
      enabled (try: `--prerelease=allow`)

      hint: The `requires-python` value (>=3.8) includes Python versions that are not supported by your dependencies        
      (e.g., numpy>=1.26.0,<=1.26.1 only supports >=3.9, <3.13). Consider using a more restrictive `requires-python` value  
      (like >=3.9, <3.13).

      hint: While the active Python version is 3.14, the resolution failed for other Python versions supported by your      
      project. Consider limiting your project's supported Python versions using `requires-python`.
  • I ran Ruff with the NPY201 rule and verified that all checks pass.
  • I confirmed that uv sync --dev completes successfully with the updated constraints.

these changes follows the official NumPy 2.0 migration guide.

please tell me, if there any additional changes needed!

additional reference

Update np.bool to be an alias to np.bool_ and un-deprecate it

image

@meta-cla

meta-cla Bot commented Jan 12, 2026

Copy link
Copy Markdown

Hi @muhammad-fiaz!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Jan 12, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

kencoken added a commit to kencoken/sam3 that referenced this pull request Mar 16, 2026
- pyproject.toml: Python >=3.10, numpy>=1.26 (no upper bound),
  add Py3.13/3.14 classifiers, ruff NPY201 (from upstream PR facebookresearch#403)
- sam3/agent/helpers/visualizer.py: np.bool -> np.bool_  (from PR facebookresearch#403)
- sam3/model_builder.py:
    - replace pkg_resources with importlib.resources (pkg_resources absent
      as a standalone module under Python 3.14 + setuptools 82)
    - skip CUDA-only position-encoding & decoder coord-cache precomputation
      when CUDA is unavailable (precompute paths hard-code device="cuda")
- sam3/model/geometry_encoders.py:
    - guard pin_memory() behind torch.cuda.is_available() (pin_memory
      requires a working CUDA driver)
@tamird

tamird commented May 15, 2026

Copy link
Copy Markdown

This PR looks quite obviously LLM-generated. Looking at some other merged PRs like #137 it seems they have much more succinct descriptions. Consider writing the words with your human hands rather than the LLM.

@muhammad-fiaz

muhammad-fiaz commented May 16, 2026

Copy link
Copy Markdown
Author

Hello, @tamird first look at the actual changes made in this PR rather than judging based on the description alone. This PR only contains a minor version update along with a small API syntax compatibility change, and the implementation was done manually. btw I even added reference citation links to clearly show the related changes and sources :)

@muhammad-fiaz

Copy link
Copy Markdown
Author

Optional: if anyone would like to try these changes before the PR is merged, you can install them directly from my fork:

pip install git+https://github.com/muhammad-fiaz/sam3.git@main

or

uv add git+https://github.com/muhammad-fiaz/sam3.git@main

This includes the NumPy 2.x compatibility updates and the Python 3.10+ requirement introduced by this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants