Add vLLM-metax vllm metax cmake presets jobs override#305
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for overriding the number of CMake build jobs and NVCC threads via command-line arguments and function parameters, and includes a new unit test to verify this behavior. The reviewer identified a potential bug where get_cpu_cores() returning 0 or None could lead to a ZeroDivisionError or TypeError, and provided a robust code suggestion to handle these edge cases.
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.
| if nvcc_threads is None: | ||
| nvcc_threads = min(4, cpu_cores) | ||
| elif nvcc_threads < 1: | ||
| raise ValueError("nvcc_threads must be at least 1") | ||
| if cmake_jobs is None: | ||
| cmake_jobs = max(1, cpu_cores // nvcc_threads) | ||
| elif cmake_jobs < 1: | ||
| raise ValueError("cmake_jobs must be at least 1") |
There was a problem hiding this comment.
If get_cpu_cores() returns None (which multiprocessing.cpu_count() can do on some platforms) or returns 0 (which can happen in certain containerized or restricted environments), the current logic will raise a TypeError or a ZeroDivisionError.
Specifically, if cpu_cores is 0, nvcc_threads is set to 0 via min(4, 0). Then, calculating cmake_jobs using cpu_cores // nvcc_threads results in 0 // 0, which raises a ZeroDivisionError.
We can make this logic robust against both None and 0 values by defaulting cpu_cores to at least 1 and ensuring nvcc_threads is at least 1.
| if nvcc_threads is None: | |
| nvcc_threads = min(4, cpu_cores) | |
| elif nvcc_threads < 1: | |
| raise ValueError("nvcc_threads must be at least 1") | |
| if cmake_jobs is None: | |
| cmake_jobs = max(1, cpu_cores // nvcc_threads) | |
| elif cmake_jobs < 1: | |
| raise ValueError("cmake_jobs must be at least 1") | |
| if nvcc_threads is None: | |
| nvcc_threads = max(1, min(4, cpu_cores or 1)) | |
| elif nvcc_threads < 1: | |
| raise ValueError("nvcc_threads must be at least 1") | |
| if cmake_jobs is None: | |
| cmake_jobs = max(1, (cpu_cores or 1) // nvcc_threads) | |
| elif cmake_jobs < 1: | |
| raise ValueError("cmake_jobs must be at least 1") |
Summary
Validation
Review notes