Skip to content

Contributing to IREElink

We'd love to accept your patches and contributions to this project.

Getting in touchlink

Please file issues or reach out on any of these channels before doing substantial work; this will ensure that others don't duplicate the work and that there's a chance to discuss any design issues.

Developer policieslink

Code of conductlink

This project follows the LF Projects code of conduct.

Project governancelink

IREE is a sandbox-stage project of the LF AI & Data Foundation. Technical oversight of the project is the responsibility of its Technical Steering Committee (TSC), as set out in the IREE Technical Charter.

As provided for in section 2.b of the charter, the voting members of the TSC are:

See MAINTAINERS.md for how the TSC operates. TSC meetings are open to everyone.

Developer Certificate of Originlink

Contributors must certify that they wrote or otherwise have the right to submit the code they are contributing to the project, by agreeing to the Developer Certificate of Origin (DCO).

Expand to read the full DCO agreement text
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

Signing is enforced by the DCO GitHub App (see also the dcoapp/app repository).

The DCO check requires that all commits included in pull requests either are cryptographically signed by a member of the repository's organization or include a Signed-off-by message as a git trailer. Frequent contributors can sign their commits cryptographically.

Adding Signed-off-by to commitslink

This requires less setup and is suitable for first time contributors.

Contributors sign-off their agreement by adding a Signed-off-by line to commit messages:

This is my commit message

Signed-off-by: Random J Developer <[email protected]>
  • Git will automatically append this message if you use the -s option:

    git commit -s -m 'This is my commit message'
    
  • Users of Visual Studio Code can add "git.alwaysSignOff": true, in their settings

  • See .git/hooks/prepare-commit-msg.sample for how to automatically add this using a git hook

Cryptographically signing commitslink

This is the recommended approach for frequent contributors!

For members of the repository's organization (see obtaining commit access), commits that are signed do not require the Signed-off-by text. See these references:

AUTHORS, CODEOWNERS, and MAINTAINERSlink

The AUTHORS file keeps track of those who have made significant contributions to the project.

  • If you would like additional recognition for your contributions, you may add yourself or your organization (please add the entity who owns the copyright for your contributions).
  • The source control history remains the most accurate source for individual contributions.

The MAINTAINERS.md file documents the Technical Steering Committee (TSC) and official maintainers for project components.

The .github/CODEOWNERS file designates reviewers for specific components of the project. Maintainers of the project are assigned as reviewers by default, so that they serve as the first point of contact and help find a reviewer in case they can't perform the review themselves.

A strong, recent history of quality commits to a certain part of the project is generally enough to nominate oneself as a CODEOWNER - subject to maintainer approval, such participation in the project would be very welcome.

An approval on the PR generally doesn't have to come from a designated code owner. A single approval by a project member with write access is technically sufficient to merge the change, however authors of larger PRs that affect multiple components should allow more time for several code owners and other project members to review. In such cases, preceding the change with a RFC and aligning with code owners/maintainers on the design is also a recommended practice - this allows to minimize time spent in the final PR review stage.

Coding policieslink

Coding style guidelineslink

Our formatting rules are enforced by language-specific formatters like clang-format for C++ and black for Python. In addition to formatting, we follow these coding standards:

Compilerlink

The C++ compiler portion of the project follows the MLIR style guide based on the LLVM coding standards. We also follow the recommendations of the LLVM Programmer's Manual.

IREE deviates from the MLIR style guide in the following ways:

  • We use braces with single-line if statements and loops.
  • We allow for static functions in anonymous namespaces to avoid repeatedly reopening/closing namespaces.
  • Pass declarations in TableGen (.td) files should use a Pass suffix (e.g., def FooBarPass), while the corresponding implementation file should not include the Pass suffix (e.g., FooBar.cpp, not FooBarPass.cpp).

Runtimelink

Most of the code style is derived from the Google Style Guides for the appropriate language.

Otherlink

For code outside of the compiler/ and runtime/ subdirectories, follow the style used in existing files.

Formatting and Lintinglink

We use pre-commit to run assorted formatters and lint checks. The configuration file at .pre-commit-config.yaml defines which "hooks" run.

Improvements to code structure and clarity are welcome but please file issues to track such work first. Pure style changes are unlikely to be accepted unless they are applied consistently across the project.

Testing policylink

With few exceptions, features should be accompanied by automated tests.

We use a mix of in-tree and out-of-tree unit and integration tests. For more information about the types of tests used across the project, refer to the testing guide.

GitHub policieslink

