Skip to content

Docs: script to auto-generate ggml operations docs #14598

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

Merged
merged 4 commits into from
Jul 10, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/update-ops-docs.yml
Copy link
Member

@slaren slaren Jul 9, 2025

Choose a reason for hiding this comment

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

You can test this in your own fork, but adding commits will be trickier than this. It may be preferable to only check if the document is out of date, and fail the job if it is not, but not actually update it. server.yml does this for the WebUI bundle file.

Copy link
Collaborator

@ngxson ngxson Jul 9, 2025

Choose a reason for hiding this comment

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

IMO we don't necessarily need to commit the result to the repo. Managing CI permission can be tricky.

Maybe a simple command to print this list to console is enough. Something like: test-backend-ops --support --output table which outputs markdown table directly to the console.

Some extra things to concern about:

  1. I feel like the python script is not necessary. It's kinda a hack on top of existing cpp code. Ok maybe unfair to say this because the python code actually takes multiple CSV from multiple cpp runs. But still, I feel like there is an easier way to do so..
  2. Having a "checking" pipeline like @slaren suggest can lead to extra works whenever someone wants to implement a trivial kernel. For example, when adding ggml_gelu_erf, having to regenerate the CSV, then regenerate the table - that's 2 extra steps.
  3. What about the case where we have rtx3090.csv but I only have an RTX 4060? Which file will be taken for generating the table?

Just to be clear, I do think this feature is useful, but I just want to do it without too much over-engineering

Copy link
Member

Choose a reason for hiding this comment

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

The workflow only runs if the csv files changes, so adding a new op alone won't make it fail.

3. What about the case where we have rtx3090.csv but I only have an RTX 4060? Which file will be taken for generating the table?

Yeah we should only have one for each backend. Multiple runs with different devices can be merged into a single file if necessary and to add more details in the future, but not really very important.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Update Operations Documentation

on:
push:
paths:
- 'docs/ops/**'
- 'scripts/create_ops_docs.py'
pull_request:
paths:
- 'docs/ops/**'
- 'scripts/create_ops_docs.py'

jobs:
update-ops-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Generate operations documentation to temporary file
run: |
mkdir -p /tmp/ops_check
./scripts/create_ops_docs.py /tmp/ops_check/ops.md

- name: Check if docs/ops.md matches generated version
run: |
if ! diff -q docs/ops.md /tmp/ops_check/ops.md; then
echo "Operations documentation (docs/ops.md) is not up to date with the backend CSV files."
echo "To fix: run ./scripts/create_ops_docs.py and commit the updated docs/ops.md along with your changes"
echo "Differences found:"
diff docs/ops.md /tmp/ops_check/ops.md || true
exit 1
fi
echo "Operations documentation is up to date."
95 changes: 95 additions & 0 deletions docs/ops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# GGML Operations

List of GGML operations and backend support status.

Legend:
- ✅ Fully supported by this backend
- 🟡 Partially supported by this backend
- ❌ Not supported by this backend

| Operation | CPU | CUDA |
|-----------|------|------|
| ABS | ✅ | 🟡 |
| ACC | ✅ | ✅ |
| ADD | ✅ | ✅ |
| ADD1 | ✅ | ✅ |
| ARANGE | ✅ | ✅ |
| ARGMAX | ✅ | ✅ |
| ARGSORT | ✅ | ✅ |
| CLAMP | ✅ | ✅ |
| CONCAT | ✅ | 🟡 |
| CONT | ✅ | 🟡 |
| CONV_2D_DW | ✅ | ✅ |
| CONV_TRANSPOSE_1D | ✅ | ✅ |
| CONV_TRANSPOSE_2D | ✅ | ✅ |
| COS | ✅ | ✅ |
| COUNT_EQUAL | ✅ | ✅ |
| CPY | 🟡 | 🟡 |
| CROSS_ENTROPY_LOSS | ✅ | ✅ |
| CROSS_ENTROPY_LOSS_BACK | ✅ | ✅ |
| DIAG_MASK_INF | ✅ | ✅ |
| DIV | ✅ | ✅ |
| DUP | ✅ | 🟡 |
| ELU | ✅ | ❌ |
| EXP | ✅ | 🟡 |
| FLASH_ATTN_EXT | ✅ | 🟡 |
| GATED_LINEAR_ATTN | ✅ | ✅ |
| GEGLU | ✅ | ✅ |
| GEGLU_ERF | ✅ | ✅ |
| GEGLU_QUICK | ✅ | ✅ |
| GELU | ✅ | 🟡 |
| GELU_ERF | ✅ | 🟡 |
| GELU_QUICK | ✅ | 🟡 |
| GET_ROWS | ✅ | 🟡 |
| GET_ROWS_BACK | 🟡 | 🟡 |
| GROUP_NORM | ✅ | ✅ |
| HARDSIGMOID | ✅ | 🟡 |
| HARDSWISH | ✅ | 🟡 |
| IM2COL | ✅ | ✅ |
| L2_NORM | ✅ | ✅ |
| LEAKY_RELU | ✅ | ✅ |
| LOG | ✅ | ✅ |
| MEAN | ✅ | ✅ |
| MUL | ✅ | ✅ |
| MUL_MAT | 🟡 | 🟡 |
| MUL_MAT_ID | ✅ | ✅ |
| NEG | ✅ | 🟡 |
| NORM | ✅ | ✅ |
| OPT_STEP_ADAMW | ✅ | ✅ |
| OUT_PROD | 🟡 | 🟡 |
| PAD | ✅ | ✅ |
| PAD_REFLECT_1D | ✅ | ❌ |
| POOL_2D | ✅ | ✅ |
| REGLU | ✅ | ✅ |
| RELU | ✅ | 🟡 |
| REPEAT | ✅ | 🟡 |
| REPEAT_BACK | ✅ | ✅ |
| RMS_NORM | ✅ | ✅ |
| RMS_NORM_BACK | ✅ | ✅ |
| RMS_NORM_MUL | ✅ | ✅ |
| ROPE | ✅ | ✅ |
| ROPE_BACK | ✅ | ✅ |
| RWKV_WKV6 | ✅ | ✅ |
| RWKV_WKV7 | ✅ | ✅ |
| SCALE | ✅ | ✅ |
| SET | ✅ | ❌ |
| SET_ROWS | 🟡 | ❌ |
| SGN | ✅ | 🟡 |
| SIGMOID | ✅ | 🟡 |
| SILU | ✅ | 🟡 |
| SILU_BACK | ✅ | ✅ |
| SIN | ✅ | ✅ |
| SOFT_MAX | ✅ | ✅ |
| SOFT_MAX_BACK | 🟡 | 🟡 |
| SQR | ✅ | ✅ |
| SQRT | ✅ | ✅ |
| SSM_CONV | ✅ | ✅ |
| SSM_SCAN | ✅ | ✅ |
| STEP | ✅ | 🟡 |
| SUB | ✅ | ✅ |
| SUM | ✅ | ✅ |
| SUM_ROWS | ✅ | ✅ |
| SWIGLU | ✅ | ✅ |
| TANH | ✅ | 🟡 |
| TIMESTEP_EMBEDDING | ✅ | ✅ |
| UPSCALE | ✅ | ✅ |
Loading
Loading