Skip to content

Error instead of deadlocking when in-place op operands share storage#3614

Open
NahButch wants to merge 1 commit into
huggingface:mainfrom
NahButch:inplace-deadlock
Open

Error instead of deadlocking when in-place op operands share storage#3614
NahButch wants to merge 1 commit into
huggingface:mainfrom
NahButch:inplace-deadlock

Conversation

@NahButch

Copy link
Copy Markdown

inplace_op2/inplace_op3 take a write lock on self's storage and then a read lock on the other operands' storage. When the operands are views into the same tensor, both locks target the same non-reentrant RwLock and the call deadlocks.

Detect shared storage with same_storage and return a clear error — the same contract slice_set already uses. Adds a regression test; on the previous code it hangs forever (verified via timeout).

Fixes #3227

🤖 Generated with Claude Code

inplace_op2/inplace_op3 take a write lock on self's storage and then a
read lock on the other operands' storage. When the operands are views
into the same tensor, both locks target the same non-reentrant RwLock
and the call deadlocks.

Detect shared storage with same_storage and return a clear error, the
same contract slice_set already uses. Adds a regression test; on the
previous code it hangs forever.

Fixes huggingface#3227

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

In-place ops deadlock when operands share the same storage

1 participant