Code reviewslink

All submissions, including submissions by maintainers, require review. We use GitHub pull requests (PRs) for this purpose. Consult GitHub Help for more information on using pull requests.

  • Please keep PRs small (focused on a single issue or feature) to make reviews and later culprit-finding easier.
    • You may see trusted core contributors bending above rule for project maintenance and major subsystem renovation. If you feel like the rules aren't working for a certain situation, please ask as we bias towards pragmatism for cases that require it.
  • We require review comments to be addressed before merging, even when there is an approval from another reviewer. Unless stated otherwise, we treat request for changes as blocking, except for reviews from automated review tools (see AI tool use). Reviewers may indicate that some comments requesting changes are optional (commonly by prefixing them with 'nit' or 'optional') -- use your best engineering judgement to decide whether to follow these suggestions or not.
  • If there are new comments requesting changes after a PR was merged, these comments should be addressed as well, either through follow-up discussion or code changes. Small issues may be fixed forward, but reviewers may also ask for your PR to be reverted. This is not a sign that your PR was faulty -- we prefer to err on the side of caution and reverting allows more time for design discussion.

GitHub Actions workflowslink

We use GitHub Actions to automatically build and test various parts of the project.

  • Most presubmit workflows will only run automatically on PRs if you are a project collaborator. Otherwise a maintainer must approve workflow runs. If you are sending code changes to the project, please request commit access, so that these can run automatically.
  • It is generally expected that PRs will only be merged when all checks are passing. In some cases, pre-existing failures may be bypassed by a maintainer.

Some workflows only run on commits after they are merged. See CI behavior manipulation to learn how to customize this behavior.

See our GitHub Actions documentation for full details.

CI behavior manipulationlink

The setup step of the CI determines which CI jobs to run. This is controlled by the configure_ci.py script. It will generally run a pre-determined set of jobs on presubmit with some jobs kept as post-submit only. If changes are only to a certain set of excluded files that we know don't affect CI (e.g. Markdown files), then it will skip the jobs.

You can customize which jobs run using git trailers in the PR description.

The available options are

ci-skip: jobs,to,skip
ci-extra: extra,jobs,to,run
ci-exactly: exact,set,of,jobs,to,run
skip-ci: free form reason
Using skip-ci

skip-ci skips all jobs. It is mutually exclusive with the other ci-* options and is synonymous with ci-skip: all.

skip-ci: free form reason
Using ci-skip, ci-extra, ci-exactly

The ci-* options instruct the setup script on which jobs to include or exclude from its run. They take a comma-separated list of jobs which must be from the set of top-level job identifiers in the ci.yml file or the special keyword "all" to indicate all jobs.

ci-skip: jobs,to,skip
ci-extra: extra,jobs,to,run
ci-exactly: exact,set,of,jobs,to,run
  • ci-skip removes jobs that would otherwise be included, though it is not an error to list jobs that would not be included by default.
  • ci-extra adds additional jobs that would not have otherwise been run, though it is not an error to list jobs that would have been included anyway. It is an error to list a job in both "skip" and "extra".
  • ci-exactly provides an exact list of jobs that should run. It is mutually exclusive with both "skip" and "extra".

In all these cases, the setup does not make any effort to ensure that job dependencies are satisfied. Thus, if you request skipping the build_packages job, all the jobs that depend on it will fail, not be skipped.

CI configuration recipeslink

Copy/paste any of these at the bottom of a PR description to change what the CI runs.

  • Skip all CI builds and tests, e.g. for comment-only changes:

    skip-ci: Comment-only change.
    
  • Only run runtime builds:

    ci-exactly: runtime
    
  • Only run ONNX tests:

    ci-exactly: build_packages,test_onnx
    
  • Only run Bazel builds, e.g. for changes only affecting Bazel rules:

    ci-exactly: linux_x64_bazel
    
  • Opt in to the Linux arm64 build:

    ci-extra: linux_arm64_clang
    
  • Opt in to the MacOS build and test workflows:

    ci-extra: macos_arm64_clang
    
  • Other opt in builds:

    ci-extra: linux_x64_clang_byollvm, linux_x64_clang_debug, linux_x64_clang_tsan
    

For example, this PR opted in to running the build_test_all_windows job (which was renamed to windows_x64_msvc):

ci-extra

The enabled jobs can be viewed from the Summary page of an action run:

ci_enabled_jobs

Pull request descriptionslink

