Skip to content

Merge DeviceStream into CommandEncoder#3264

Merged
zcbenz merged 1 commit intoml-explore:mainfrom
zcbenz:encoder-refactor-1
Mar 19, 2026
Merged

Merge DeviceStream into CommandEncoder#3264
zcbenz merged 1 commit intoml-explore:mainfrom
zcbenz:encoder-refactor-1

Conversation

@zcbenz
Copy link
Copy Markdown
Collaborator

@zcbenz zcbenz commented Mar 16, 2026

Refs #3078, #3216.

Merge the members of DeviceStream into CommandEncoder, and move implementations of encoding methods from Device to CommandEncoder. With this change we would only need to make get_command_encoder thread safe to be able to run multi-streams in multi-threads.

@zcbenz zcbenz force-pushed the encoder-refactor-1 branch from b4c6677 to 3d01c86 Compare March 16, 2026 08:38
@zcbenz zcbenz requested a review from angeloskath March 18, 2026 22:32
Copy link
Copy Markdown
Member

@angeloskath angeloskath left a comment

Choose a reason for hiding this comment

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

Sorry for taking long to review this.

It looks really good. I think the merging is helpful even to clean things up a bit. I have one comment that is more conceptual than practical and I apologize in advance if it is too pedantic. Feel free to ignore it.

The CommandEncoder used to represent the command encoder. A transient object that encodes commands to the GPU and then goes away. The stream was the persistent object. As a result there was a natural place to put the outputs of previous command encoders while keeping the within command encoder inputs outputs in the CommandEncoder object. It is also the reason you felt the need to change the map output to fence to prev_fences_ from outputs.

Anyway, I don't have a good solution tbh. Perhaps adding a comment on line 111 that explains that this block of members is to synchronize the kernels within a single MTL::ComputeCommandEncoder and maybe rename prev_fences_ to prev_ce_outputs_ ?

@zcbenz zcbenz force-pushed the encoder-refactor-1 branch from 3d01c86 to 0d67d84 Compare March 19, 2026 08:42
@zcbenz zcbenz merged commit c8292ea into ml-explore:main Mar 19, 2026
16 checks passed
@zcbenz zcbenz deleted the encoder-refactor-1 branch March 19, 2026 10:39
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.

2 participants