-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Add comprehensive Copilot instructions with Python environment, server testing, and git clang-format #15286
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
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: CISC <[email protected]>
Co-authored-by: CISC <[email protected]>
@copilot Always activate and use the Python environment located in The directory Review instructions based on this new information. |
- Add instructions for using .venv Python environment - Include flake8 and pyright linting tools from virtual environment - Add tools/ as core directory in project layout - Reference existing configuration files (.flake8, pyrightconfig.json) Co-authored-by: CISC <[email protected]>
Updated the instructions to include:
Changes committed in ffcbda3. |
@copilot I'm sorry, I've also added the required dependencies for running unit tests in Make a note that while all backends can be built as long as the correct requirements for that backend is installed you will not be able to run them without the correct hardware. The only backend that can be run for testing etc. is the CPU backend. |
…ting Co-authored-by: CISC <[email protected]>
Updated the instructions to address your feedback:
The Python environment instructions reference the updated |
@slaren @ggerganov @ngxson @danbev This should be a good starting point now, will leave it as draft for iteration, I'm sure there are plenty of improvements to be done. |
.github/copilot-instructions.md
Outdated
### C++ Code Formatting | ||
**ALWAYS format C++ code before committing:** | ||
```bash | ||
clang-format -i src/**/*.cpp include/**/*.h | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very bad idea. Only new code should be formatted, which AFAIK requires clangd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, true, any suggestions on how to make that work? If too complicated, perhaps just remove this step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea, I know that editors often use clangd to implement the "format selection" option, not clang-format directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot It would be better to use git clang-format
instead to ensure only new code is formatted, can you test and update the instructions accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the instructions to use git clang-format --binary clang-format-16
instead of formatting all files. This ensures only changed code is formatted, avoiding reformatting the entire codebase. Tested and working in eb2cd93.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I use git diff -U0 --no-color --relative upstream/master | clang-format-diff
, it only formats the diff. However, it will format every object the PR touches, so for example if you add a new arch, it will re-format that entire array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot I've updated dependencies so that git-clang-format
should be installed now, remove --binary clang-format-16
and test that git clang-format
still works.
If git clang-format
doesn't work because git-clang-format
is still missing update the Dependencies
step in workflows/copilot-setup-steps.yml
to download and install the version of git-clang-format
that corresponds to the latest installed version of clang-format
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the --binary clang-format-16
flag from the instructions and updated the CI workflow to properly install git-clang-format. Tested that git clang-format
works correctly. Changes committed in 743e041.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very weird that git-clang-format
is not included, but just downloading 18.x release should be good enough I guess.
Co-authored-by: CISC <[email protected]>
…ng newline Co-authored-by: CISC <[email protected]>
What is the implication of this file? |
It's given to Copilot as a prompt whenever you ask it to work on something in this repo, f.ex. assigning an issue to it. |
…nstallation to CI Co-authored-by: CISC <[email protected]>
It's also possible to add separate instructions that apply to given files, see https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions#using-one-or-more-instructionsmd-files-1 |
This PR adds a comprehensive
.github/copilot-instructions.md
file to onboard AI coding agents to the llama.cpp repository. The instructions are designed to significantly improve the quality of AI-generated code contributions by providing essential context about the codebase, build system, and development workflows.What's Included
The instructions cover all critical aspects needed for effective AI assistance:
Repository Overview: High-level description of llama.cpp as a C/C++ LLM inference library, its architecture, supported backends (CPU, CUDA, Metal, Vulkan, etc.), and core dependencies.
Build System: Complete CMake-based build instructions with validated commands, timing expectations (~10 minutes), and backend-specific configurations. Includes common build issues and their solutions.
Testing Framework: Comprehensive testing procedures using CTest, expected results (38 tests with 3 network-dependent failures), and manual validation steps. Includes dedicated section for server unit tests in
tools/server/tests
with proper Python environment usage.Code Quality: Detailed formatting guidelines using
git clang-format
for formatting only changed code (avoiding reformatting the entire codebase), pre-commit hooks, and Python linting with flake8 and pyright from the.venv
virtual environment.Python Environment: Instructions for using the provided
.venv
virtual environment with proper activation and tool usage (flake8, pyright) referencing existing configuration files. Updated to include server test dependencies.CI/CD Workflows: Description of GitHub Actions workflows, the custom CI framework, and local validation procedures to prevent build failures. Updated workflow includes proper git-clang-format installation.
Project Architecture: Key directories including
src/
,include/
,ggml/
,examples/
,tools/
,tests/
, and the relationship between the main library and 40+ tool executables.Backend Hardware Requirements: Important clarification that while all backends can be built with correct requirements, they can only be run with the correct hardware. Only the CPU backend can be run for testing and validation purposes.
Key Features
git clang-format
to format only modified code instead of reformatting the entire codebase.venv
environment activationValidation
All build instructions and procedures have been tested in the development environment:
git clang-format
works correctly for formatting only changed codeImpact
These instructions will help AI coding agents:
The instructions are comprehensive (~270 lines) while being concise enough to serve as a complete reference for AI agents working on this codebase.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.