1*da0073e9SAndroid Build Coastguard Worker# Summary 2*da0073e9SAndroid Build Coastguard WorkerThese are a collection of scripts for access lists of commits between releases. There are other scripts for automatically generating labels for commits. 3*da0073e9SAndroid Build Coastguard Worker 4*da0073e9SAndroid Build Coastguard WorkerThe release_notes Runbook and other supporting docs can be found here: [Release Notes Supporting Docs](https://drive.google.com/drive/folders/1J0Uwz8oE7TrdcP95zc-id1gdSBPnMKOR?usp=sharing) 5*da0073e9SAndroid Build Coastguard Worker 6*da0073e9SAndroid Build Coastguard WorkerAn example of generated docs for submodule owners: [2.0 release notes submodule docs](https://drive.google.com/drive/folders/1zQtmF_ak7BkpGEM58YgJfnpNXTnFl25q?usp=share_link) 7*da0073e9SAndroid Build Coastguard Worker 8*da0073e9SAndroid Build Coastguard Worker### Authentication: 9*da0073e9SAndroid Build Coastguard WorkerFirst run the `test_release_notes.py` script to make sure you have the correct authentication set up. This script will try to access the GitHub API and will fail if you are not authenticated. 10*da0073e9SAndroid Build Coastguard Worker 11*da0073e9SAndroid Build Coastguard Worker- If you have enabled ghstack then authentication should be set up correctly. 12*da0073e9SAndroid Build Coastguard Worker- Otherwise go to `https://github.com/settings/tokens` and create a token. You can either follow the steps to setup ghstack or set the env variable `GITHUB_TOKEN`. 13*da0073e9SAndroid Build Coastguard Worker 14*da0073e9SAndroid Build Coastguard Worker 15*da0073e9SAndroid Build Coastguard Worker## Steps: 16*da0073e9SAndroid Build Coastguard Worker 17*da0073e9SAndroid Build Coastguard Worker### Part 1: getting a list of commits 18*da0073e9SAndroid Build Coastguard Worker 19*da0073e9SAndroid Build Coastguard WorkerYou are going to get a list of commits since the last release in csv format. The usage is the following: 20*da0073e9SAndroid Build Coastguard WorkerAssuming tags/v1.13.1 is last released version 21*da0073e9SAndroid Build Coastguard WorkerFrom this directory run: 22*da0073e9SAndroid Build Coastguard Worker`python commitlist.py --create_new tags/v1.13.1 <commit_hash> ` 23*da0073e9SAndroid Build Coastguard Worker 24*da0073e9SAndroid Build Coastguard WorkerThis saves a commit list to `results/commitlist.csv`. Please confirm visually that the oldest commits weren’t included in the branch cut for the last release as a sanity check. 25*da0073e9SAndroid Build Coastguard Worker 26*da0073e9SAndroid Build Coastguard WorkerNB: the commit list contains commits from the merge-base of tags/<most_recent_release_tag> and whatever commit hash you give it, so it may have commits that were cherry-picked to <most_recent_release_tag>! 27*da0073e9SAndroid Build Coastguard Worker 28*da0073e9SAndroid Build Coastguard Worker* Go through the list of cherry-picked commits to the last release and delete them from results/commitlist.csv. 29*da0073e9SAndroid Build Coastguard Worker* This is done manually: 30*da0073e9SAndroid Build Coastguard Worker * Look for all the PRs that were merged in the release branch with a github query like: https://github.com/pytorch/pytorch/pulls?q=is%3Apr+base%3Arelease%2F<most_recent_release_tag>+is%3Amerged 31*da0073e9SAndroid Build Coastguard Worker * Look at the commit history https://github.com/pytorch/pytorch/commits/release/<most_recent_release_tag>, to find all the direct push in the release branch (usually for reverts) 32*da0073e9SAndroid Build Coastguard Worker 33*da0073e9SAndroid Build Coastguard Worker 34*da0073e9SAndroid Build Coastguard WorkerIf you already have a commit list and want to update it, use the following command. This command can be helpful if there are cherry-picks to the release branch or if you’re categorizing commits throughout the three months up to a release. Warning: this is not very well tested. Make sure that you’re on the same branch (e.g., release/<upcoming_release_tag>) as the last time you ran this command, and that you always *commit* your csv before running this command to avoid losing work. 35*da0073e9SAndroid Build Coastguard Worker 36*da0073e9SAndroid Build Coastguard Worker`python commitlist.py --update_to <commit_hash>` 37*da0073e9SAndroid Build Coastguard Worker 38*da0073e9SAndroid Build Coastguard Worker### Part 2: categorizing commits 39*da0073e9SAndroid Build Coastguard Worker 40*da0073e9SAndroid Build Coastguard Worker#### Exploration and cleanup 41*da0073e9SAndroid Build Coastguard Worker 42*da0073e9SAndroid Build Coastguard WorkerIn this folder is an ipython notebook that I used for exploration and finding relevant commits. For example the commitlist attempts to categorize commits based off the `release notes:` label. Users of PyTorch often add new release notes labels. This Notebook has a cell that can help you identify new labels. 43*da0073e9SAndroid Build Coastguard Worker 44*da0073e9SAndroid Build Coastguard WorkerThere is a list of all known categories defined in `common.py`. It has designations for types of categories as well such as `_frontend`. 45*da0073e9SAndroid Build Coastguard Worker 46*da0073e9SAndroid Build Coastguard WorkerThe `categorize` function in commitlist.py does an adequate job of adding the appropriate categories. Since new categories though may be created for your release you may find it helpful to add new heuristics around files changed to help with categorization. 47*da0073e9SAndroid Build Coastguard Worker 48*da0073e9SAndroid Build Coastguard WorkerIf you update the automatic categorization you can run the following to update the commit list. 49*da0073e9SAndroid Build Coastguard Worker`python commitlist.py --rerun_with_new_filters` Note that this will only update the commits in the commit list that have a category of "Uncategorized". 50*da0073e9SAndroid Build Coastguard Worker 51*da0073e9SAndroid Build Coastguard WorkerOne you have dug through the commits and done as much automated categorization you can run the following for an interface to categorize any remaining commits. 52*da0073e9SAndroid Build Coastguard Worker 53*da0073e9SAndroid Build Coastguard Worker#### Training a commit classifier 54*da0073e9SAndroid Build Coastguard WorkerI added scripts to train a commit classifier from the set of labeled commits in commitlist.csv. This will utilize the title, author, and files changed features of the commits. The file requires torchtext, and tqdm. I had to install torchtext from source but if you are also a PyTorch developer this would likely already be installed. 55*da0073e9SAndroid Build Coastguard Worker 56*da0073e9SAndroid Build Coastguard Worker- There should already exist a `results/` directory from gathering the commitlist.csv. The next step is to create `mkdir results/classifier` 57*da0073e9SAndroid Build Coastguard Worker- Run `python classifier.py --train` This will train the model and save for inference. 58*da0073e9SAndroid Build Coastguard Worker- Run `python categorize.py --use_classifier` This will pre-populate the output with the most likely category. And pressing enter will confirm selection. 59*da0073e9SAndroid Build Coastguard Worker - Or run `python categorize.py` to label without the classifier. 60*da0073e9SAndroid Build Coastguard Worker 61*da0073e9SAndroid Build Coastguard WorkerThe interface modifies results/commitlist.csv. If you want to take a coffee break, you can CTRL-C out of it (results/commitlist.csv gets written to on each categorization) and then commit and push results/commitlist.csv to a branch for safekeeping. 62*da0073e9SAndroid Build Coastguard Worker 63*da0073e9SAndroid Build Coastguard WorkerIf you want to revert a change you just made, you can edit results/commitlist.csv directly. 64*da0073e9SAndroid Build Coastguard Worker 65*da0073e9SAndroid Build Coastguard WorkerFor each commit, after choosing the category, you can also choose a topic. For the frontend category, you should take the time to do it to save time in the next step. For other categories, you can do it but only of you are 100% sure as it is confusing for submodule owners otherwise. 66*da0073e9SAndroid Build Coastguard Worker 67*da0073e9SAndroid Build Coastguard WorkerThe categories are as follow: 68*da0073e9SAndroid Build Coastguard Worker Be sure to update this list if you add a new category to common.py 69*da0073e9SAndroid Build Coastguard Worker 70*da0073e9SAndroid Build Coastguard Worker* jit: Everything related to the jit (including tensorexpr) 71*da0073e9SAndroid Build Coastguard Worker* quantization: Everything related to the quantization mode/passes/operators 72*da0073e9SAndroid Build Coastguard Worker* mobile: Everything related to the mobile build/ops/features 73*da0073e9SAndroid Build Coastguard Worker* onnx: Everything related to onnx 74*da0073e9SAndroid Build Coastguard Worker* caffe2: Everything that happens in the caffe2 folder. No need to add any topics here as these are ignored (they don’t make it into the final release notes) 75*da0073e9SAndroid Build Coastguard Worker* distributed: Everything related to distributed training and rpc 76*da0073e9SAndroid Build Coastguard Worker* visualization: Everything related to tensorboard and visualization in general 77*da0073e9SAndroid Build Coastguard Worker* releng: Everything related to release engineering (circle CI, docker images, etc) 78*da0073e9SAndroid Build Coastguard Worker* amd: Everything related to rocm and amd CPUs 79*da0073e9SAndroid Build Coastguard Worker* cuda: Everything related to cuda backend 80*da0073e9SAndroid Build Coastguard Worker* benchmark: Everything related to the opbench folder and utils.benchmark submodule 81*da0073e9SAndroid Build Coastguard Worker* package: Everything related to torch.package 82*da0073e9SAndroid Build Coastguard Worker* performance as a product: All changes that improve perfs 83*da0073e9SAndroid Build Coastguard Worker* profiler: Everything related to the profiler 84*da0073e9SAndroid Build Coastguard Worker* composability: Everything related to the dispatcher and ATen native binding 85*da0073e9SAndroid Build Coastguard Worker* fx: Everything related to torch.fx 86*da0073e9SAndroid Build Coastguard Worker* code_coverage: Everything related to the code coverage tool 87*da0073e9SAndroid Build Coastguard Worker* vulkan: Everything related to vulkan support (mobile GPU backend) 88*da0073e9SAndroid Build Coastguard Worker* skip: Everything that is not end user or dev facing like code refactoring or internal implementation changes 89*da0073e9SAndroid Build Coastguard Worker* frontend: To ease your future work, we split things here (may be merged in the final document) 90*da0073e9SAndroid Build Coastguard Worker * python_api 91*da0073e9SAndroid Build Coastguard Worker * cpp_api 92*da0073e9SAndroid Build Coastguard Worker * complex 93*da0073e9SAndroid Build Coastguard Worker * vmap 94*da0073e9SAndroid Build Coastguard Worker * autograd 95*da0073e9SAndroid Build Coastguard Worker * build 96*da0073e9SAndroid Build Coastguard Worker * memory_format 97*da0073e9SAndroid Build Coastguard Worker * foreach 98*da0073e9SAndroid Build Coastguard Worker * dataloader 99*da0073e9SAndroid Build Coastguard Worker * nestedtensor 100*da0073e9SAndroid Build Coastguard Worker * sparse 101*da0073e9SAndroid Build Coastguard Worker * mps 102*da0073e9SAndroid Build Coastguard Worker 103*da0073e9SAndroid Build Coastguard Worker 104*da0073e9SAndroid Build Coastguard WorkerThe topics are as follow: 105*da0073e9SAndroid Build Coastguard Worker 106*da0073e9SAndroid Build Coastguard Worker* bc_breaking: All commits marked as BC-breaking (the script should highlight them). If any other commit look like it could be BC-breaking, add it here as well! 107*da0073e9SAndroid Build Coastguard Worker* deprecation: All commits introducing deprecation. Should be clear from commit msg. 108*da0073e9SAndroid Build Coastguard Worker* new_features: All commits introducing a new feature (new functions, new submodule, new supported platform etc) 109*da0073e9SAndroid Build Coastguard Worker* improvements: All commits providing improvements to existing feature should be here (new backend for a function, new argument, better numerical stability) 110*da0073e9SAndroid Build Coastguard Worker* bug fixes: All commits that fix bugs and behaviors that do not match the documentation 111*da0073e9SAndroid Build Coastguard Worker* performance: All commits that are here mainly for performance (we separate this from improvements above to make it easier for users to look for it) 112*da0073e9SAndroid Build Coastguard Worker* documentation: All commits that add/update documentation 113*da0073e9SAndroid Build Coastguard Worker* devs: All commits that are not end-user facing but still impact people that compile from source, develop into pytorch, extend pytorch, cpp extensions, etc 114*da0073e9SAndroid Build Coastguard Worker* unknown 115*da0073e9SAndroid Build Coastguard Worker 116*da0073e9SAndroid Build Coastguard Worker 117*da0073e9SAndroid Build Coastguard Worker### Part 3: export categories to markdown 118*da0073e9SAndroid Build Coastguard Worker 119*da0073e9SAndroid Build Coastguard Worker`python commitlist.py --export_markdown` 120*da0073e9SAndroid Build Coastguard Worker 121*da0073e9SAndroid Build Coastguard WorkerThe above exports results/commitlist.csv to markdown by listing every commit under its respective category. 122*da0073e9SAndroid Build Coastguard WorkerIt will create one file per category in the results/export/ folder. 123*da0073e9SAndroid Build Coastguard Worker 124*da0073e9SAndroid Build Coastguard WorkerThis part is a little tedious but it seems to work. May want to explore using pandoc to convert the markdown to google doc format. 125*da0073e9SAndroid Build Coastguard Worker 126*da0073e9SAndroid Build Coastguard Worker1. Make sure you are using the light theme of VSCode. 127*da0073e9SAndroid Build Coastguard Worker2. Open a preview of the markdown file and copy the Preview. 128*da0073e9SAndroid Build Coastguard Worker3. In the correct google doc copy the preview and make sure to paste WITH formatting. 129*da0073e9SAndroid Build Coastguard Worker4. You can now send these google docs to the relevant submodule owners for review. 130*da0073e9SAndroid Build Coastguard Worker5. Install the google doc extension [docs to markdown](https://github.com/evbacher/gd2md-html) 131*da0073e9SAndroid Build Coastguard Worker6. Start to compile back down these markdown files into a single markdown file. 132*da0073e9SAndroid Build Coastguard Worker 133*da0073e9SAndroid Build Coastguard Worker`TODO`: This is by far the most manual process and is ripe for automation. If the next person up would like to investigate Google Doc APIS there is some room hor improvement here. 134*da0073e9SAndroid Build Coastguard Worker 135*da0073e9SAndroid Build Coastguard Worker### Part 4: Cherry Picks 136*da0073e9SAndroid Build Coastguard Worker 137*da0073e9SAndroid Build Coastguard WorkerYou will likely have started this process prior to the branch-cut being finalized. This means Cherry Picks. 138*da0073e9SAndroid Build Coastguard WorkerThis was my process for keeping track. I use a notes app to log my progress as I periodically incorporate the new cherry picks. 139*da0073e9SAndroid Build Coastguard WorkerI will have initially ran something like: 140*da0073e9SAndroid Build Coastguard Worker``` Bash 141*da0073e9SAndroid Build Coastguard Workerpython commitlist.py --create_new tags/v1.13.1 <commit-hash> 142*da0073e9SAndroid Build Coastguard Worker``` 143*da0073e9SAndroid Build Coastguard WorkerI keep track of that commit-hash. Once there are some cherry-picks that you would like to incorporate I rebase the release branch to upstream 144*da0073e9SAndroid Build Coastguard Workerand run: 145*da0073e9SAndroid Build Coastguard Worker```Bash 146*da0073e9SAndroid Build Coastguard Workerpython commitlist.py --update_to <latest-cherry-pick-hash> 147*da0073e9SAndroid Build Coastguard Worker``` 148*da0073e9SAndroid Build Coastguard WorkerI then run 149*da0073e9SAndroid Build Coastguard Worker``` Python 150*da0073e9SAndroid Build Coastguard Workerimport pandas as pd 151*da0073e9SAndroid Build Coastguard Worker 152*da0073e9SAndroid Build Coastguard Workercommit_list_df = pd.read_csv("results/commitlist.csv") 153*da0073e9SAndroid Build Coastguard Workerlast_known_good_hash = "<the most recent hash>" 154*da0073e9SAndroid Build Coastguard Worker 155*da0073e9SAndroid Build Coastguard Workerprevious_index = commit_list_df[commit_list_df.commit_hash == last_known_good_hash].index.values[0] 156*da0073e9SAndroid Build Coastguard Workercherry_pick_df = commit_list_df.iloc[previous_index+1:] 157*da0073e9SAndroid Build Coastguard Workerpath = "<your_path>/cherry_picks.csv" 158*da0073e9SAndroid Build Coastguard Workercherry_pick_df.to_csv(path, index=False) 159*da0073e9SAndroid Build Coastguard Worker 160*da0073e9SAndroid Build Coastguard Worker 161*da0073e9SAndroid Build Coastguard Workerfrom commitlist import CommitList, to_markdown 162*da0073e9SAndroid Build Coastguard Workercherry_pick_commit_list = CommitList.from_existing(path) 163*da0073e9SAndroid Build Coastguard Worker 164*da0073e9SAndroid Build Coastguard Workerimport os 165*da0073e9SAndroid Build Coastguard Workercategories = list(cherry_pick_commit_list.stat().keys()) 166*da0073e9SAndroid Build Coastguard Workerfor category in categories: 167*da0073e9SAndroid Build Coastguard Worker print(f"Exporting {category}...") 168*da0073e9SAndroid Build Coastguard Worker lines =to_markdown(cherry_pick_commit_list, category) 169*da0073e9SAndroid Build Coastguard Worker filename = f'/tmp/cherry_pick/results/result_{category}.md' 170*da0073e9SAndroid Build Coastguard Worker os.makedirs(os.path.dirname(filename), exist_ok=True) 171*da0073e9SAndroid Build Coastguard Worker with open(filename, 'w') as f: 172*da0073e9SAndroid Build Coastguard Worker f.writelines(lines) 173*da0073e9SAndroid Build Coastguard Worker 174*da0073e9SAndroid Build Coastguard Worker``` 175*da0073e9SAndroid Build Coastguard Worker 176*da0073e9SAndroid Build Coastguard WorkerThis will create new markdown files only from cherry picked commits. And I manually copied and pasted these into the submodule google docs and commented so that 177*da0073e9SAndroid Build Coastguard Workerthe submodule owners will see these new commits. 178*da0073e9SAndroid Build Coastguard Worker 179*da0073e9SAndroid Build Coastguard Worker 180*da0073e9SAndroid Build Coastguard Worker### Part 5: Pulling on the submodules into one 181*da0073e9SAndroid Build Coastguard WorkerI pretty much followed the run book here. One thing I did was use the [markdown-all-in-one](https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one) 182*da0073e9SAndroid Build Coastguard Workerextension to create a table of contents which was really helpful in jumping to sections and copy and pasting the appropriate commits. 183*da0073e9SAndroid Build Coastguard Worker 184*da0073e9SAndroid Build Coastguard WorkerYou will then create a release at [Pytorch Release](https://github.com/pytorch/pytorch/releases) and if you save as a draft you can see how it will be rendered. 185*da0073e9SAndroid Build Coastguard Worker 186*da0073e9SAndroid Build Coastguard Worker 187*da0073e9SAndroid Build Coastguard Worker 188*da0073e9SAndroid Build Coastguard Worker#### Tidbits 189*da0073e9SAndroid Build Coastguard WorkerYou will probably have a release note that doesn't fit into the character limit of github. I used the following regex: 190*da0073e9SAndroid Build Coastguard Worker`\[#(\d+)\]\(https://github.com/pytorch/pytorch/pull/\d+\)` to replace the full lunks to (#<pull-request-number>). 191*da0073e9SAndroid Build Coastguard WorkerThis will get formatted correctly in the github UI and can be checked when creating a draft release. 192*da0073e9SAndroid Build Coastguard Worker 193*da0073e9SAndroid Build Coastguard Worker 194*da0073e9SAndroid Build Coastguard WorkerThe following markdown code is helpful for creating side-by-side tables of BC breaking/ deprecated code: 195*da0073e9SAndroid Build Coastguard Worker 196*da0073e9SAndroid Build Coastguard Worker 197*da0073e9SAndroid Build Coastguard Worker``` Markdown 198*da0073e9SAndroid Build Coastguard Worker<table> 199*da0073e9SAndroid Build Coastguard Worker<tr> 200*da0073e9SAndroid Build Coastguard Worker<th>PRIOR RELEASE NUM</th> 201*da0073e9SAndroid Build Coastguard Worker<th>NEW RELEASE NUM</th> 202*da0073e9SAndroid Build Coastguard Worker</tr> 203*da0073e9SAndroid Build Coastguard Worker<tr> 204*da0073e9SAndroid Build Coastguard Worker<td> 205*da0073e9SAndroid Build Coastguard Worker 206*da0073e9SAndroid Build Coastguard Worker```Python 207*da0073e9SAndroid Build Coastguard Worker# Code Snippet 1 208*da0073e9SAndroid Build Coastguard Worker``` 209*da0073e9SAndroid Build Coastguard Worker 210*da0073e9SAndroid Build Coastguard Worker</td> 211*da0073e9SAndroid Build Coastguard Worker<td> 212*da0073e9SAndroid Build Coastguard Worker 213*da0073e9SAndroid Build Coastguard Worker```Python 214*da0073e9SAndroid Build Coastguard Worker# Code Snippet 2 215*da0073e9SAndroid Build Coastguard Worker``` 216*da0073e9SAndroid Build Coastguard Worker 217*da0073e9SAndroid Build Coastguard Worker</td> 218*da0073e9SAndroid Build Coastguard Worker</tr> 219*da0073e9SAndroid Build Coastguard Worker</table> 220*da0073e9SAndroid Build Coastguard Worker``` 221