Skip to content

[shim] Fix GPU ownership of restored tasks - #4218

Merged
un-def merged 1 commit into
masterfrom
pr_shim_fix_restored_gpu_ids
Aug 26, 2026
Merged

[shim] Fix GPU ownership of restored tasks#4218
un-def merged 1 commit into
masterfrom
pr_shim_fix_restored_gpu_ids

Conversation

@un-def

@un-def un-def commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

restoreStateFromContainers() stored the GPU IDs extracted from the container on the task, but GpuLock.Lock() locks only the GPUs that are not locked yet and returns that subset. If two restored containers report the same GPU, the second task claims a GPU it does not hold, and releasing that task's resources frees a GPU the first one is still using.

A restored task now owns only the GPUs actually locked for it. The GPUs locked for a task that cannot be stored, e.g., one with a duplicate task ID, are released as well, as nothing else will release them.

Also adds the first tests covering restoreStateFromContainers(). They use a fake docker.APIClient implementing the two methods it calls, so they need no Docker daemon.

restoreStateFromContainers() stored the GPU IDs extracted from the
container on the task, but GpuLock.Lock() locks only the GPUs that are
not locked yet and returns that subset. If two restored containers
report the same GPU, the second task claims a GPU it does not hold, and
releasing that task's resources frees a GPU the first one is still
using.

A restored task now owns only the GPUs actually locked for it. The GPUs
locked for a task that cannot be stored, e.g., one with a duplicate task
ID, are released as well, as nothing else will release them.

Also adds the first tests covering restoreStateFromContainers(). They
use a fake docker.APIClient implementing the two methods it calls, so
they need no Docker daemon.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@un-def
un-def merged commit 7820727 into master Aug 26, 2026
27 checks passed
@un-def
un-def deleted the pr_shim_fix_restored_gpu_ids branch August 26, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant