{"id":18711152,"url":"https://github.com/rocm/composable_kernel","last_synced_at":"2026-04-02T11:45:43.826Z","repository":{"id":37015209,"uuid":"390032985","full_name":"ROCm/composable_kernel","owner":"ROCm","description":"Composable Kernel: Performance Portable Programming Model for Machine Learning Tensor Operators","archived":false,"fork":false,"pushed_at":"2025-05-12T19:36:47.000Z","size":40898,"stargazers_count":396,"open_issues_count":107,"forks_count":184,"subscribers_count":25,"default_branch":"develop","last_synced_at":"2025-05-12T20:47:48.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rocm.docs.amd.com/projects/composable_kernel/en/latest/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"asroy/composable_kernel","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ROCm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-07-27T15:22:44.000Z","updated_at":"2025-05-12T16:56:26.000Z","dependencies_parsed_at":"2023-09-23T08:16:59.117Z","dependency_job_id":"48907f17-243f-4100-896d-b4794d962f9a","html_url":"https://github.com/ROCm/composable_kernel","commit_stats":null,"previous_names":["rocm/composable_kernel","rocmsoftwareplatform/composable_kernel"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ROCm%2Fcomposable_kernel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ROCm%2Fcomposable_kernel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ROCm%2Fcomposable_kernel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ROCm%2Fcomposable_kernel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ROCm","download_url":"https://codeload.github.com/ROCm/composable_kernel/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254291974,"owners_count":22046425,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T12:37:21.031Z","updated_at":"2026-04-02T11:45:43.820Z","avatar_url":"https://github.com/ROCm.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Composable Kernel\n\n\u003e [!NOTE]\n\u003e The published documentation is available at [Composable Kernel](https://rocm.docs.amd.com/projects/composable_kernel/en/latest/) in an organized, easy-to-read format, with search and a table of contents. The documentation source files reside in the `docs` folder of this repository. As with all ROCm projects, the documentation is open source. For more information on contributing to the documentation, see [Contribute to ROCm documentation](https://rocm.docs.amd.com/en/latest/contribute/contributing.html).\n\nThe Composable Kernel (CK) library provides a programming model for writing performance-critical\nkernels for machine learning workloads across multiple architectures (GPUs, CPUs, etc.). The CK library\nuses general purpose kernel languages, such as HIP C++.\n\nCK uses two concepts to achieve performance portability and code maintainability:\n\n* A tile-based programming model\n* Algorithm complexity reduction for complex machine learning (ML) operators. This uses an innovative\n   technique called *Tensor Coordinate Transformation*.\n\n![ALT](/docs/data/ck_component.png \"CK Components\")\n\nThe current CK library is structured into four layers:\n\n* Templated Tile Operators\n* Templated Kernel and Invoker\n* Instantiated Kernel and Invoker\n* Client API\n\n![ALT](/docs/data/ck_layer.png \"CK Layers\")\n\n## General information\n\n* [CK supported operations](include/ck/README.md)\n* [CK Tile supported operations](include/ck_tile/README.md)\n* [CK wrapper](client_example/25_wrapper/README.md)\n* [CK codegen](codegen/README.md)\n* [CK profiler](profiler/README.md)\n* [Examples (Custom use of CK supported operations)](example/README.md)\n* [Client examples (Use of CK supported operations with instance factory)](client_example/README.md)\n* [Terminology](/TERMINOLOGY.md)\n* [Contributors](/CONTRIBUTORS.md)\n\nCK is released under the **[MIT license](/LICENSE)**.\n\n## Building CK\n\nWe recommend building CK inside Docker containers, which include all necessary packages. Pre-built\nDocker images are available on [DockerHub](https://hub.docker.com/r/rocm/composable_kernel/tags).\n\n1. To build a new Docker image, use the Dockerfile provided with the source code:\n\n    ```bash\n    DOCKER_BUILDKIT=1 docker build -t ck:latest -f Dockerfile .\n    ```\n\n2. Launch the Docker container:\n\n    ```bash\n    docker run                                     \\\n    -it                                            \\\n    --privileged                                   \\\n    --group-add sudo                               \\\n    -w /root/workspace                             \\\n    -v ${PATH_TO_LOCAL_WORKSPACE}:/root/workspace  \\\n    ck:latest                                      \\\n    /bin/bash\n    ```\n\n3. Clone CK source code from the GitHub repository and start the build:\n\n    ```bash\n    git clone https://github.com/ROCm/composable_kernel.git \u0026\u0026 \\\n    cd composable_kernel \u0026\u0026 \\\n    mkdir build \u0026\u0026 \\\n    cd build\n    ```\n\n    You must set the `GPU_TARGETS` macro to specify the GPU target architecture(s) you want\n    to run CK on. You can specify single or multiple architectures. If you specify multiple architectures,\n    use a semicolon between each; for example, `gfx908;gfx90a;gfx942`.\n\n    ```bash\n    cmake                                                                                             \\\n    -D CMAKE_PREFIX_PATH=/opt/rocm                                                                    \\\n    -D CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc                                                         \\\n    -D CMAKE_BUILD_TYPE=Release                                                                       \\\n    -D GPU_TARGETS=\"gfx908;gfx90a\"                                                                    \\\n    ..\n    ```\n\n    If you don't set `GPU_TARGETS` on the cmake command line, CK is built for all GPU targets\n    supported by the current compiler (this may take a long time). \n    Tests and examples will only get built if the GPU_TARGETS is set by the user on the cmake command line.\n\n    NOTE: If you try setting `GPU_TARGETS` to a list of architectures, the build will only work if the \n    architectures are similar, e.g., `gfx908;gfx90a`, or `gfx1100;gfx1101;gfx11012`. Otherwise, if you \n    want to build the library for a list of different architectures,\n    you should use the `GPU_ARCHS` build argument, for example `GPU_ARCHS=gfx908;gfx1030;gfx1100;gfx942`.\n\n    **Convenience script for development builds:**\n\n    Alternatively, you can use the provided convenience script `script/cmake-ck-dev.sh` which automatically \n    configures CK for development with sensible defaults. In the build directory:\n\n    ```bash\n    ../script/cmake-ck-dev.sh\n    ```\n\n    This script:\n    * Cleans CMake cache files before configuring\n    * Sets `BUILD_DEV=ON` for development mode\n    * Defaults to GPU targets: `gfx908;gfx90a;gfx942`\n    * Enables verbose makefile output\n    * Sets additional compiler flags for better error messages\n\n    By default, it considers the parent directory to be the project source directory.\n\n    You can specify the source directory as the first argument.\n    You can specify custom GPU targets (semicolon-separated) as the second argument:\n\n    ```bash\n    ../script/cmake-ck-dev.sh .. gfx1100\n    ```\n\n    Or pass additional cmake arguments:\n\n    ```bash\n    ../script/cmake-ck-dev.sh .. gfx90a -DCMAKE_BUILD_TYPE=Release\n    ```\n\n5. Build the entire CK library:\n\n    ```bash\n    make -j\"$(nproc)\"\n    ```\n\n6. Install CK:\n\n    ```bash\n    make -j install\n    ```\n    **[See Note on -j](#notes)**\n\n### Building for Windows\n\nInstall TheRock and run CMake configure as\n\n```bash\n    cmake                                                                                      \\\n    -D CMAKE_PREFIX_PATH=\"C:/dist/TheRock\"                                                     \\\n    -D CMAKE_CXX_COMPILER=\"C:/dist/TheRock/bin/hipcc.exe\"                                      \\\n    -D CMAKE_BUILD_TYPE=Release                                                                \\\n    -D GPU_TARGETS=\"gfx1151\"                                                                   \\\n    -G Ninja                                                                                   \\\n    ..\n```\n\nUse Ninja to build either the whole library or individual targets.\n\n## Optional post-install steps\n\n* Build examples and tests:\n\n    ```bash\n    make -j examples tests\n    ```\n\n* Build and run all examples and tests:\n\n    ```bash\n    make -j check\n    ```\n\n    You can find instructions for running each individual example in [example](/example).\n\n* Build and run smoke/regression examples and tests:\n\n    ```bash\n    make -j smoke # tests and examples that run for \u003c 30 seconds each\n    ```\n     ```bash\n    make -j regression # tests and examples that run for \u003e= 30 seconds each\n    ```\n\n* Build ckProfiler:\n\n    ```bash\n    make -j ckProfiler\n    ```\n\n    You can find instructions for running ckProfiler in [profiler](/profiler).\n\n* Build our documentation locally:\n\n    ``` bash\n    cd docs\n    pip3 install -r sphinx/requirements.txt\n    python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html\n    ```\n\n### Notes\nThe `-j` option for building with multiple threads in parallel, which speeds up the build significantly.\nHowever, `-j` launches unlimited number of threads, which can cause the build to run out of memory and\ncrash. On average, you should expect each thread to use ~2Gb of RAM.\nDepending on the number of CPU cores and the amount of RAM on your system, you may want to\nlimit the number of threads. For example, if you have a 128-core CPU and 128 Gb of RAM it's advisable to use `-j32`.\n\nAdditional cmake flags can be used to significantly speed-up the build:\n\n* `DTYPES` (default is not set) can be set to any subset of \"fp64;fp32;tf32;fp16;fp8;bf16;int8\" to build\n  instances of select data types only. The main default data types are fp32 and fp16; you can safely skip\n  other data types.\n\n* `DISABLE_DL_KERNELS` (default is OFF) must be set to ON in order not to build instances, such as `gemm_dl` or\n  `batched_gemm_multi_d_dl`. These instances are useful on architectures like the NAVI2x, as most\n  other platforms have faster instances, such as `xdl` or `wmma`, available.\n\n* `DISABLE_DPP_KERNELS` (default is OFF) must be set to ON in order not to build instances, such as `gemm_dpp`. \n  These instances offer a slightly better performance of fp16 gemms on NAVI2x. But on other architectures faster alternatives are available.\n\n* `CK_USE_FP8_ON_UNSUPPORTED_ARCH` (default is OFF) must be set to ON in order to build instances,\n  such as `gemm_universal`, `gemm_universal_streamk` and `gemm_multiply_multiply` for fp8 data type for GPU targets which do not  have native support for fp8 data type, such as gfx908 or gfx90a. These instances are useful on\n  architectures like the MI100/MI200 for the functional support only.\n\n## Using sccache for building\n\nThe default CK Docker images come with a pre-installed version of sccache, which supports clang\nbeing used as hip-compiler (\" -x hip\"). Using sccache can help reduce the time to re-build code from\nhours to 1-2 minutes. In order to invoke sccache, you need to run:\n\n```bash\n sccache --start-server\n```\n\nthen add the following flags to the cmake command line:\n\n```bash\n -DCMAKE_HIP_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER_LAUNCHER=sccache\n```\n\nYou may need to clean up the build folder and repeat the cmake and make steps in order to take\nadvantage of the sccache during subsequent builds.\n\n## Using CK as pre-built kernel library\n\nYou can find instructions for using CK as a pre-built kernel library in [client_example](/client_example).\n\n## Contributing to CK\n\nWhen you contribute to CK, make sure you run `clang-format` on all changed files. We highly\nrecommend using git hooks that are managed by the `pre-commit` framework. To install hooks, run:\n\n```bash\nsudo script/install_precommit.sh\n```\n\nWith this approach, `pre-commit` adds the appropriate hooks to your local repository and\nautomatically runs `clang-format` (and possibly additional checks) before any commit is created.\n\nIf you need to uninstall hooks from the repository, you can do so by running the following command:\n\n```bash\nscript/uninstall_precommit.sh\n```\n\nIf you need to temporarily disable pre-commit hooks, you can add the `--no-verify` option to the\n`git commit` command.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocm%2Fcomposable_kernel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frocm%2Fcomposable_kernel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocm%2Fcomposable_kernel/lists"}