fix: off-by-one error in GpuSelector.get_gpu_arg

gpu <= len(self._valid_gpus) should be gpu < len(self._valid_gpus).

The list is zero-indexed, so requesting gpu index equal to the list
length causes an IndexError. For example, with 2 valid GPUs (indices
0 and 1), requesting gpu=2 passes the check (2 <= 2) but
self._valid_gpus[2] is out of bounds.
This commit is contained in:
ryzendigo 2026-03-16 14:28:59 +08:00
parent 5a214eb0d1
commit dfb34367c9

View File

@ -63,7 +63,7 @@ class LibvaGpuSelector:
if not self._valid_gpus:
return ""
if gpu <= len(self._valid_gpus):
if gpu < len(self._valid_gpus):
return self._valid_gpus[gpu]
else:
logger.warning(f"Invalid GPU index {gpu}, using first valid GPU")