Skip to content

Add GitHub Action for code formatting checks in src/ggml-hsa#138

Draft
Copilot wants to merge 108 commits intohsa-backendfrom
copilot/add-github-action-format-check
Draft

Add GitHub Action for code formatting checks in src/ggml-hsa#138
Copilot wants to merge 108 commits intohsa-backendfrom
copilot/add-github-action-format-check

Conversation

Copy link

Copilot AI commented Oct 14, 2025

Overview

This PR adds an automated GitHub Action workflow that enforces code formatting standards for the src/ggml-hsa directory. The workflow checks both Python and C++ files and provides detailed feedback when formatting issues are detected.

Changes

1. New GitHub Action Workflow (.github/workflows/format-check.yml)

Created a comprehensive workflow that:

  • Triggers automatically on:

    • Pull requests that modify files in src/ggml-hsa/**
    • Pushes to the hsa-backend branch that modify files in src/ggml-hsa/**
  • Python Formatting: Uses Black to check all Python files (.py) in src/ggml-hsa

  • C++ Formatting: Uses clang-format-20 to check all C++ files (.cpp, .hpp, .h, .c) against the existing .clang-format style file in src/ggml-hsa/

  • Key Behavior:

    • ✅ Only suggests changes via detailed diffs in GitHub Step Summary
    • Never modifies code automatically
    • ✅ Fails the check when formatting issues are detected
    • ✅ Provides clear, actionable instructions for developers to fix issues locally

2. Documentation (Updated src/ggml-hsa/README.md)

Added a new "Code Formatting" section that documents:

  • Python formatting requirements and commands
  • C++ formatting requirements and commands
  • How the automated checks work
  • Clear statement that changes are never applied automatically

Technical Details

The workflow uses clang-format-20 because the existing .clang-format file in src/ggml-hsa/ contains options (like AlignCaseArrows) that are only supported in version 20 or later.

Example Output

When formatting issues are detected, developers will see:

  • A failed check with clear error messages
  • Detailed diffs showing exactly what needs to change
  • Instructions on how to fix the issues locally using black or clang-format-20

Example fix commands:

# Fix Python files
black src/ggml-hsa

# Fix C++ files
clang-format-20 -i --style=file:src/ggml-hsa/.clang-format <file>

Benefits

  • 🎯 Enforces consistent code style automatically
  • 📝 Clear documentation for contributors
  • 🔍 Catches formatting issues early in the review process
  • 🚫 Respects developer control - never modifies code automatically
  • ✨ Provides helpful diffs and instructions

Closes #[issue_number]

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Create github action that checks code formatting</issue_title>
<issue_description>We need a github action that checks the files in src/ggml-hsa if the follow the coding style. If the format is not correct, it should suggest a change but never make the change itself.

For Python files, it is enforced by black.

For C++, clang format is to be used with the file in https://github.com/ypapadop-amd/ggml/blob/hsa-backend/src/ggml-hsa/.clang-format</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #134


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

* CMake support for HSA backend

* Stubs for initializing HSA

* Stubs for HSA buffers

* Stubs for HSA and host buffers

* Using new backend CMake declaration

* Additional stubs for HSA backend

* Formatting

* Adding function to track unimplemented APIs
* Identifying memory pools

* Support for buffer type alignment and max size

* Cache memory properties

* Comments

* Using fixed-width integrals

* Buffer allocation support
* Adding HSA backend to examples/simple-backend

* Adding HSA backend to backend registration

* Adding Eigen as a temporary matrix mulmat implementation

* Support for device type reporting

* Support for free and total memory reporting

* Properly reporting which kernels are supported
* More function implementations, cleanups

* Remove redundant information, catch exception
* Correcting comment

* Add description from agent name

* Implementation of backend get_device_description

* Comments

* Adding cpu backend as fallback for all ops

* Marking which functions can be improved and correct guid

* Remove needs-implementation marker on more functions

* Hide cpu backend internally

* Remove extra header
* HSA backend in test-mul-mat

* HSA backend in gpt-2-backend

* Offloading to CPU backend if operation not implemented
* Creating HSA queue

* Zero-init all members

* Adding signal support
* Add HSA backend to GPT-2 example

* Remove CPU backend from HSA

* Returning that it is host buffer for NPU memory

* Adding CPY kernels and factoring out kernel code

* Formatting, comments

* Temporary storage for cpy

* Extracting supports_op conditions

* Renaming function
* Add option for CPU fallback in CMakeLists

* Adding fallback to CPU backend if operation is not supported
* Add operation example

* Using tensor count variable

* Count source tensors and copy name

* Detect if execution failed

* Switching test to int32_t

* add kernel using XRT

* Aligning example size with kernel

* Adding dev heap pool

* Using HSA in add kernel

* Using relaxed write to queue

* Remove XRT dependency

* Size independent test

* Correct elements for kernel

* Moving load functions to common.h

* Using simplified AIE packet

* Moving loading to a kernel registry

* Adding constructor

* Add kernel

* Refactoring add script

* Single name for PDI and instr.txt

* Refactoring

* Generalizing add.py

* Adding dims

* Comments and error checking

* Modularize python script

* CMake kernel generation

* Remove magic numbers and use GGML data type naming

* Adding a structure for NPU kernels and free function

* Accepting only contiguous tensors for now

* Stub for keeping loaded kernel in context

* Passing device info as parameter, renaming contexts for easy filtering

* Renaming variables

* Reworking example

* Using registry of kernels

* Using HSA agent name for kernels

* Using dladdr to get the kernel directory
* Using static instead of anonymous namespace

* Handling exceptions
* clang-format configuration loosely based on ggml-sycl

* Formatting
* Comments, disabling copy/move when not allowed

* Replacing high / low bits macros

* Factoring out dispatch functionality

* Free all finished packets
* Missing checks in example

* Adding init_tensor support
* Vector add for floats

* Handling higher dims upon load

* Move tensor testing in the operation supports function

* mul_mat kernel compilation

* Smaller gemm

* Renaming args

* Smaller gemm

* Copy instead of moving PDI

* Unify cmake kernel generation functions

* Using latest CMake Python integration

* Missing CMake HSA integration

* Install kernels

* Adding missing dependencies

* Updating test to use HSA conditionally. HSA-specific mul_mat test

* Encoding all dims in kernel filename
* Using new compilation process in CMake

* Loading insts as binary
* Renaming dispatch function

* Track allocated memory for packets
* Avoid warnings

* Adding extra data to HSA backend tensors

* Caching kernel in tensor extra metadata
* Renaming pending data functions. Refactor packet dispatch

* Guard all CPU fallback cases

* Internal nodes do not init extra until after graph allocation

* Assert cleanups

* Comments

* Separate CMake support
* Add expected find_package definitions

* Expose both C and C++ Peano compilers

* Remove unused property

* Relocating kernels

* Output kernels for a device in a directory

* Explicit names for Peano compilation
* Python script fixes

* Separating kernel discovery to its own header
* Remove conservative asserts

* Removing cpy kernel. Delegating to the CPU device for supports_op

* Extracting types in example

* Create completely independent fallback graph

* Correct source tensor iteration

* Better messages

* Caching emulated tensors
ypapadop-amd and others added 8 commits October 13, 2025 10:49
* Avoid multiple logging

* Abstracting log switch

* Enable/disable logging at run-time
* Verbose log when kernel not found

* Fix typo

* Use ggml_op_is_empty when possible. Remove deadcode

* Move ggml-hsa specific tests to separate directory

* Move simple-vector example as a test-vector-hsa
* Raise exception if module not found

* Moving kernels as generic

* Reorganizing IRON kernels

* Avoiding shadowing function name

* Update README

* Update src/ggml-hsa/kernels/build.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Initial plan

* Add GitHub Copilot instructions for GGML repository

Co-authored-by: ypapadop-amd <102817138+ypapadop-amd@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ypapadop-amd <102817138+ypapadop-amd@users.noreply.github.com>
* Updating requirements

* Remove chaning cwd
* Remove CoreFunction from kernel implementation

* Moving parameters out of CoreFunction

* Per arch num of cols

* Hybrid solution with both CoreFunction and external functions helper

* Moving more out of the CoreFunction factory

* Remove CoreFunction

* Renaming kernel files

* Remove unused variable
Copilot AI and others added 3 commits October 14, 2025 15:23
Co-authored-by: ypapadop-amd <102817138+ypapadop-amd@users.noreply.github.com>
Co-authored-by: ypapadop-amd <102817138+ypapadop-amd@users.noreply.github.com>
Co-authored-by: ypapadop-amd <102817138+ypapadop-amd@users.noreply.github.com>
Copilot AI changed the title [WIP] Add GitHub action to check code formatting Add GitHub Action for code formatting checks in src/ggml-hsa Oct 14, 2025
Copilot AI requested a review from ypapadop-amd October 14, 2025 15:30
@ypapadop-amd ypapadop-amd force-pushed the hsa-backend branch 2 times, most recently from 2476d49 to fc9f7fc Compare October 23, 2025 18:35
@ypapadop-amd ypapadop-amd force-pushed the hsa-backend branch 2 times, most recently from e9fd043 to 4622500 Compare November 3, 2025 17:12
@ypapadop-amd ypapadop-amd force-pushed the hsa-backend branch 2 times, most recently from 62b78e4 to 52d220b Compare November 17, 2025 17:10
@ypapadop-amd ypapadop-amd force-pushed the hsa-backend branch 3 times, most recently from 092e35d to 6f9f0ea Compare December 15, 2025 18:59
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.

Create github action that checks code formatting

3 participants