huggingface / huggingface/candle

In-place ops deadlock when operands share the same storage

Open
#3,227 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
21k
Forks
1.8k
Avg merge
16h 42m
Merged PRs (30d)
25

Description

In `InPlaceOp2`, we must acquire a write lock on the lhs tensor's storage and a read lock on the rhs tensor's storage. Because Rust's RwLock is not reentrant, this results in a deadlock when both tensors share the same storage (e.g., are narrowed views into a larger tensor).

https://github.com/huggingface/candle/blob/9ede2041fe36b6ece24c69ce48d19de51c74d166/candle-core/src/custom_op.rs#L361-L364

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in candle-core/src/custom_op.rs around lines 361-364 and inspect how InPlaceOp2 acquires the lhs write lock and rhs read lock. Reproduce the shared-storage case with narrowed tensor views, then verify that the operation no longer deadlocks while preserving the intended locking behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.