Skip to content

build: move vesin[torch] to the torch extra (fix conda-forge) - #5501

Merged
njzjz merged 1 commit into
deepmodeling:masterfrom
wanghan-iapcm:fix-vesin-torch-extra
Jun 7, 2026
Merged

njzjz merged 1 commit into
deepmodeling:masterfrom
wanghan-iapcm:fix-vesin-torch-extra

Conversation

@wanghan-iapcm

@wanghan-iapcm wanghan-iapcm commented Jun 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

vesin's torch bindings ship as a separate PyPI package (vesin-torch, pulled in by the vesin[torch] extra). conda-forge packages vesin but not vesin-torch, so listing vesin[torch] in the core dependencies (added in #5491) breaks the conda-forge build of the base deepmd-kit package.

This moves vesin[torch] out of the core dependencies and into the torch optional-dependency extra (backend/find_pytorch.get_pt_requirement), so only deepmd-kit[torch] (pip) pulls it. The neighbor-list runtime already guards usage via is_vesin_torch_available(), and nlist_backend="auto" falls back to the native builder when vesin is absent, so this is behavior-preserving for installs that don't ship the torch extra.

Changes

  • pyproject.toml: drop vesin[torch] from core dependencies.
  • backend/find_pytorch.py: add vesin[torch] to the torch extra.

Known limitations

  • No automated test covers the build-backend's generated extras; the change is verified by inspection (the pip install deepmd-kit[torch] resolution and the conda-forge recipe build are not exercised in CI here).
  • When torch is not requested, the torch extra is empty and vesin is not installed (intended).

Summary by CodeRabbit

  • Chores
    • Adjusted dependency configuration for improved package management.

vesin's torch bindings ship as a separate PyPI package (vesin-torch, pulled
in by the vesin[torch] extra).  conda-forge packages vesin but not
vesin-torch, so listing vesin[torch] in the core dependencies breaks the
conda-forge build.  Move it under the torch optional-dependency extra
(get_pt_requirement), so only deepmd-kit[torch] (pip) pulls it; the runtime
already guards usage via is_vesin_torch_available().
@dosubot dosubot Bot added the build label Jun 7, 2026
@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 145f7e48-d06d-473f-a425-dc2dec7b3d05

📥 Commits

Reviewing files that changed from the base of the PR and between 2e3117e and 629a66c.

📒 Files selected for processing (2)
  • backend/find_pytorch.py
  • pyproject.toml
💤 Files with no reviewable changes (1)
  • pyproject.toml

📝 Walkthrough

Walkthrough

The PR relocates the vesin[torch] dependency from static project declarations in pyproject.toml to conditional inclusion in get_pt_requirement() within the backend module, making the dependency available only when PyTorch is unavailable during backend initialization.

Changes

Conditional vesin[torch] dependency handling

Layer / File(s) Summary
Relocate vesin[torch] to conditional requirement
backend/find_pytorch.py, pyproject.toml
get_pt_requirement() now includes vesin[torch] in the returned PyTorch dependency list with supporting comments, while the entry is removed from static project.dependencies to avoid duplication.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: moving vesin[torch] from core dependencies to the torch extra to resolve a conda-forge compatibility issue.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@wanghan-iapcm
wanghan-iapcm requested a review from njzjz June 7, 2026 02:31
@codecov

codecov Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.41%. Comparing base (2e3117e) to head (629a66c).
⚠️ Report is 247 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5501      +/-   ##
==========================================
- Coverage   81.42%   81.41%   -0.01%     
==========================================
  Files         871      871              
  Lines       96951    96952       +1     
  Branches     4240     4241       +1     
==========================================
- Hits        78941    78938       -3     
- Misses      16707    16711       +4     
  Partials     1303     1303              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@njzjz
njzjz added this pull request to the merge queue Jun 7, 2026
Merged via the queue into deepmodeling:master with commit 99c1ece Jun 7, 2026
73 checks passed
@wanghan-iapcm
wanghan-iapcm deleted the fix-vesin-torch-extra branch June 13, 2026 01:21
pull Bot pushed a commit to ishandutta2007/deepmd-kit that referenced this pull request Sep 23, 2026
…mportable (deepmodeling#6037)

> **This PR has been reduced, and the original description was wrong.**
It claimed that nothing in
> the project metadata declares a neighbor-list backend, and added a
`dpa4` extra to fix that. The
> claim was false: `deepmd` assembles extras through a custom build
backend, and
> `backend/find_pytorch.py` already declares `e3nn>=0.5.9`,
`vesin[torch]` and
> `nvalchemi-toolkit-ops>=0.3.1` under the `torch` extra — visible in
the built metadata as
> `vesin[torch]; extra == "torch"`, and put there deliberately by deepmodeling#5501.
I had checked only
> `pyproject.toml`, where none of those strings appear. The `dpa4` extra
duplicated an extra that
> already exists and has been removed, together with the test that
parsed `pyproject.toml`.
>
> What is left is the half that never depended on that claim: the error
message.

The DPA-4 / SeZM descriptor needs `vesin` or `nvalchemiops` at runtime,
and both ship with the
`torch` extra. An environment that has the rest of the PyTorch stack but
no neighbor-list backend
builds a model and then stops at:

```
RuntimeError: SeZM neighbor-list construction requires either 'nvalchemiops' or 'vesin',
but neither is importable.
```

`nvalchemiops` and `vesin` are *import* names. Neither is what a user
types into pip: the first comes
from the distribution `nvalchemi-toolkit-ops`, and the second needs its
`torch` extra, because the
torch bindings ship separately from `vesin` itself. So the message names
two things that cannot be
installed as written.

That gap is not hypothetical. `backend/find_pytorch.py` records the case
in its own comment — conda-forge
ships `vesin` but not `vesin-torch` — which is exactly an environment
where `import vesin` succeeds,
`is_vesin_torch_available()` is false, and this message is all the user
gets.

## Change

The `RuntimeError` now gives commands that resolve it, and points at the
extra that ships a backend:

```
SeZM neighbor-list construction requires a neighbor-list backend, but neither 'vesin' nor
'nvalchemiops' is importable. Install one of:
  pip install 'vesin[torch]'        # portable CPU/CUDA cell list
  pip install nvalchemi-toolkit-ops # batched CUDA kernels
'vesin' also ships with the PyTorch extra: pip install 'deepmd-kit[torch]'.
```

Text only. No dependency, default, or behaviour changes; the selection
logic is untouched.

`nvalchemi-toolkit-ops` is offered as an alternative rather than
recommended: it is a CUDA package
restricted to Linux and `python>=3.11`, whereas `vesin[torch]` is
portable.

## Tests

`source/tests/pt/test_neighbor_backend_missing.py` makes both backends
report unavailable and checks
that the message names the installable distributions and the extra. Both
tests fail against the old
message and pass against the new one.

## Note on the no-extra install

`pip install deepmd-kit` with no extra — the PyTorch CPU path in
`doc/install/easy-install.md` — does
**not** reach this message today. `e3nn` sits in the same `torch` extra,
and
`deepmd/pt/model/descriptor/sezm_nn/projection.py` imports it at module
scope, so that install fails
earlier with `ModuleNotFoundError: e3nn`. deepmodeling#6036 makes that import lazy;
with it applied, the CPU path
reaches this message too.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants