Skip to content

[Python] Refactor pyproject.toml dependencies - #19723

Merged
tlopex merged 1 commit into
apache:mainfrom
tlopex:lazy-import-psutil-meta-schedule
Jun 11, 2026
Merged

tlopex merged 1 commit into
apache:mainfrom
tlopex:lazy-import-psutil-meta-schedule

Conversation

@tlopex

@tlopex tlopex commented Jun 10, 2026

Copy link
Copy Markdown
Member

This pr refactors pyproject.toml and deletes redundant dependencies

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors project dependencies in pyproject.toml by moving psutil from main dependencies to optional and test groups, renaming importer-pytorch to importer-torch, and updating the all extra. In python/tvm/s_tir/meta_schedule/utils.py, the psutil import is moved inline. Feedback suggests catching ImportError when importing psutil inline to fall back to os.cpu_count(), and keeping importer-pytorch as an alias to avoid breaking backward compatibility.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread python/tvm/s_tir/meta_schedule/utils.py Outdated
Comment thread pyproject.toml Outdated
@tlopex
tlopex force-pushed the lazy-import-psutil-meta-schedule branch 4 times, most recently from 095d0c6 to 30becbe Compare June 11, 2026 00:50
A plain `import tvm` hard-required psutil: the import chain
tvm -> relax -> relax/pipeline.py -> s_tir.meta_schedule ->
meta_schedule/utils.py reached a top-level `import psutil`, even though
the only use in that module is psutil.cpu_count() for the meta schedule
search. All other call sites (popen_pool, disco.process_pool, rpc.server)
already import psutil lazily inside the functions that need it.

- Move `import psutil` in s_tir/meta_schedule/utils.py from module level
  into _cpu_count_impl with an actionable error message, and drop psutil
  from the core dependencies.
- Drop the importer extras: users importing torch/onnx/tflite models
  already have the corresponding framework installed, so declaring it on
  TVM's side is redundant.
- Drop the coreml extra: the CoreML BYOC backend additionally requires a
  USE_COREML=ON build (off by default and in the published wheels) and
  Xcode's coremlcompiler, so the extra alone could not enable the
  feature. Its lazy coremltools import now raises an actionable error
  instead.
- Organize the remaining extras by feature: torch, cuda (cuda-python for
  NVRTC JIT), meta-schedule (xgboost), popen-pool (psutil, cloudpickle),
  rpc (tornado, psutil, cloudpickle), and all (the union of the
  lightweight feature deps).
- Add a popen-pool dependency group (cloudpickle, psutil) included by the
  test group, covering the PopenPool worker deps when running the test
  suite from a source checkout.
- Give the onnx/torch/tflite frontends actionable ImportErrors too. The
  onnx frontend's existing "Unable to import onnx" guards were
  unreachable: the unguarded module-level import failed first.
@tlopex
tlopex force-pushed the lazy-import-psutil-meta-schedule branch from 30becbe to 0e8e0df Compare June 11, 2026 00:50
@tlopex
tlopex merged commit a4a2bf5 into apache:main Jun 11, 2026
9 checks passed
MasterJH5574 pushed a commit to MasterJH5574/tvm that referenced this pull request Jun 15, 2026
This pr refactors `pyproject.toml` and deletes redundant dependencies

(cherry picked from commit a4a2bf5)
MasterJH5574 pushed a commit to MasterJH5574/tvm that referenced this pull request Jun 15, 2026
This pr refactors `pyproject.toml` and deletes redundant dependencies

(cherry picked from commit a4a2bf5)
tqchen pushed a commit that referenced this pull request Oct 16, 2026
This pr refactors `pyproject.toml` and deletes redundant dependencies
tqchen pushed a commit that referenced this pull request Oct 18, 2026
This pr refactors `pyproject.toml` and deletes redundant dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants