|
| 1 | +# Contributing to Halide |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Halide! This document explains |
| 4 | +how to participate in the project, whether you're reporting a bug, proposing a |
| 5 | +feature, or submitting code. |
| 6 | + |
| 7 | +## Code of Conduct |
| 8 | + |
| 9 | +All participants in the Halide community are expected to follow our |
| 10 | +[Code of Conduct](CODE_OF_CONDUCT.md). Please read it before contributing. |
| 11 | + |
| 12 | +## Getting started |
| 13 | + |
| 14 | +### Before opening a pull request |
| 15 | + |
| 16 | +If you are new to the project, please open an Issue or start a Discussion before |
| 17 | +submitting a pull request. This helps us align on the approach before you invest |
| 18 | +significant effort, and avoids situations where a contribution gets rejected |
| 19 | +after the work is already done. |
| 20 | + |
| 21 | +Even for established contributors, opening an Issue or Discussion first is |
| 22 | +encouraged for any non-trivial change. |
| 23 | + |
| 24 | +### Questions and brainstorming |
| 25 | + |
| 26 | +For questions about using Halide, brainstorming ideas, or early-stage feature |
| 27 | +discussions, please use |
| 28 | +[GitHub Discussions](https://github.com/halide/Halide/discussions). Issues are |
| 29 | +reserved for actionable items: confirmed bugs, missed optimizations with |
| 30 | +reproducing cases, and polished feature specifications. |
| 31 | + |
| 32 | +## Reporting bugs |
| 33 | + |
| 34 | +We have two issue templates for different kinds of problems: |
| 35 | + |
| 36 | +- **Bug report** — for functional correctness issues (wrong output, crashes, |
| 37 | + compilation failures, etc.) |
| 38 | +- **Enhancement requests** — for cases where Halide produces a correct output, |
| 39 | + but something could be better: an error message could be made clearer, |
| 40 | + documentation is missing or misleading, an optimization was missed, or a |
| 41 | + pipeline took unexpectedly long to compile. |
| 42 | + |
| 43 | +Both templates will ask you to provide a minimal reproducing case. The more |
| 44 | +self-contained your example, the faster we can investigate. |
| 45 | + |
| 46 | +## Proposing features |
| 47 | + |
| 48 | +Feature proposals should be well-specified: describe the problem, the proposed |
| 49 | +solution, and any alternatives you considered. If your idea is still in the |
| 50 | +brainstorming stage, start a Discussion instead; it can be promoted to an issue |
| 51 | +once the design solidifies. |
| 52 | + |
| 53 | +## Pull requests |
| 54 | + |
| 55 | +### Requirements |
| 56 | + |
| 57 | +_Note: the following list of requirements is still in an aspirational state. You |
| 58 | +may see contributors make ad-hoc, but justified, exceptions to these rules. When |
| 59 | +this happens, the justification should be noted in writing in the PR comments._ |
| 60 | + |
| 61 | +- **Tests are expected** for all code changes. Bug fixes should include a |
| 62 | + regression test. New features should include tests that exercise the new |
| 63 | + functionality. We will always ask that new features come with a fuzz test, |
| 64 | + where applicable. Documentation-only changes, CI configuration updates, and |
| 65 | + trivial fixes (typos, formatting) are exempt. |
| 66 | + |
| 67 | +- **CI must be green.** We merge on green. Our CI runs a number of automated |
| 68 | + checks, including (but not limited to) `clang-format` for C++ and `ruff` for |
| 69 | + Python. If CI fails, please update your PR to fix the issue. The set of checks |
| 70 | + may grow over time. We use `pre-commit` to enforce these checks in CI; it is a |
| 71 | + good idea to run it locally, too. |
| 72 | + |
| 73 | +- **AI attribution.** If a significant part of your contribution was generated |
| 74 | + by an AI tool, you must note this in the commit message using a |
| 75 | + `Co-authored-by` trailer, as described in the |
| 76 | + [Code of Conduct](CODE_OF_CONDUCT.md). For example (this list is not |
| 77 | + exhaustive): |
| 78 | + |
| 79 | + ``` |
| 80 | + Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> |
| 81 | + Co-authored-by: Cursor <cursoragent@cursor.com> |
| 82 | + Co-authored-by: Gemini 3 <gemini-code-assist@google.com> |
| 83 | + Co-authored-by: copilot-swe-agent[bot] <198982749+copilot@users.noreply.github.com> |
| 84 | + Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> |
| 85 | + ``` |
| 86 | + |
| 87 | +- **Documentation.** New or changed public APIs (those in the `Halide::` |
| 88 | + namespace) should be accompanied by updated documentation. |
| 89 | + |
| 90 | +- **Python bindings.** Halide provides a Python binding for its public C++ API. |
| 91 | + If your change adds or modifies an API in the `Halide::` namespace, please |
| 92 | + update the corresponding Python bindings as well. |
| 93 | + |
| 94 | +- **Performance impact.** If your change could affect code generation quality or |
| 95 | + runtime performance, please describe the expected impact in the PR description |
| 96 | + and include benchmark results where practical. |
| 97 | + |
| 98 | +### Review and merging |
| 99 | + |
| 100 | +Every pull request requires approval from at least one project maintainer. Once |
| 101 | +a PR is approved and CI is green, any maintainer may merge it. While we don't |
| 102 | +have a formal code ownership process, it is a good idea to use git-blame to |
| 103 | +determine who the relevant maintainer is. |
| 104 | + |
| 105 | +Normally, we are able to review PRs within a (business) week. If a PR has not |
| 106 | +been reviewed in that time, please add a comment to the PR tagging the relevant |
| 107 | +maintainer. We appreciate reminders, but no more than once per week, please. Do |
| 108 | +not ping maintainers over email or other side channels. |
| 109 | + |
| 110 | +If your PR has stalled in review, it may be helpful to break it up into smaller |
| 111 | +PRs that are easier to review. A good rule of thumb is that PRs larger than 500 |
| 112 | +lines take significantly longer to review. |
| 113 | + |
| 114 | +## Common PR anti-patterns |
| 115 | + |
| 116 | +In the past, we have seen PRs fail to be merged for a number of (often |
| 117 | +frustrating) reasons. We list a few here to help you avoid them. |
| 118 | + |
| 119 | +1. **Working on something large before broader consensus is reached.** If you're |
| 120 | + working on something that you expect to take multiple days of work or |
| 121 | + hundreds of lines of code to complete, please start a Discussion to make sure |
| 122 | + the design is sound and that the maintainers understand your problem and |
| 123 | + agree with your proposed solution. It's frustrating to do a lot of work just |
| 124 | + to hear the maintainers think the problem doesn't need to be solved in Halide |
| 125 | + (e.g. should be done at the application level or in LLVM). These are |
| 126 | + sometimes known as "XY problems." |
| 127 | +2. **Communication deadlock between author and reviewer.** We sometimes see PRs |
| 128 | + stall because the author and the reviewer believe they are waiting on the |
| 129 | + other person to do something. This is why we encourage you to ping PRs when |
| 130 | + you're waiting for a response. |
| 131 | +3. **Bundling unrelated changes, especially bug-fixes, into a single PR.** When |
| 132 | + CI is red due to a pre-existing bug, it is tempting to roll the fix into your |
| 133 | + PR. However, this makes the PR larger and makes it take longer to review. |
| 134 | + This can snowball. |
| 135 | + |
| 136 | +## Building Halide |
| 137 | + |
| 138 | +See the [README](README.md#building-halide) for build instructions. |
0 commit comments