Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add GGML_UNARY_OP_ARGMAX Metal kernel #1019

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PABannier
Copy link
Contributor

This PR implements the Metal kernel used for the GGML_UNARY_OP_ARGMAX operation.

It is necessary for Encodec.cpp to run on the Metal backend.

@ggerganov
Copy link
Owner

Thanks, will merge these soon. Just need to sync the ggerganov/llama.cpp#10238 from llama.cpp to avoid resolving conflicts manually.

[encoder setBuffer:id_dst offset:offs_dst atIndex:1];
[encoder setBytes:&ne00 length:sizeof( int64_t) atIndex:2];

[encoder dispatchThreadgroups:MTLSizeMake(1, 1, 1) threadsPerThreadgroup:MTLSizeMake(nrows, 1, 1)];
Copy link
Owner

Choose a reason for hiding this comment

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

Threadgroup sizes are typically maximum of 1024, so this implementation will stop working when nrows is larger than 1024. Instead, we should launch multiple threadgroups and distribute the rows across them.

Also, the implementation currently assumes src0 is contiguous, so add a GGML_ASSERT for that or extend the implementation by providing and taking account of the strides.

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