Skip to content

Remove multithreading concepts from metal.rs#529

Open
jgilchrist wants to merge 1 commit into
jw1912:mainfrom
tcheran-chess:no-thread-stuff-in-metal-runtime
Open

Remove multithreading concepts from metal.rs#529
jgilchrist wants to merge 1 commit into
jw1912:mainfrom
tcheran-chess:no-thread-stuff-in-metal-runtime

Conversation

@jgilchrist

Copy link
Copy Markdown
Contributor

The original change by Blightwidow had a lot of things wrapped in Mutex, Send, Atomic, etc. but training is single-threaded so it's all unnecessary.

This switches everything to RefCell instead. It also removes BufferEntry which was a completely unnecessary wrapper around a dyn MetalBuffer.

@jgilchrist

Copy link
Copy Markdown
Contributor Author

Ah, will get this rebased

@jgilchrist jgilchrist force-pushed the no-thread-stuff-in-metal-runtime branch 2 times, most recently from fabcb06 to 50b3f2f Compare June 15, 2026 16:30
matrices as NSUInteger,
(row_bytes * 4) as NSUInteger,
(matrix_bytes * 4) as NSUInteger,
(row_numel * 4) as NSUInteger,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed after the rename in 45b0210

/// The only concrete type that does get constructed in this
/// that does not also implement Send + Sync is MTLBuffer
/// and we only use this in a safe way
struct SendMetal<T: ?Sized>(Retained<ProtocolObject<T>>);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SendMetal and BufferEntry both go away

The original change had a lot of things wrapped in Mutex, Send, Atomic, etc. but
training is single-threaded so it's all unnecessary.

This switches everything to RefCell instead. It also removes BufferEntry
which was a completely unnecessary wrapper around a dyn MetalBuffer.
@jgilchrist jgilchrist force-pushed the no-thread-stuff-in-metal-runtime branch from 50b3f2f to 628fb03 Compare June 15, 2026 16:35
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