llama.cpp icon indicating copy to clipboard operation
llama.cpp copied to clipboard

Feature Request: Implement missing ops from backends

Open am17an opened this issue 1 year ago • 57 comments

Prerequisites

  • [x] I am running the latest code. Mention the version if possible as well.
  • [x] I carefully followed the README.md.
  • [x] I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
  • [x] I reviewed the Discussions, and have a new and useful enhancement to share.

Feature Description

The list of supported operation in ggml per backend is maintained at https://github.com/ggml-org/llama.cpp/blob/master/docs/ops.md

How to contribute to make the list more complete:

  1. Pick an operation which is not implemented in a backend (pick ones marked with āŒ), pick only one per PR
  2. Implement the operation
  3. Test your implementation with test-backend-ops -o <op>
  4. If it passes test for the op, create a PR.
  5. Mention performance tests in the PR if they exist (via test-backend-ops perf -o <op>)

Notes:

  1. The ops suffixed with _BACK are related to training which is WIP and does not require immediate attention
  2. Do not link this issue in your PR, which will lead to closing this issue when your PR is merged. Instead, just mention it. Example PRs will be linked below
  3. This list can be temporarily out of sync, you can check support by first running test-backend-ops -o <op> on master to confirm
  4. Please do not ask to be assigned a particular task, make the PR first if you think it will be useful

Motivation

Feature parity between backends is always desirable and it's easy to test the implementation, making it an ideal good first issue.

Possible Implementation

No response

am17an avatar Jul 28 '25 03:07 am17an

I would like to contribute to this effort. May I ask whether it is okay to work on operators marked as [🟔 Partially supported] in the ops.md table?

jeemzz147 avatar Jul 29 '25 02:07 jeemzz147

I would like to contribute to this effort. May I ask whether it is okay to work on operators marked as [🟔 Partially supported] in the ops.md table?

Yes that would also work. The reason it's preferable to work on completely unsupported ops is because sometimes it's not possible to add full support to an op on a backend (e.g. some quantisation schemes in CUDA) and it might not be clear as a newcomer why that's the case. But if you make an operation support more complete, that would always be welcome!

am17an avatar Jul 29 '25 04:07 am17an

I've verified that PAD_REFLECT_1D is currently unsupported on CUDA. I would like to work on the PAD_REFLECT_1D op for the CUDA. Please let me know if there are any considerations or edge cases I should keep in mind. Thanks!

jeemzz147 avatar Jul 29 '25 06:07 jeemzz147

I've verified that PAD_REFLECT_1D is currently unsupported on CUDA.

It's already in progress in #14659

CISC avatar Jul 29 '25 07:07 CISC

since PAD_REFLECT_1D is already in progress (#14659), I’d like to work on the SET op for the CUDA backend instead. Thanks!

jeemzz147 avatar Jul 29 '25 07:07 jeemzz147

Can I pick up CONV_2D for CUDA please? thank you

Do I need to create a separate issue for that?

nimit25 avatar Jul 29 '25 18:07 nimit25

Hey!

I'm relatively new to the project, have been using llama.cpp in the past. Really would like to help the project grow and contribute what I can.

Curious about two thing:

  1. Is there a good tutorial/guide on getting started with metal framework for this project?
  2. I noticed the BLAS is mostly unsupported backend, just. curious to know if there is a fundamental blocking reason behind this?

Thanks in advance!

iliailmer avatar Sep 01 '25 22:09 iliailmer

@iliailmer

  1. AFAIK there is no tutorial as such, but test-backend-ops always has a reference CPU implementation to compare new implementations with. Other suggestions would be to look at older PRs added related to the backend you're interested in.

  2. BLAS just forwards mul_mat to another library (see ggml-blas.cpp), it would not make sense to add operators there apart from mul_mat and a few others

am17an avatar Sep 02 '25 12:09 am17an

Can I pick up CONV_2D for metal?

vrvrv avatar Sep 29 '25 13:09 vrvrv

Gonna pick up LOG for metal if that's alright?

ayush-os avatar Oct 10 '25 16:10 ayush-os

FYI, I'm gonna pick up OPT_STEP_ADAMW for metal

cern1710 avatar Oct 12 '25 05:10 cern1710

i'm working on conv_transpose_2d

iliailmer avatar Oct 12 '25 16:10 iliailmer

Any reason why nobody is taking up ops for BLAS backend? Literally zero ops =/

pra-dan avatar Nov 27 '25 09:11 pra-dan

The BLAS backend is just a way to use a BLAS library to run matrix multiplications. It's not literally zero ops, MUL_MAT is partially supported. Otherwise this "backend" will use the regular CPU operators.

0cc4m avatar Nov 27 '25 10:11 0cc4m

The referenced table mentions that CUMSUM is implemented on the CPU (and some other) backends, but a quick grep for GGML_OP_CUMSUM leads to no results for me. Is the table incorrect or is CUMSUM called something else?

codetalker7 avatar Dec 07 '25 21:12 codetalker7

A search does find it.

0cc4m avatar Dec 07 '25 21:12 0cc4m

My bad; I was searching in my old local directory. Seems that CUMSUM is now implemented on CUDA as well. I'll try to work on NORM_MUL_ADD.

codetalker7 avatar Dec 07 '25 21:12 codetalker7

My bad; I was searching in my old local directory. Seems that CUMSUM is now implemented on CUDA as well. I'll try to work on NORM_MUL_ADD.

That's a fusion and is only in the list because not all backends have updated their CSVs.

CISC avatar Dec 08 '25 13:12 CISC

@hipudding @noemotiovon @lhez @max-krasnyansky @taronaeo I think CANN, OpenCL and zDNN are the only remaining backends that still have fusion ops in the CSVs, please update them so we can get a more accurate ops.md.

CISC avatar Dec 09 '25 23:12 CISC

@CISC Thank you for the reminder. Updated in #17904.

lhez avatar Dec 10 '25 06:12 lhez