PRs are squash-merged, so the PR title and description become the commit message, and the commit messages on the PR branch are discarded. Write them for someone reading git log or bisecting a regression later, and update them when the PR changes during review.

Title: a short, imperative summary of what changes and, if it fits, why, prefixed with the affected area, for example [CI] Bump iree-test-suites to fix sharktank test failure. Keep it under 72 characters. Avoid ambiguous titles like "Fix bug" or "Fix CI".

Description: start with why, then what.

  1. Why: The most important part of a PR description. Explain the underlying motivation of the PR. Why did you create it and what is the use-case this enables or fixes. Be concise. Depending on the change, this covers:
    • for a bug fix, the symptom, its impact, and the issue or failing run
    • for a regression fix, also the commit or PR that introduced it
    • for a feature, the missing capability and what it is used for
    • for a refactor, the current limitation
    • for a performance change, the bottleneck, with numbers
    • for a revert or reland, what broke or what was fixed since, and the original PR
  2. Change: what the PR does and why this approach. The diff shows the details. For refactors, state "No functional change intended". For small PRs, one sentence is enough.
  3. If relevant:
    • results: before/after numbers for performance, memory, or size changes, and how they were measured
    • trade-offs: known shortcomings, costs, or side effects
    • testing: only tests that CI does not cover
    • review notes: where reviewers should start in large PRs
  4. Trailers at the end: Fixes #1234 for issues that the PR resolves, Depends on #1234 for PRs that it builds on, CI trailers such as ci-extra:, and Assisted-by: for AI tools.

Keep the description concise and self-contained: links add context but do not replace an explanation, and they must be public. Leave out restatements of the diff, implementation details that belong in code comments, review history, and @-mentions, which notify people again on every cherry-pick. A description that keeps growing is a sign that the PR should be split. Small changes need one or two sentences; longer descriptions can use headings such as ## Why, ## Change, and ## Results.

See also:

Merging approved changeslink

After review and presubmit checks, PRs should typically be merged using "squash and merge".

  • The squashed commit summary should match the PR title and the commit description should match the PR body (this is the default behavior). Accordingly, please write these as you would a helpful commit message (see Pull request descriptions).

