Block vLLM/SGLang serve on non-Linux with clear error#966
Block vLLM/SGLang serve on non-Linux with clear error#966alfredoclarifai wants to merge 2 commits intocli-improvementfrom
Conversation
vLLM and SGLang only support Linux with GPU access. On macOS/Windows, they crash deep in C extensions with opaque errors. This adds an early platform check in both serve paths (API-connected and --grpc) to fail fast with an actionable message suggesting cloud deploy or Ollama. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds an early OS/platform guard in the CLI model serving paths to fail fast (with a clearer UserError) when attempting to serve vLLM/SGLang-based models on non-Linux platforms.
Changes:
- Add non-Linux detection for vLLM/SGLang during
clarifai model serve(API-connected) validation. - Add similar detection during
clarifai model serve --grpcvalidation. - Reuse
toolkit.provider(when present) alongsiderequirements.txtinspection to detect the engine.
Comments suppressed due to low confidence (1)
clarifai/cli/model.py:1404
serve_cmdintroducestoolkit_provider = config.get('toolkit', {}).get('provider'), but later in the same validation block the LM Studio branch still re-readsconfig.get('toolkit', {}).get('provider')instead of usingtoolkit_provider. Using the cached variable consistently would avoid duplicate lookups and keep the checks uniform (and reduces the chance of future drift between branches).
toolkit_provider = config.get('toolkit', {}).get('provider')
if _platform.system() != "Linux":
for engine in ('vllm', 'sglang'):
if engine in dependencies or toolkit_provider == engine:
raise UserError(
f"{engine} is not supported on {_platform.system()}. It requires a Linux environment with GPU access.\n"
" Use 'clarifai model deploy .' to run on cloud GPU, or switch to the Ollama or LM Studio toolkit for local serving."
)
if "ollama" in dependencies or toolkit_provider == 'ollama':
| if _platform.system() != "Linux": | ||
| for engine in ('vllm', 'sglang'): | ||
| if engine in dependencies or toolkit_provider == engine: | ||
| raise UserError( | ||
| f"{engine} is not supported on {_platform.system()}. It requires a Linux environment with GPU access.\n" | ||
| " Use 'clarifai model deploy .' to run on cloud GPU, or switch to the Ollama or LM Studio toolkit for local serving." | ||
| ) |
There was a problem hiding this comment.
This adds new platform-specific behavior (raising UserError on non-Linux when vLLM/SGLang is detected), but the existing CLI tests for clarifai model serve don’t appear to cover these branches. Adding unit tests that mock platform.system() (and set up requirements.txt/toolkit.provider for vllm/sglang) would prevent regressions and should cover both API-connected serve and the --grpc path.
| import platform as _platform | ||
|
|
||
| toolkit_provider = config.get('toolkit', {}).get('provider') | ||
| if _platform.system() != "Linux": | ||
| for engine in ('vllm', 'sglang'): | ||
| if engine in dependencies or toolkit_provider == engine: | ||
| raise UserError( | ||
| f"{engine} is not supported on {_platform.system()}. It requires a Linux environment with GPU access.\n" | ||
| " Use 'clarifai model deploy .' to run on cloud GPU, or switch to the Ollama or LM Studio toolkit for local serving." | ||
| ) |
There was a problem hiding this comment.
In _run_local_grpc, the non-Linux guard for vLLM/SGLang only runs inside if mode not in ("container", "env"). That means clarifai model serve --grpc --mode env|container on macOS/Windows will skip this early check and can still hit the same deep C-extension failures this PR is trying to avoid. Consider moving the platform/toolkit check outside the mode gate (using toolkit_provider and/or parsing requirements regardless of mode) so the behavior is consistent across all --grpc modes.
|
@alfredoclarifai I have included these improvements in my branch, so closing this PR |
Summary
AttributeErrortracebacks--grpc)Test plan
clarifai model serve .in a vLLM model directory — should get clear error instead of C extension tracebackclarifai model serve --grpcin an SGLang model directory — same clear error🤖 Generated with Claude Code