gemini-code-assist[bot] commented on code in PR #19723:
URL: https://github.com/apache/tvm/pull/19723#discussion_r3391154479


##########
python/tvm/s_tir/meta_schedule/utils.py:
##########
@@ -56,6 +55,8 @@ def _cpu_count_impl(logical: bool = True) -> int:
     Setting these variables may interfere the host-side search with profiling 
of generated kernels
     when measuring locally.
     """
+    import psutil  # type: ignore  # pylint: disable=import-outside-toplevel
+
     return psutil.cpu_count(logical=logical) or 1

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   Since `psutil` has been removed from the main dependencies and made 
optional, importing it directly will raise a `ModuleNotFoundError` if the 
`meta-schedule` extra is not installed. To make this utility robust, we should 
catch `ImportError` and fall back to the standard library's `os.cpu_count()`.
   
   ```suggestion
       try:
           import psutil  # type: ignore  # pylint: 
disable=import-outside-toplevel
           return psutil.cpu_count(logical=logical) or 1
       except ImportError:
           return os.cpu_count() or 1
   ```



##########
pyproject.toml:
##########
@@ -48,18 +48,19 @@ dependencies = [
   "apache-tvm-ffi>=0.1.12",
   "ml_dtypes",
   "numpy",
-  "psutil",
   "typing_extensions",
 ]
 
 [project.optional-dependencies]
-torch = ["torch"]
 importer-onnx = ["onnx", "onnxoptimizer", "onnxruntime"]
-importer-pytorch = ["torch", "torchvision"]
+importer-torch = ["torch", "torchvision"]

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Renaming the optional dependency group from `importer-pytorch` to 
`importer-torch` is a breaking change for users and automated scripts that 
install TVM using `pip install "apache-tvm[importer-pytorch]"`. To prevent 
breaking backward compatibility, please keep `importer-pytorch` as an alias.
   
   ```suggestion
   importer-torch = ["torch", "torchvision"]
   importer-pytorch = ["torch", "torchvision"]
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to