You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "tqchen (via GitHub)" <gi...@apache.org> on 2026/07/16 00:52:48 UTC

[PR] fix(device): require canonical Python device names [tvm-ffi]

tqchen opened a new pull request, #671:
URL: https://github.com/apache/tvm-ffi/pull/671

   ## Summary
   
   - remove the Python-only `llvm`, `c`, `test`, `nvptx`, and `cl` device aliases
   - retain canonical device names and their existing error behavior
   - cover direct construction and typed FFI conversion rejection
   
   ## Testing
   
   - `pytest -o addopts= tests/python/test_device.py tests/python/test_function.py tests/python/test_type_converter.py`
   - scoped pre-commit hooks, including Ruff, Cython lint, and ty


-- 
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: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] fix(device): require canonical Python device names [tvm-ffi]

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on code in PR #671:
URL: https://github.com/apache/tvm-ffi/pull/671#discussion_r3592753293


##########
python/tvm_ffi/cython/device.pxi:
##########
@@ -115,13 +115,8 @@ cdef class Device:
     }
 
     _DEVICE_NAME_TO_TYPE = {
-        "llvm": DLDeviceType.kDLCPU,
         "cpu": DLDeviceType.kDLCPU,
-        "c": DLDeviceType.kDLCPU,
-        "test": DLDeviceType.kDLCPU,
         "cuda": DLDeviceType.kDLCUDA,
-        "nvptx": DLDeviceType.kDLCUDA,
-        "cl": DLDeviceType.kDLOpenCL,
         "opencl": DLDeviceType.kDLOpenCL,
         "vulkan": DLDeviceType.kDLVulkan,
         "metal": DLDeviceType.kDLMetal,

Review Comment:
   Follow-up: we decided to treat `mps` and `wgpu` as standard device spellings. Commit 064908b restores them in the C++ parser and adds the matching Python constructor mappings, so direct construction and typed FFI conversion remain consistent. The compiler/target aliases (`llvm`, `c`, `test`, `nvptx`, and `cl`) remain rejected.



-- 
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: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] fix(device): require canonical Python device names [tvm-ffi]

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on code in PR #671:
URL: https://github.com/apache/tvm-ffi/pull/671#discussion_r3591822406


##########
python/tvm_ffi/cython/device.pxi:
##########
@@ -115,13 +115,8 @@ cdef class Device:
     }
 
     _DEVICE_NAME_TO_TYPE = {
-        "llvm": DLDeviceType.kDLCPU,
         "cpu": DLDeviceType.kDLCPU,
-        "c": DLDeviceType.kDLCPU,
-        "test": DLDeviceType.kDLCPU,
         "cuda": DLDeviceType.kDLCUDA,
-        "nvptx": DLDeviceType.kDLCUDA,
-        "cl": DLDeviceType.kDLOpenCL,
         "opencl": DLDeviceType.kDLOpenCL,
         "vulkan": DLDeviceType.kDLVulkan,
         "metal": DLDeviceType.kDLMetal,

Review Comment:
   Good catch on the mismatch. This change intentionally makes device parsing canonical-only, so adding aliases to Python would reintroduce the compatibility surface being removed. I updated the C++ parser in 68cc76b to accept only `metal` and `webgpu`, and moved the existing `mps`/`wgpu` expectations to the rejection cases. Direct Python construction and typed FFI conversion now follow the same canonical-name policy.



-- 
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: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] fix(device): require canonical Python device names [tvm-ffi]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #671:
URL: https://github.com/apache/tvm-ffi/pull/671#discussion_r3591798503


##########
python/tvm_ffi/cython/device.pxi:
##########
@@ -115,13 +115,8 @@ cdef class Device:
     }
 
     _DEVICE_NAME_TO_TYPE = {
-        "llvm": DLDeviceType.kDLCPU,
         "cpu": DLDeviceType.kDLCPU,
-        "c": DLDeviceType.kDLCPU,
-        "test": DLDeviceType.kDLCPU,
         "cuda": DLDeviceType.kDLCUDA,
-        "nvptx": DLDeviceType.kDLCUDA,
-        "cl": DLDeviceType.kDLOpenCL,
         "opencl": DLDeviceType.kDLOpenCL,
         "vulkan": DLDeviceType.kDLVulkan,
         "metal": DLDeviceType.kDLMetal,

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   There is an inconsistency between the Python `Device` constructor and the C++ FFI parser (`include/tvm/ffi/device.h`). The C++ parser accepts `"mps"` (mapping to `kDLMetal`) and `"wgpu"` (mapping to `kDLWebGPU`), which means `A(tvm_ffi.Device).convert("mps")` succeeds, but direct construction via `tvm_ffi.device("mps")` raises a `ValueError`.
   
   To ensure consistency, we should add `"mps"` (and `"wgpu"` if possible, though `"webgpu"` is outside this diff hunk) to `_DEVICE_NAME_TO_TYPE` in Python.
   
   ```
       _DEVICE_NAME_TO_TYPE = {
           "cpu": DLDeviceType.kDLCPU,
           "cuda": DLDeviceType.kDLCUDA,
           "opencl": DLDeviceType.kDLOpenCL,
           "vulkan": DLDeviceType.kDLVulkan,
           "metal": DLDeviceType.kDLMetal,
           "mps": DLDeviceType.kDLMetal,
   ```



-- 
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: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] fix(device): require canonical Python device names [tvm-ffi]

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen merged PR #671:
URL: https://github.com/apache/tvm-ffi/pull/671


-- 
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: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org