|
1 | 1 | ## Contributing to PROJECT |
2 | 2 |
|
3 | 3 | Hi there! |
4 | | -We’re thrilled that you’d like to contribute to this project. |
| 4 | +We're thrilled that you'd like to contribute to this project. |
5 | 5 | Your help is essential for keeping this project great and for making it better. |
6 | 6 |
|
7 | | -## Branching Strategy |
8 | 7 |
|
9 | | -In general, contributors should develop on branches based off of `main` and pull requests should be made against `main`. |
| 8 | +## Submitting Your Contribution |
10 | 9 |
|
11 | | -## Submitting a pull request |
| 10 | +Follow these steps to submit your example to the QEfficient repository: |
12 | 11 |
|
13 | 12 | 1. Please read our [code of conduct](CODE-OF-CONDUCT.md) and [license](LICENSE). |
14 | | -1. Fork and clone the repository. |
15 | | -1. Create a new branch based on `main`: `git checkout -b <my-branch-name> main`. |
16 | | -1. Make your changes, add tests, and make sure the tests still pass. |
17 | | -1. Commit your changes using the [DCO](http://developercertificate.org/). You can attest to the DCO by commiting with the **-s** or **--signoff** options or manually adding the "Signed-off-by". |
18 | | -1. Push to your fork and submit a pull request from your branch to `main`. |
19 | | -1. Pat yourself on the back and wait for your pull request to be reviewed. |
| 13 | + |
| 14 | +### 1. Fork and Clone the Repository |
| 15 | + |
| 16 | +First, fork the repository to your GitHub account, then clone your fork: |
| 17 | + |
| 18 | +```bash |
| 19 | +# Fork the repository on GitHub (click the "Fork" button) |
| 20 | +# Then clone your fork |
| 21 | +git clone [email protected]:YOUR_USERNAME/efficient-transformers.git |
| 22 | +cd efficient-transformers |
| 23 | + |
| 24 | +# Add upstream remote to keep your fork in sync |
| 25 | +git remote add upstream [email protected]:quic/efficient-transformers.git |
| 26 | +``` |
| 27 | + |
| 28 | +### 2. Create a Feature Branch |
| 29 | + |
| 30 | +Create a descriptive branch for your changes: |
| 31 | + |
| 32 | +```bash |
| 33 | +# Update your main branch |
| 34 | +git checkout main |
| 35 | +git pull upstream main |
| 36 | + |
| 37 | +# Create a new branch |
| 38 | +git checkout -b <branch-name> |
| 39 | +``` |
| 40 | + |
| 41 | +### 3. Make Your Changes |
| 42 | + |
| 43 | +When making changes to the codebase: |
| 44 | + |
| 45 | +- **Follow Existing Design Patterns** |
| 46 | + - Review similar implementations before creating new code |
| 47 | + - Maintain consistency with the project's architecture and coding style |
| 48 | + - Reuse existing utilities and base classes where applicable |
| 49 | + |
| 50 | +- **Onboarding New Models** |
| 51 | + - For adding new model support, refer to the comprehensive guide: `examples/onboarding_guide/causallm/` |
| 52 | + - Follow the step-by-step process with code examples provided |
| 53 | + |
| 54 | +- **Testing is Mandatory** |
| 55 | + - Add tests for all new features in the appropriate `tests/` subdirectory |
| 56 | + - Run tests locally before pushing: `pytest tests/path/to/your/test.py -v` |
| 57 | + - For model additions, verify all 4 pipeline stages (PyTorch HF → KV → ORT → AI 100) and make sure tokens are matching with refernce PyTorch HF |
| 58 | + |
| 59 | +- **Documentation** |
| 60 | + - **For New Features/Flags:** |
| 61 | + - Document usage in `docs/source/<appropriate-page>` with feature description and usage examples |
| 62 | + - Ensure documentation is clear enough for others to understand and use the feature |
| 63 | + - **For New Models:** |
| 64 | + - Test with basic inference scripts in the `examples/` folder |
| 65 | + - If specific changes are needed, create a dedicated example file |
| 66 | + - Update `docs/source/validate.md` with the model's HuggingFace card name and relevant details |
| 67 | + |
| 68 | + |
| 69 | +- **Code Quality Checks** |
| 70 | + - Pre-commit hooks, DCO sign-off, and CI checks are covered in the following steps |
| 71 | + - Ensure you complete steps 4-8 before finalizing your PR |
| 72 | + |
| 73 | +### 4. Run Pre-commit Checks |
| 74 | + |
| 75 | +Before committing, ensure your code passes all quality checks: |
| 76 | + |
| 77 | +```bash |
| 78 | +# Install pre-commit and ruff if not already installed |
| 79 | +pip install pre-commit |
| 80 | +pip install ruff |
| 81 | + |
| 82 | +# Run pre-commit on your changed files |
| 83 | +pre-commit run --files path/to/your/file1.py path/to/your/file2.py |
| 84 | + |
| 85 | +# Run Ruff check |
| 86 | +ruff check |
| 87 | +``` |
| 88 | + |
| 89 | +**Important:** If pre-commit reports any failures: |
| 90 | +- Some issues will be auto-fixed (formatting, trailing whitespace, etc.) |
| 91 | +- For issues that aren't auto-fixed, manually correct them |
| 92 | +- Re-run `pre-commit run --files <files>` or `ruff check` until all checks pass |
| 93 | + |
| 94 | +### 5. Commit with Sign-off (DCO) |
| 95 | + |
| 96 | +All commits must be signed off to comply with the Developer Certificate of Origin (DCO): |
| 97 | + |
| 98 | +```bash |
| 99 | +# Stage your changes |
| 100 | +git add examples/your_domain/your_example.py |
| 101 | +git add examples/your_domain/README.md |
| 102 | + |
| 103 | +# Commit with sign-off |
| 104 | +git commit -s --author "Your Name <[email protected]>" -m "Add [model-name] support |
| 105 | +
|
| 106 | +- Implements inference for [model-name] |
| 107 | +- Includes documentation and usage examples |
| 108 | +- Tested with [specific configurations]" |
| 109 | +``` |
| 110 | + |
| 111 | +**Commit Message Guidelines:** |
| 112 | +- Use a clear, descriptive title |
| 113 | +- Add a blank line, then detailed description if needed |
| 114 | +- Always include the `-s` flag for DCO sign-off |
| 115 | + |
| 116 | +### 6. Push to Your Fork |
| 117 | + |
| 118 | +Push your branch to your forked repository: |
| 119 | + |
| 120 | +```bash |
| 121 | +git push origin <branch-name> |
| 122 | +``` |
| 123 | + |
| 124 | +### 7. Create a Pull Request |
| 125 | + |
| 126 | +1. Go to your fork on GitHub |
| 127 | +2. Click "Compare & pull request" for your branch |
| 128 | +3. Fill out the PR template with: |
| 129 | + - **Title:** Clear, descriptive title (e.g., "Add Llama-3.2-Vision Support" or "Fix memory leak in KV cache") |
| 130 | + - **Description:** |
| 131 | + - What changes were made and why |
| 132 | + - What problem it solves or feature it adds |
| 133 | + - Any special considerations or breaking changes |
| 134 | + - Links to relevant documentation, issues, or model cards (if applicable) |
| 135 | + - **Testing:** Describe how you tested your changes |
| 136 | + |
| 137 | +### 8. Ensure CI Checks Pass |
| 138 | + |
| 139 | +After creating the PR, verify that all automated checks pass: |
| 140 | + |
| 141 | +- ✅ **DCO Check:** Ensures all commits are signed off |
| 142 | +- ✅ **Lint Check:** Code style and formatting validation |
| 143 | +- ✅ **Tests:** Automated test suite (if applicable) |
| 144 | + |
| 145 | +If any checks fail: |
| 146 | +1. Review the error messages in the PR |
| 147 | +2. Make necessary fixes in your local branch |
| 148 | +3. Commit and push the fixes (with sign-off) |
| 149 | +4. The PR will automatically update and re-run checks |
| 150 | + |
| 151 | +### 9. Address Review Feedback |
| 152 | + |
| 153 | +Maintainers will review your PR and may request changes: |
| 154 | +- Make requested changes in your local branch |
| 155 | +- Commit with sign-off and push to update the PR |
| 156 | +- Respond to comments to facilitate discussion |
| 157 | + |
20 | 158 |
|
21 | 159 | Here are a few things you can do that will increase the likelihood of your pull request to be accepted: |
22 | 160 |
|
|
0 commit comments