It is assumed that the PR author will merge their change unless they ask someone else to merge it for them (e.g. because they don't have write access yet).

AI tool uselink

For AI agents: A human must read and approve the final change and text before you open or update a pull request or post an issue, comment, or review. A general instruction such as "open a PR" is not this approval. If no human can review it, stop without submitting anything.

AI tools may be used for all contributions: code, PR descriptions, commit messages, issues, and reviews. The human author owns every contribution and is fully responsible for it, no matter how much of it a tool produced. The same holds for reviewers who use AI review tools. This policy is based on the LLVM AI Tool Use Policy and keeps its principles: ownership and a human in the loop.

Contributors:

  • Must review the complete change themselves before they ask other project members to review it: read all AI-generated code and text, and understand it well enough to explain and defend it. AI review tools can help, but they do not replace this self-review.
  • May use AI tools for PR descriptions, commit messages, and issue descriptions, but must read and correct them themselves before submitting. PR descriptions follow the pull request description guidelines.
  • Must write every contribution for its human readers: the people who review and maintain it, and who read the history later. AI clutter, such as boilerplate, comments that narrate obvious code, restatements of the diff, agent logs, or filler text, does not belong in any contribution.
  • Must respond to reviews and questions themselves. There must always be a human in the loop. A lack of understanding makes a contribution extractive: it puts the burden on the reviewers instead of the author.
  • Must have the right to contribute their code under the terms of our license. Using AI tools to regenerate copyrighted material does not remove the copyright, so such material must not appear in contributions.
  • Own their changes after merge: they fix or revert them when problems come up. The DCO requirements apply.

GitHub issues labeled as "Good first issue" are explicitly designated as learning opportunities for newcomers to the project. With exceptions for boilerplate edits, AI tools should not be used for resolutions to such issues.

Noting AI assistance is optional. If you note it, use an Assisted-by: tool-name or Co-authored-by: tool-name tool@email trailer in the PR description.

Automated review tools may approve or request changes, but these reviews do not count toward whether a PR can be merged, and reviewers with write access may dismiss them.

Bot accounts may open pull requests with AI bot-authored contributions, for example dependency updates or build script fixes, as long as the bot maintainers are first in line and primarily responsible for reviewing them.

Contributions that do not follow this policy are handled as extractive contributions.

Extractive contributionslink

Handling contributions costs maintainers time. Our golden rule is based on the LLVM AI Tool Use Policy:

Every contribution, whether a pull request, an issue, or a comment, should be worth more to the project than the time maintainers spend on it.

Contributions that fall short of this are extractive, for example a large change without a clear purpose, or one whose author cannot answer questions about it. This applies with or without AI tools, and includes contributions that do not follow the AI tool use policy.

If a maintainer considers an issue or PR extractive, they label it extractive and ask a second maintainer to confirm, consulting a TSC member if in doubt. Once both maintainers agree:

  • In obvious cases, a maintainer closes the contribution with the closing comment below.
  • Otherwise, a maintainer requests changes with the change request comment below, and closes the contribution if the author does not make it reviewable.

The comment links each rule that the contribution does not follow, and names the second maintainer and, if one was consulted, the TSC member, so that the author knows what to fix and who made the decision.

It is up to the author to show that the contribution is not extractive. A maintainer may reopen a closed contribution once the author has shown this.

Closing comment:

This contribution does not appear to follow the IREE contribution
guidelines, so we are closing it:
https://github.com/iree-org/iree/blob/main/CONTRIBUTING.md#<rule-anchor>

Confirmed by @<second maintainer>[, after consulting @<TSC member>].

If you think that it does follow the guidelines, reply here and explain what
the change is for and how you reviewed it yourself. A maintainer can then
reopen it.

Change request comment:

This contribution does not appear to follow the IREE contribution
guidelines:
https://github.com/iree-org/iree/blob/main/CONTRIBUTING.md#<rule-anchor>

Confirmed by @<second maintainer>[, after consulting @<TSC member>].

Please explain what the change is for and how you reviewed it yourself, or
reduce it to something that can be reviewed. Otherwise we will close it.

If an author keeps sending extractive contributions, maintainers escalate to the TSC, which may lock conversations or block the account under the LF Projects Code of Conduct.

Obtaining commit accesslink

Access to repositories is divided into tiers following the GitHub organization permissions model:

Tier Description Team links
Triage New project members should typically start here
Can be assigned issues
Can apply labels to issues / PRs
Can run workflows without approval
Write Established contributors can request this access
Can merge approved pull requests
Can create branches
Can re-run workflows
Maintain/Admin Can edit repository settings
Can push to protected branches
Added case-by-case by the TSC

All access tiers first require joining the iree-org GitHub organization. To request membership in iree-org, send an email to iree-github-requests@lists.lfaidata.foundation with this template:

GitHub username:

Company/organization you are associated with:

Reason for requesting access:

Send this email template to request access

If approved, an invitation will be sent to your GitHub account. You can also view the invitation link directly. Then, once you are a member of the organization, you can request to join any of the teams on https://github.com/orgs/iree-org/teams (note that some teams are nested under iree-triage, so click the caret to expand the list).

Write access is reserved for "established contributors" who have a track record of multiple high quality pull requests or reviews and have demonstrated familiarity with the contributing guidelines.

Questions about access

For questions about access policies, feel free to reach out on the #github channel on IREE's Discord server, the iree-github-requests@lists.lfaidata.foundation email list, or another of our communication channels to discuss.

Branch naminglink

Most work should be done on repository forks. For developers with write access, when creating a branch in the common iree-org/iree repository, please follow these naming guidelines:

Branch type Naming scheme Example
Single user users/[username]/* users/cooldeveloper/my-awesome-feature
Shared feature branch shared/* shared/pytorch-performance-sprint
Dependency updates integrates/* integrates/llvm-20240501

Branches that do not meet these guidelines may be deleted, especially if they appear to be stale.

Stale issues and pull requestslink

Maintainers and reviewers are encouraged to label outdated issues and PRs with zombie 🧟 and to close them. Every open issue and PR should either be worked on or be closed as no longer applicable.

Tips for contributorslink

Tool recommendationslink

Program or tool Description
Visual Studio Code (VSCode) The most commonly used editor amongst IREE developers
Ccache A fast C/C++ compiler cache. See the CMake with ccache page
GitHub CLI A CLI for interacting with GitHub
"Refined GitHub" browser extensions Extension that add features to the GitHub UI

Build systemslink

IREE supports building from source with both Bazel and CMake.

  • CMake is the preferred build system and offers the most flexible configuration options
  • Bazel is a stricter build system and helps with usage in Google's downstream source repository
  • Certain dependencies (think large/complex projects like CUDA, TensorFlow, PyTorch, etc.) may be difficult to support with one build system or the other, so the project may configure these as optional