Skip to content

Commit bb91d47

Browse files
jdsgomesdatumbox
authored andcommitted
[fbsync] Model contrib guidelines (#5315)
Summary: * Adding multiweight support for shufflenetv2 prototype models * Revert "Adding multiweight support for shufflenetv2 prototype models" This reverts commit 31fadbe. * Adding multiweight support for shufflenetv2 prototype models * Revert "Adding multiweight support for shufflenetv2 prototype models" This reverts commit 4e3d900. * Remove module vs method name clash * add model contribution guidelines * update CONTRIBUTING_MODELS.md * Fix formatting and typo * fix in-document links * Update CONTRIBUTING.md * remove Implementation Details section Reviewed By: NicolasHug Differential Revision: D34140246 fbshipit-source-id: 0c96404ac238bb039b0e2d057c7db961a6ab0512 Co-authored-by: Vasilis Vryniotis <[email protected]> Co-authored-by: Vasilis Vryniotis <[email protected]>
1 parent 13bd922 commit bb91d47

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,9 @@ You can also choose to only build a subset of the examples by using the
186186
example ``EXAMPLES_PATTERN="transforms" make html`` will only build the examples
187187
with "transforms" in their name.
188188

189-
### New model
189+
### New architecture or improved model weights
190190

191-
More details on how to add a new model will be provided later. Please, do not send any PR with a new model without discussing
192-
it in an issue as, most likely, it will not be accepted.
191+
Please refer to the guidelines in [Contributing to Torchvision - Models](https://github.com/pytorch/vision/blob/main/CONTRIBUTING_MODELS.md).
193192

194193
### New dataset
195194

CONTRIBUTING_MODELS.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Contributing to Torchvision - Models
2+
3+
- [New Model Architectures - Overview](#new-model-architectures---overview)
4+
5+
- [New Weights for Existing Model Architectures](#new-weights-for-existing-model-architectures)
6+
7+
## New Model Architectures - Overview
8+
9+
For someone who would be interested in adding a model architecture, it is also expected to train the model, so here are a few important considerations:
10+
11+
- Training big models requires lots of resources and the cost quickly adds up
12+
13+
- Reproducing models is fun but also risky as you might not always get the results reported on the paper. It might require a huge amount of effort to close the gap
14+
15+
- The contribution might not get merged if we significantly lack in terms of accuracy, speed etc
16+
17+
- Including new models in TorchVision might not be the best approach, so other options such as releasing the model through to [Pytorch Hub](https://pytorch.org/hub/) should be considered
18+
19+
So, before starting any work and submitting a PR there are a few critical things that need to be taken into account in order to make sure the planned contribution is within the context of TorchVision, and the requirements and expectations are discussed beforehand. If this step is skipped and a PR is submitted without prior discussion it will almost certainly be rejected.
20+
21+
### 1. Preparation work
22+
23+
- Start by looking into this [issue](https://github.com/pytorch/vision/issues/2707) in order to have an idea of the models that are being considered, express your willingness to add a new model and discuss with the community whether or not this model should be included in TorchVision. It is very important at this stage to make sure that there is an agreement on the value of having this model in TorchVision and there is no one else already working on it.
24+
25+
- If the decision is to include the new model, then please create a new ticket which will be used for all design and implementation discussions prior to the PR. One of the TorchVision maintainers will reach out at this stage and this will be your POC from this point onwards in order to provide support, guidance and regular feedback.
26+
27+
### 2. Implement the model
28+
29+
Please take a look at existing models in TorchVision to get familiar with the idioms. Also please look at recent contributions for new models. If in doubt about any design decisions you can ask for feedback on the issue created in step 1. Example of things to take into account:
30+
31+
- The implementation should be as close as possible to the canonical implementation/paper
32+
- The PR must include the code implementation, documentation and tests
33+
- It should also extend the existing reference scripts used to train the model
34+
- The weights need to reproduce closely the results of the paper in terms of accuracy, even though the final weights to be deployed will be those trained by the TorchVision maintainers
35+
- The PR description should include commands/configuration used to train the model, so that the TorchVision maintainers can easily run them to verify the implementation and generate the final model to be released
36+
- Make sure we re-use existing components as much as possible (inheritance)
37+
- New primitives (transforms, losses, etc) can be added if necessary, but the final location will be determined after discussion with the dedicated maintainer
38+
- Please take a look at the detailed [implementation and documentation guidelines](https://github.com/pytorch/vision/issues/5319) for a fine grain list of things not to be missed
39+
40+
### 3. Train the model with reference scripts
41+
42+
To validate the new model against the common benchmark, as well as to generate pre-trained weights, you must use TorchVision’s reference scripts to train the model.
43+
44+
Make sure all logs and a final (or best) checkpoint are saved, because it is expected that a submission shows that a model has been successfully trained and the results are in line with the original paper/repository. This will allow the reviewers to quickly check the validity of the submission, but please note that the final model to be released will be re-trained by the maintainers in order to verify reproducibility, ensure that the changes occurred during the PR review did not introduce any bugs, and to avoid moving around a large amount of data (including all checkpoints and logs).
45+
46+
### 4. Submit a PR
47+
48+
Submit a PR and tag the assigned maintainer. This PR should:
49+
50+
- Link the original ticket
51+
- Provide a link for the original paper and the original repository if available
52+
- Highlight the important test metrics and how they compare to the original paper
53+
- Highlight any design choices that deviate from the original paper/implementation and rationale for these choices
54+
55+
## New Weights for Existing Model Architectures
56+
57+
The process of improving existing models, for instance improving accuracy by retraining the model with a different set of hyperparameters or augmentations, is the following:
58+
59+
1. Open a ticket and discuss with the community and maintainers whether this improvement should be added to TorchVision. Note that to add new weights the improvement should be significant.
60+
61+
2. Train the model using TorchVision reference scripts. You can add new primitives (transforms, losses, etc) when necessary, but the final location will be determined after discussion with the dedicated maintainer.
62+
63+
3. Open a PR with the new weights, together with the training logs and the checkpoint chosen so the reviewers can verify the submission. Details on how the model was trained, i.e., the training command using the reference scripts, should be included in the PR.
64+
65+
4. The PR reviewers should replicate the results on their side to verify the submission and if all goes well the new weights should be ready to be released!

0 commit comments

Comments
 (0)