Skip to content

Commit 8983e90

Browse files
byjlwmalfet
authored andcommitted
added contributing (pytorch#711)
1 parent 36e66d8 commit 8983e90

File tree

2 files changed

+152
-17
lines changed

2 files changed

+152
-17
lines changed

README.md

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ python3 torchchat.py --help
6666
### Download Weights
6767
Most models use HuggingFace as the distribution channel, so you will need to create a HuggingFace account.
6868

69-
[prefix default]: HF_TOKEN="${SECRET_HF_TOKEN_PERIODIC}"
69+
[prefix default]: HF_TOKEN="${SECRET_HF_TOKEN_PERIODIC}"
7070
Create a HuggingFace user access token [as documented here](https://huggingface.co/docs/hub/en/security-tokens).
7171
Log into huggingface:
7272
```
@@ -216,7 +216,7 @@ For more details on quantization and what settings to use for your use
216216
case visit our [Quanitization documentation](docs/quantization.md) or
217217
run `python3 torchchat.py export`
218218

219-
[end default]:
219+
[end default]:
220220

221221
### Deploy and run on iOS
222222

@@ -315,17 +315,50 @@ files.
315315
While we describe how to use torchchat using the popular llama3 model,
316316
you can perform the example commands with any of these models.
317317

318+
319+
## Design Principles
320+
321+
torchtune embodies PyTorch’s design philosophy [[details](https://pytorch.org/docs/stable/community/design.html)], especially "usability over everything else".
322+
323+
### Native PyTorch
324+
325+
torchchat is a native-PyTorch library. While we provide integrations with the surrounding ecosystem (eg: Hugging Face models, etc), all of the core functionality is written in PyTorch.
326+
327+
### Simplicity and Extensibility
328+
329+
torchchat is designed to be easy to understand, use and extend.
330+
331+
- Composition over implementation inheritance - layers of inheritance for code re-use makes the code hard to read and extend
332+
- No training frameworks - explicitly outlining the training logic makes it easy to extend for custom use cases
333+
- Code duplication is preferred over unnecessary abstractions
334+
- Modular building blocks over monolithic components
335+
336+
### Correctness
337+
338+
torchchat provides well-tested components with a high-bar on correctness.
339+
We provide
340+
341+
- Extensive unit-tests to ensure things operate as they should
342+
343+
## Community Contributions
344+
345+
We really value our community and the contributions made by our wonderful users. We'll use this section to call out some of these contributions! If you'd like to help out as well, please see the [CONTRIBUTING](docs/CONTRIBUTING.md) guide.
346+
318347
## Troubleshooting
319348

320349

321350
**CERTIFICATE_VERIFY_FAILED**
322351
Run `pip install --upgrade certifi`.
323352

324353

325-
**Access to model is restricted and you are not in the authorized
326-
list** Some models require an additional step to access. Follow the
354+
**Access to model is restricted and you are not in the authorized list**
355+
Some models require an additional step to access. Follow the
327356
link provided in the error to get access.
328357

358+
**Installing ET Fails**
359+
If `./scripts/install_et.sh` fails with an error like `Building wheel for executorch (pyproject.toml) did not run successfully` It's possible that it's linking to an older version of pytorch installed some other way like via homebrew. You can break the link by uninstalling other versions such as `brew uninstall pytorch` Note: You may break something that depends on this, so be aware.
360+
361+
329362
### Disclaimer
330363
The torchchat Repository Content is provided without any guarantees
331364
about performance or compatibility. In particular, torchchat makes
@@ -344,18 +377,18 @@ solely responsible for complying with all such obligations.
344377

345378

346379
### Disclaimer
347-
The torchchat Repository Content is provided without any guarantees about
348-
performance or compatibility. In particular, torchchat makes available
349-
model architectures written in Python for PyTorch that may not perform
350-
in the same manner or meet the same standards as the original versions
351-
of those models. When using the torchchat Repository Content, including
352-
any model architectures, you are solely responsible for determining the
353-
appropriateness of using or redistributing the torchchat Repository Content
354-
and assume any risks associated with your use of the torchchat Repository Content
355-
or any models, outputs, or results, both alone and in combination with
356-
any other technologies. Additionally, you may have other legal obligations
357-
that govern your use of other content, such as the terms of service for
358-
third-party models, weights, data, or other technologies, and you are
380+
The torchchat Repository Content is provided without any guarantees about
381+
performance or compatibility. In particular, torchchat makes available
382+
model architectures written in Python for PyTorch that may not perform
383+
in the same manner or meet the same standards as the original versions
384+
of those models. When using the torchchat Repository Content, including
385+
any model architectures, you are solely responsible for determining the
386+
appropriateness of using or redistributing the torchchat Repository Content
387+
and assume any risks associated with your use of the torchchat Repository Content
388+
or any models, outputs, or results, both alone and in combination with
389+
any other technologies. Additionally, you may have other legal obligations
390+
that govern your use of other content, such as the terms of service for
391+
third-party models, weights, data, or other technologies, and you are
359392
solely responsible for complying with all such obligations.
360393

361394

@@ -401,4 +434,3 @@ code in this distribution is covered by the MIT and Apache Open Source
401434
licenses.) However you may have other legal obligations that govern
402435
your use of content, such as the terms of service for third-party
403436
models.
404-

docs/CONTRIBUTING.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Contributing to torchchat
2+
We want to make contributing to this project as easy and transparent as possible.
3+
4+
 
5+
6+
## Dev install
7+
You should first [fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) the torchchat repository
8+
and then clone your forked repository.
9+
10+
```git clone https://github.com/<YOUR_GITHUB_USER>/torchchat.git```
11+
12+
Then navigate into the newly cloned repo and install dependencies needed for development.
13+
The following steps require that you have [Python 3.10](https://www.python.org/downloads/release/python-3100/) installed.
14+
15+
[skip default]: begin
16+
```bash
17+
# get the code
18+
git clone https://github.com/pytorch/torchchat.git
19+
cd torchchat
20+
21+
# set up a virtual environment
22+
python3 -m venv .venv
23+
source .venv/bin/activate
24+
```
25+
[skip default]: end
26+
```
27+
# install dependencies
28+
./install_requirements.sh
29+
```
30+
31+
Installations can be tested by
32+
33+
```bash
34+
# ensure everything installed correctly
35+
python3 torchchat.py --help
36+
```
37+
38+
&nbsp;
39+
40+
## Contributing workflow
41+
We actively welcome your pull requests.
42+
43+
1. Create your new branch from `main` in your forked repo, with a name describing the work you're completing e.g. `add-feature-x`.
44+
2. If you've added code that should be tested, add tests. Ensure all tests pass. See the [testing section](#testing) for more information.
45+
3. If you've changed APIs, [update the documentation](#updating-documentation).
46+
4. Make sure your [code lints](#coding-style).
47+
5. If you haven't already, complete the [Contributor License Agreement ("CLA")](#contributor-license-agreement-cla)
48+
49+
&nbsp;
50+
51+
## Testing
52+
TODO: Fill out the details
53+
54+
- **Unit tests**
55+
TODO: Fillout the details
56+
57+
&nbsp;
58+
59+
## Updating documentation
60+
Each API and class should be clearly documented. Well-documented code is easier to review and understand/extend. All documentation is contained in the [docs directory](docs/):
61+
62+
63+
Documentation is written in [RST](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html) format.
64+
65+
66+
&nbsp;
67+
68+
## Coding Style
69+
TODO: Define this
70+
71+
&nbsp;
72+
73+
## Best Practices
74+
75+
This section captures some best practices for contributing code to torchchat. Following these will make PR reviews easier.
76+
77+
- **Modular Blocks instead of Monolithic Classes**. Stuffing all of the logic into a single class limits readability and makes it hard to reuse logic. Think about breaking the implementation into self-contained blocks which can be used independently from a given model. For example, attention mechanisms, embedding classes, transformer layers etc.
78+
- **Say no to Implementation Inheritance**. You really don’t need it AND it makes the code much harder to understand or refactor since the logic is spread across many files/classes. Where needed, consider using Protocols.
79+
- **Clean Interfaces**. There’s nothing more challenging than reading through functions/constructors with ~100 parameters. Think carefully about what needs to be exposed to the user and don’t hesitate to hard-code parameters until there is a need to make them configurable.
80+
- **Intrusive Configs**. Config objects should not intrude into the class implementation. Configs should interact with these classes through cleanly defined builder functions which convert the config into flat parameters needed to instantiate an object.
81+
- **Limit Generalization**. Attempting to generalize code before this is needed unnecessarily complicates implementations - you are anticipating use cases you don’t know a lot about. When you actually need to generalize a component, think about whether it’s worth it to complicate a given interface to stuff in more functionality. Don’t be afraid of code duplication if it makes things easier to read.
82+
- **Value Checks and Asserts**. Don’t check values in higher level modules - defer the checks to the modules where the values are actually used. This helps reduce the number of raise statements in code which generally hurts readability, but are critical for correctness.
83+
84+
&nbsp;
85+
86+
## Issues
87+
We use GitHub issues to track public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue.
88+
89+
Meta has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue.
90+
91+
&nbsp;
92+
93+
## License
94+
By contributing to torchchat, you agree that your contributions will be licensed under the LICENSE file in the root directory of this source tree.
95+
96+
&nbsp;
97+
98+
## Contributor License Agreement ("CLA")
99+
In order to accept your pull request, we need you to submit a CLA. You only need to do this once to work on any of Meta's open source projects.
100+
101+
Complete your CLA here: <https://code.facebook.com/cla>
102+
103+
&nbsp;

0 commit comments

Comments
 (0)