unslothai/unsloth · error · ValueError
Invalid gpu_ids {requested_ids}: duplicate GPU IDs are not a
Error message
Invalid gpu_ids {requested_ids}: duplicate GPU IDs are not allowed. What it means
Raised during GPU ID validation on the Vulkan path (llama.cpp Vulkan builds) when the requested gpu_ids list contains the same Vulkan ordinal twice. Vulkan selects devices by ggml ordinal (--device VulkanN), a separate index space from CUDA/ROCm ids, so only basic well-formedness checks (duplicates, negatives) apply — there is no parent-visible or physical-count cross-check on this path.
Source
Thrown at studio/backend/utils/hardware/hardware.py:2762
) -> list[int]:
parent_visible_spec = _get_parent_visible_gpu_spec()
parent_visible_ids = get_parent_visible_gpu_ids()
physical_gpu_count = get_physical_gpu_count()
if gpu_ids is None:
return [] if is_vulkan else parent_visible_ids
requested_ids = list(gpu_ids)
if len(requested_ids) == 0:
return [] if is_vulkan else parent_visible_ids
if is_vulkan:
# A Vulkan build selects by ggml Vulkan ordinal (--device VulkanN), a separate
# index space from CUDA/ROCm ids that may be empty under CPU-only torch. The
# CUDA parent-visible / physical-count checks below do not apply; only reject
# malformed ordinals (issue #7239).
if len(set(requested_ids)) != len(requested_ids):
raise ValueError(f"Invalid gpu_ids {requested_ids}: duplicate GPU IDs are not allowed.")
negative_ids = [gpu_id for gpu_id in requested_ids if gpu_id < 0]
if negative_ids:
raise ValueError(
f"Invalid gpu_ids {requested_ids}: GPU IDs must be non-negative. "
f"Rejected IDs: {negative_ids}."
)
return requested_ids
if not parent_visible_spec["supports_explicit_gpu_ids"]:
env_var_name = (
"ZE_AFFINITY_MASK" if get_device() == DeviceType.XPU else "CUDA_VISIBLE_DEVICES"
)
raise ValueError(
f"Invalid gpu_ids {requested_ids}: explicit physical GPU IDs are "
f"unsupported when {env_var_name} uses non-numeric or subdevice "
f"entries ({parent_visible_spec['raw']!r}). Omit gpu_ids to use "
"the parent-visible devices."
)View on GitHub (pinned to 203007d190)
Solutions
- Deduplicate the gpu_ids list before passing it: sorted(set(gpu_ids)).
- Fix the config/UI layer that produced the duplicated ids.
- Use distinct Vulkan ordinals, one per device you want to use (e.g. [0, 1]).
Example fix
# before apply_gpu_ids([0, 0]) # ValueError: duplicate GPU IDs are not allowed # after apply_gpu_ids(sorted(set([0, 0]))) # -> [0]
Defensive patterns
Strategy: validation
Validate before calling
def normalize_gpu_ids(ids):
"""Dedup while preserving order."""
return list(dict.fromkeys(ids))
# guard: resolve_requested_gpu_ids(normalize_gpu_ids(gpu_ids)) Type guard
def are_unique_non_negative_ints(ids) -> bool:
return (
isinstance(ids, (list, tuple))
and all(isinstance(i, int) for i in ids)
and len(set(ids)) == len(ids)
and all(i >= 0 for i in ids)
) Prevention
- Deduplicate gpu id lists before any hardware API call.
- Use set operations when merging default and user GPU selections.
- Reject duplicate selections in UI multi-selects.
- Remember Vulkan uses its own ordinal space — do not reuse CUDA id logic blindly.
When it happens
Trigger: Calling resolve_requested_gpu_ids([0, 0]) or any gpu_ids list with a repeated element while the active device backend is Vulkan.
Common situations: Config files where a default id list got concatenated with a user-specified one (e.g. [0] + [0, 1]); UI multi-select allowing duplicate submissions; hand-edited YAML/JSON with copy-paste duplication.
Related errors
- Invalid gpu_ids {requested_ids}: GPU IDs must be non-negativ
- Invalid gpu_ids {requested_ids}: duplicate GPU IDs are not a
- Invalid gpu_ids {requested_ids}: GPU IDs must be non-negativ
- transformer_quant '{requested_scheme}' is unavailable for '{
- '{Path(gguf_filename or '').name}' is the {picked} partition
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/bea913c0e4877d5b.
Report an issue: GitHub.