Skip to content

How does Candle's metal implementation work? #2160

Closed Answered by nihalpasham
nihalpasham asked this question in Q&A
Discussion options

You must be logged in to vote

I figured out what I was missing.

Something that's worth noting in the implementation, is that the backend is "lazy" in that unless you are moving the data to the CPU, the operations are not committed.

Yep, that makes sense. Commands are encoded in a command buffer but only committed when one of two conditions is met:

  • The commit threshold is exceeded (more than 50 commands) or
  • An operation indirectly triggers a commit, such as printing the actual data of a tensor.

In my previous example with a simple matmul operation, I kept adding breakpoints to find the indirect manual trigger that commits the corresponding command buffer. However, I overlooked inspecting the print statement itself. T…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@nihalpasham
Comment options

@tomsanbear
Comment options

@nihalpasham
Comment options

Answer selected by nihalpasham
@tomsanbear
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants