├── .gitignore ├── LICENSE ├── README.md ├── session_1 ├── README.md └── images │ ├── Nvidia_CUDA_Logo.jpg │ ├── cuda-example-part1.png │ ├── cuda-example.png │ ├── gpu-latency.gif │ ├── gpu-memory-hierarchy.png │ ├── h100-diagram.png │ ├── h100-specs.png │ └── output-onlinegiftools.gif ├── session_10 └── README.md ├── session_11 ├── README.md ├── diagrams.png └── overlapping-communication-and-computation-via-decomposition.pdf ├── session_2 ├── README.md ├── flash_attention.py ├── flash_attention_[annotated].pdf └── requirements.txt ├── session_3 └── README.md ├── session_4 ├── README.md ├── blockwise_transformers_[annotated].pdf ├── ring_attention_[annotated].pdf └── sequence_parallelism_[annotated].pdf ├── session_5 ├── README.md └── paged_attention_[annotated].pdf ├── session_6 ├── README.md ├── gpipe_[annotated].pdf ├── pipe_dream_[annotated].pdf └── zero_bubble_pipeline_parallelism_[annotated].pdf ├── session_7 ├── README.md ├── deepseek-v2_[annotated].pdf └── deepseek-v3_[annotated].pdf ├── session_8 ├── README.md ├── megatron-diagrams.excalidraw └── megatron_annotated.pdf └── session_9 ├── README.md └── reducing_activation_recomputation_[annotated].pdf /.gitignore: -------------------------------------------------------------------------------- 1 | .venv/ 2 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EleutherAI ML Scalability & Performance Reading Group 2 | 3 | My annotated papers, slides, and meeting recordings for the EleutherAI ML Scalability & Performance research paper reading group. 4 | 5 | Sessions: 6 | 7 | 1. [Session 1](./session_1/) 8 | - [Intro to GPU architecture, CUDA, NCCL, and common ML performance bottlenecks](https://www.youtube.com/watch?v=Cp7g1Ll4v0M) 9 | 2. [Session 2](./session_2/) 10 | - [FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness](./session_2/flash_attention_[annotated].pdf) 11 | 3. [Session 3](./session_3/) 12 | - [ZeRO: Memory Optimizations Toward Training Trillion Parameter Models](https://arxiv.org/abs/1910.02054) 13 | 4. [Session 4](./session_4) 14 | - [Sequence Parallelism: Long Sequence Training from System Perspective](./session_4/sequence_parallelism_[annotated].pdf) 15 | - [Blockwise Parallel Transformer for Large Context Models](./session_4/blockwise_transformers_[annotated].pdf) 16 | - [Ring Attention with Blockwise Transformers for Near-Infinite Context Length](./session_4/ring_attention_[annotated].pdf) 17 | 5. [Session 5](./session_5/) 18 | - [Efficient Memory Management for Large Language Model Serving with PagedAttention](https://arxiv.org/abs/2309.06180) 19 | 6. [Session 6](./session_6) 20 | - [GPipe: Efficient Training of Giant Neural Networks using Pipeline Parallelism](./session_6/gpipe_[annotated].pdf) 21 | - [PipeDream: Fast and Efficient Pipeline Parallel DNN Training](./session_6/pipe_dream_[annotated].pdf) 22 | - [Zero Bubble Pipeline Parallelism](./session_6/zero_bubble_pipeline_parallelism_[annotated].pdf) 23 | 7. [Session 7](./session_7/) 24 | - [DeepSeek V3](./session_7/deepseek-v3_[annotated].pdf) 25 | - [DeepSeek V2](./session_7/deepseek-v2_[annotated].pdf) 26 | 8. [Session 8](./session_8) 27 | - [Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism](https://arxiv.org/abs/1909.08053) 28 | 9. [Session 9](./session_9/) 29 | - [Reducing Activation Recomputation in Large Transformer Models](https://arxiv.org/abs/2205.05198) 30 | 10. [Session 10](./session_10/) 31 | - [Task-Circuit Quantization: Leveraging Knowledge Localization and Interpretability for Compression](https://arxiv.org/abs/2504.07389) 32 | 11. [Session 11](./session_11) 33 | - [Overlap Communication with Dependent Computation via Decomposition in Large Deep Learning Models](https://dl.acm.org/doi/abs/10.1145/3567955.3567959) -------------------------------------------------------------------------------- /session_1/README.md: -------------------------------------------------------------------------------- 1 | # Session 1: Intro to GPU architecture, CUDA, NCCL, and performance bottlenecks 2 | 3 | **Presenter**: Daniel Vega-Myhre 4 | 5 | - [Slides](https://docs.google.com/presentation/d/1JbfKElxygkpl1MrMXT0Eifo-QW40dC3RTmPE2ARAG80/edit?usp=sharing) 6 | - [Recording](https://youtu.be/Cp7g1Ll4v0M?si=IppwAiTKDVMT_mMm) 7 | -------------------------------------------------------------------------------- /session_1/images/Nvidia_CUDA_Logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_1/images/Nvidia_CUDA_Logo.jpg -------------------------------------------------------------------------------- /session_1/images/cuda-example-part1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_1/images/cuda-example-part1.png -------------------------------------------------------------------------------- /session_1/images/cuda-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_1/images/cuda-example.png -------------------------------------------------------------------------------- /session_1/images/gpu-latency.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_1/images/gpu-latency.gif -------------------------------------------------------------------------------- /session_1/images/gpu-memory-hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_1/images/gpu-memory-hierarchy.png -------------------------------------------------------------------------------- /session_1/images/h100-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_1/images/h100-diagram.png -------------------------------------------------------------------------------- /session_1/images/h100-specs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_1/images/h100-specs.png -------------------------------------------------------------------------------- /session_1/images/output-onlinegiftools.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_1/images/output-onlinegiftools.gif -------------------------------------------------------------------------------- /session_10/README.md: -------------------------------------------------------------------------------- 1 | # Session 10: Task Circuit Quantization 2 | 3 | EleutherAI ML Scalability & Performance Reading Group Session 10, where researcher Hanqi Xiao presented his paper "Task-Circuit Quantization: Leveraging Knowledge Localization and Interpretability for Compression" (https://arxiv.org/abs/2504.07389). 4 | 5 | **Presenter**: Hanqi Xiao 6 | 7 | ### Papers: 8 | 1. [Task-Circuit Quantization: Leveraging Knowledge Localization and Interpretability for Compression](https://arxiv.org/abs/2504.07389) 9 | 10 | ### Links: 11 | - [Recording](https://www.youtube.com/watch?v=WUU1CCbzmKg) 12 | -------------------------------------------------------------------------------- /session_11/README.md: -------------------------------------------------------------------------------- 1 | # Session 11: Async Tensor Parallelism 2 | 3 | EleutherAI ML Scalability & Performance Reading Group Session 11 meeting recording, where we covered the paper "Overlap Communication with Dependent Computation via Decomposition in Large Deep Learning Models," as well as how it is implemented in PyTorch as "async tensor parallelism." 4 | 5 | Presenter: Daniel Vega-Myhre 6 | 7 | ### Links: 8 | - [Overlap Communication with Dependent Computation via Decomposition in Large Deep Learning Models](./overlapping-communication-and-computation-via-decomposition.pdf) 9 | - [PyTorch Async Tensor Parallelism blog post](https://discuss.pytorch.org/t/distributed-w-torchtitan-introducing-async-tensor-parallelism-in-pytorch/209487) 10 | - [Meeting recording](https://youtu.be/Ow1FLKFcSPs?si=KANmECRX1vRt4C_W) 11 | - [Presentation diagrams](./diagrams.png) 12 | -------------------------------------------------------------------------------- /session_11/diagrams.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_11/diagrams.png -------------------------------------------------------------------------------- /session_11/overlapping-communication-and-computation-via-decomposition.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_11/overlapping-communication-and-computation-via-decomposition.pdf -------------------------------------------------------------------------------- /session_2/README.md: -------------------------------------------------------------------------------- 1 | # Session 2: Flash Attention 2 | 3 | In session 2 we covered the paper [FlashAttention: Fast and Memory-Efficient Exact Attention 4 | with IO-Awareness](https://arxiv.org/pdf/2205.14135), and walked through my Triton kernel implementation. 5 | 6 | **Presenters**: Ben Schneider, Daniel Vega-Myhre 7 | 8 | ### Links 9 | - [Recording](https://youtu.be/Lys0TpsLIEc?si=T1Fy8Lf874Ax0d6S) 10 | - [Triton kernel](./flash_attention.py) 11 | - [Annotated flash attention paper](./flash_attention_[annotated].pdf) -------------------------------------------------------------------------------- /session_2/flash_attention.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import triton 3 | import triton.language as tl 4 | 5 | class FlashAttention(torch.autograd.Function): 6 | @staticmethod 7 | def forward(ctx, Q: torch.Tensor, K: torch.Tensor, V: torch.Tensor, softmax_scale: float): 8 | HEAD_DIM_Q, HEAD_DIM_K, HEAD_DIM_V = Q.shape[-1], K.shape[-1], V.shape[-1] 9 | assert HEAD_DIM_Q == HEAD_DIM_K and HEAD_DIM_K == HEAD_DIM_V 10 | 11 | batch_size, num_heads, seq_len, head_dim = Q.shape 12 | O = torch.empty_like(Q) 13 | M = torch.zeros((batch_size, num_heads, seq_len)) 14 | 15 | # Parallel kernel instances will each handle a separate 16 | # (query block index, head index, index in batch). 17 | # This parallelizes over the Q blocks (the outer for-loop in 18 | # the Flash Attention algorithm), and within those blocks 19 | # parallelizes further across each sequence (index in the batch 20 | # dimension), and within those parallelizes further across each 21 | # head. 22 | # Total degree of parallelization will be: 23 | # (SEQ_LEN // BLOCK_SIZE Q) * BATCH_SIZE * NUM_HEADS 24 | grid = lambda meta: ( 25 | triton.cdiv(seq_len, meta["BLOCK_SIZE_Q"]), 26 | batch_size * num_heads, 27 | 1 28 | ) 29 | 30 | _attn_fwd[grid]( 31 | Q_ptr=Q, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 32 | K_ptr=K, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 33 | V_ptr=V, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 34 | O_ptr=O, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 35 | M_ptr=M, # BATCH_SIZE, NUM_HEADS, SEQ_LEN 36 | softmax_scale=softmax_scale, 37 | stride_Q_batch=Q.stride(0), 38 | stride_Q_head=Q.stride(1), 39 | stride_Q_seq=Q.stride(2), 40 | stride_Q_dim=Q.stride(3), 41 | stride_K_batch=K.stride(0), 42 | stride_K_head=K.stride(1), 43 | stride_K_seq=K.stride(2), 44 | stride_K_dim=K.stride(3), 45 | stride_V_batch=V.stride(0), 46 | stride_V_head=V.stride(1), 47 | stride_V_seq=V.stride(2), 48 | stride_V_dim=V.stride(3), 49 | stride_O_batch=O.stride(0), 50 | stride_O_head=O.stride(1), 51 | stride_O_seq=O.stride(2), 52 | stride_O_dim=O.stride(3), 53 | stride_M_batch=M.stride(0), 54 | stride_M_head=M.stride(1), 55 | stride_M_seq=M.stride(2), 56 | BATCH_SIZE=batch_size, 57 | NUM_HEADS=num_heads, 58 | SEQ_LEN=seq_len, 59 | HEAD_DIM=head_dim, 60 | ) 61 | ctx.save_for_backward(Q, K, V, O, M) 62 | ctx.grid = grid 63 | ctx.softmax_scale = softmax_scale 64 | return O 65 | 66 | @staticmethod 67 | def backward(ctx, dO): 68 | ( 69 | Q, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 70 | K, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 71 | V, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 72 | O, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 73 | M, # BATCH_SIZE, NUM_HEADS, SEQ_LEN 74 | ) = ctx.saved_tensors 75 | 76 | assert dO.is_contiguous() 77 | assert Q.stride() == K.stride() == V.stride() == O.stride() == dO.stride() 78 | 79 | dQ = torch.empty_like(Q) 80 | dK = torch.empty_like(K) 81 | dV = torch.empty_like(V) 82 | D = torch.empty_like(M) # intermediate value used to make computing dK dV easier 83 | 84 | BATCH_SIZE, NUM_HEADS, SEQ_LEN = Q.shape[:3] 85 | HEAD_DIM_KV = Q.shape(3) 86 | 87 | # compute D, the 88 | d_grid = lambda meta: ( 89 | triton.cdiv(SEQ_LEN, meta['BLOCK_SIZE_Q']), 90 | BATCH_SIZE * NUM_HEADS, 91 | ) 92 | _attn_bwd_preprocess[d_grid]( 93 | O=O, 94 | dO=dO, 95 | D=D, 96 | stride_O_batch=O.stride(0), 97 | stride_O_head=O.stride(1), 98 | stride_O_seq=O.stride(2), 99 | stride_O_dim=O.stride(3), 100 | stride_dO_batch=dO.stride(0), 101 | stride_dO_head=dO.stride(1), 102 | stride_dO_seq=dO.stride(2), 103 | stride_dO_dim=dO.stride(3), 104 | stride_D_batch=D.stride(0), 105 | stride_D_head=D.stride(1), 106 | stride_D_seq=D.stride(2), 107 | NUM_HEADS=NUM_HEADS, 108 | SEQ_LEN=SEQ_LEN, 109 | HEAD_DIM=HEAD_DIM_KV, 110 | ) 111 | 112 | grid = lambda meta: ( 113 | triton.cdiv(SEQ_LEN, 'BLOCK_SIZE_SEQ'), 114 | BATCH_SIZE * NUM_HEADS, 115 | ) 116 | _attn_bwd_dk_dv[grid]( 117 | Q=Q, 118 | K=K, 119 | V=V, 120 | softmax_scale=ctx.softmax_scale, 121 | dO=dO, 122 | dQ=dQ, 123 | dK=dK, 124 | dV=dV, 125 | M=M, 126 | D=D, 127 | stride_batch=Q.stride(0), 128 | stride_head=Q.stride(1), 129 | stride_seq=Q.stride(2), 130 | stride_dim=Q.stride(3), 131 | NUM_HEADS=NUM_HEADS, 132 | SEQ_LEN=SEQ_LEN, 133 | HEAD_DIM=ctx.head_dim, 134 | ) 135 | # TODO 136 | 137 | @triton.jit 138 | def _attn_bwd_dk_dv( 139 | Q, 140 | K, 141 | V, 142 | softmax_scale, 143 | dO, 144 | dQ, 145 | dK, 146 | dV, 147 | M, 148 | D, 149 | stride_q_batch, 150 | stride_q_head, 151 | stride_q_seq, 152 | stride_q_dim, 153 | NUM_HEADS: tl.constexpr, 154 | SEQ_LEN: tl.constexpr, 155 | HEAD_DIM: tl.constexpr, 156 | ): 157 | batch_head_idx = tl.program_id(axis=1) 158 | batch_idx = batch_head_idx // NUM_HEADS 159 | head_idx = batch_head_idx % NUM_HEADS 160 | 161 | offs_seq = batch_idx * stride_q_batch + head_idx * stride_q_dim 162 | # TODO 163 | 164 | 165 | @triton.jit 166 | def _attn_bwd_preprocess( 167 | O, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 168 | dO, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 169 | D, # BATCH_SIZE, NUM_HEADS, SEQ_LEN 170 | stride_O_batch, 171 | stride_O_head, 172 | stride_O_seq, 173 | stride_O_dim, 174 | stride_dO_batch, 175 | stride_dO_head, 176 | stride_dO_seq, 177 | stride_dO_dim, 178 | stride_D_batch, 179 | stride_D_head, 180 | stride_D_seq, 181 | NUM_HEADS: tl.constexpr, 182 | SEQ_LEN: tl.constexpr, 183 | HEAD_DIM: tl.constexpr, 184 | BLOCK_SIZE_SEQ: tl.constexpr, 185 | ): 186 | query_block_idx = tl.program_id(axis=0) 187 | batch_head_idx = tl.program_id(axis=1) 188 | batch_idx = batch_head_idx // NUM_HEADS 189 | head_idx = batch_head_idx % NUM_HEADS 190 | 191 | # load O and dO blocks into SRAM 192 | offs_seq = query_block_idx * BLOCK_SIZE_SEQ + tl.arange(0, BLOCK_SIZE_SEQ) 193 | offs_head = tl.arange(0, HEAD_DIM) 194 | offs_o = ( 195 | batch_idx * stride_O_batch + head_idx * stride_O_head 196 | + offs_seq[:, None] * stride_O_seq 197 | + offs_head[None, :] 198 | ) 199 | 200 | O_block = tl.load(offs_o) # (BLOCK_SIZE_SEQ, HEAD_DIM) 201 | dO_block = tl.load(offs_o) # (BLOCK_SIZE_SEQ, HEAD_DIM) 202 | 203 | # compute D_i block and store in HBM 204 | Di_block = tl.sum(O_block * dO_block, axis=1) # (BLOCK_SIZE_SEQ,) 205 | offs_di = ( 206 | batch_idx * stride_D_batch + batch_head_idx * stride_D_head 207 | + offs_seq 208 | ) 209 | tl.store(D + offs_di, Di_block) 210 | 211 | 212 | @triton.autotune(configs=[ 213 | triton.Config(kwargs={'BLOCK_SIZE_Q': 64, 'BLOCK_SIZE_KV': 64}, num_warps=4), 214 | triton.Config(kwargs={'BLOCK_SIZE_Q': 128, 'BLOCK_SIZE_KV': 128}, num_warps=4), 215 | ], 216 | key=['BATCH_SIZE'], 217 | ) 218 | @triton.jit 219 | def _attn_fwd( 220 | Q_ptr, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 221 | K_ptr, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 222 | V_ptr, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 223 | O_ptr, # BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM 224 | M_ptr, # BATCH_SIZE, NUM_HEADS, SEQ_LEN 225 | softmax_scale, 226 | stride_Q_batch, 227 | stride_Q_head, 228 | stride_Q_seq, 229 | stride_Q_dim, 230 | stride_K_batch, 231 | stride_K_head, 232 | stride_K_seq, 233 | stride_K_dim, 234 | stride_V_batch, 235 | stride_V_head, 236 | stride_V_seq, 237 | stride_V_dim, 238 | stride_O_batch, 239 | stride_O_head, 240 | stride_O_seq, 241 | stride_O_dim, 242 | stride_M_batch, 243 | stride_M_head, 244 | stride_M_seq, 245 | BATCH_SIZE, 246 | NUM_HEADS: tl.constexpr, 247 | SEQ_LEN: tl.constexpr, 248 | HEAD_DIM: tl.constexpr, 249 | BLOCK_SIZE_Q: tl.constexpr, 250 | BLOCK_SIZE_KV: tl.constexpr, 251 | ): 252 | ''' 253 | Parallel kernel instances will each handle a separate 254 | (query block index, head index, index in batch). 255 | 256 | This parallelizes over the Q blocks (the outer for-loop in 257 | the Flash Attention algorithm), and within those blocks 258 | parallelizes further across each sequence (index in the batch 259 | dimension), and within those parallelizes further across each 260 | head. 261 | 262 | Total degree of parallelization will be: 263 | 264 | (SEQ_LEN // BLOCK_SIZE Q) * BATCH_SIZE * NUM_HEADS 265 | 266 | :Q_ptr: pointer to query tensor 267 | :K_ptr: pionter to key tensor 268 | :V_ptr: pointer to value tensor 269 | :O_ptr: pointer to output tensor to write result to 270 | :M_ptr: pointer to tensor to store `rowmax[i] + log(softmax_denom[i])` 271 | values to use to recompute the softmax values in in the backward 272 | pass with the logsumexp trick 273 | ''' 274 | inf = 1.0e6 275 | 276 | # each program handles a specific query head for a specific index in the batch dimension. 277 | # this is represented as a 2D index (query_idx, batch_idx * head_idx) 278 | query_block_idx = tl.program_id(axis=0) 279 | batch_head_idx = tl.program_id(axis=1) 280 | 281 | # decompose batch_idx * head_idx into separate batch_idx and head_idx 282 | batch_idx = batch_head_idx // NUM_HEADS 283 | head_idx = batch_head_idx % NUM_HEADS 284 | 285 | # calculate offset to this batch and head 286 | qkv_offset = batch_idx * stride_Q_batch + head_idx * stride_Q_head 287 | 288 | # get subset of Q blocks we are processing in this program id. 289 | # Q[batch_idx, head_idx, :, :] 290 | Q_block_ptr = tl.make_block_ptr( 291 | # by adding the offset to the right batch idx & head idx, 292 | # the base points to the start of a tensor of shape (seq, head_dim) 293 | # within the parent tensor of shape (batch, heads, seq, dim) 294 | base=Q_ptr + qkv_offset, # Q[batch_idx, head_idx, :, :] 295 | shape=(SEQ_LEN, HEAD_DIM), 296 | strides=(stride_Q_seq, stride_Q_dim), 297 | # the (seq, head) sub tensor has all the queries in it, 298 | # so offset into the specific query block we want. 299 | # # Q[batch_idx, head_idx, q_idx:q_idx+block_size_q, :] 300 | block_shape=(BLOCK_SIZE_Q, HEAD_DIM), 301 | offsets=(query_block_idx * BLOCK_SIZE_Q, 0), 302 | order=(1,0), 303 | ) 304 | 305 | # get K block. needs to be transposed for Q @ K^T. 306 | # K[batch_idx, head_idx, :, :] 307 | K_block_ptr = tl.make_block_ptr( 308 | base=K_ptr + qkv_offset, 309 | # inverse shape and stride params to transpose w.r.t. Q 310 | shape=(HEAD_DIM, SEQ_LEN), 311 | strides=(stride_K_dim, stride_K_seq), 312 | # for K,V we select all keys and values, not a sub-block like in Q, 313 | # so we don't add any offsets and just start at the beginning of the block. 314 | offsets=(0, 0), 315 | block_shape=(HEAD_DIM, BLOCK_SIZE_KV), 316 | order=(1,0), 317 | ) 318 | 319 | # get V block. 320 | # V[batch_idx, head_idx, :, :] 321 | V_block_ptr = tl.make_block_ptr( 322 | base=V_ptr + qkv_offset, 323 | shape=(SEQ_LEN, HEAD_DIM), 324 | strides=(stride_V_seq, stride_V_dim), 325 | offsets=(0, 0), 326 | block_shape=(BLOCK_SIZE_KV, HEAD_DIM), 327 | order=(1,0), 328 | ) 329 | 330 | # get O (output) block ptrs. 331 | O_block_ptr = tl.make_block_ptr( 332 | # points to O[batch_idx, head_idx, :, :] 333 | # of shape (seq, head dim) just like Q,K,V. 334 | base=O_ptr + qkv_offset, 335 | shape=(SEQ_LEN, HEAD_DIM), 336 | strides=(stride_O_seq, stride_O_dim), 337 | # offsets will be same as Q since we are writing 338 | # outputs for the subset of queries process in this program id. 339 | offsets=(query_block_idx * BLOCK_SIZE_Q, 0), 340 | block_shape=(BLOCK_SIZE_Q, HEAD_DIM), 341 | order=(1,0), 342 | ) 343 | 344 | # m_i = max seen so far in QK. track one for each query. 345 | s_max = tl.full((BLOCK_SIZE_Q,), -float('inf'), dtype=tl.float32) 346 | 347 | # l_i = accumlated global softmax denominator / exp sum 348 | softmax_denom = tl.zeros((BLOCK_SIZE_Q,), dtype=tl.float32) 349 | 350 | # accumulator for block of output matrix being computed by this program id. 351 | O_block = tl.zeros((BLOCK_SIZE_Q, HEAD_DIM), dtype=tl.float32) 352 | 353 | # load Q block into SRAM, it will be shared for all iterations of inner 354 | # loop doing O = softmax(Q @ K^T / scale) @ V 355 | Q_block = tl.load(Q_block_ptr) # (BLOCK_SIZE_Q, HEAD_DIM) 356 | 357 | # set up q block and kv block offsets for causal masking. 358 | offs_q = query_block_idx * BLOCK_SIZE_Q + tl.arange(0, BLOCK_SIZE_Q) 359 | offs_kv = tl.arange(0, BLOCK_SIZE_KV) 360 | 361 | # for each Q block, iterate through all associated K and V blocks 362 | # (up through diagonal of QK, since this is causal attention we don't need to compute 363 | # values for the top right triangle of QK). 364 | end_key_idx = (query_block_idx + 1) * BLOCK_SIZE_Q 365 | for start_kv_idx in tl.range(0, end_key_idx, BLOCK_SIZE_KV): 366 | causal_mask = offs_q[:, None] >= (start_kv_idx + offs_kv[None, :]) 367 | 368 | # load next K block into SRAM 369 | K_block = tl.load(K_block_ptr) # (HEAD_DIM, BLOCK_SIZE_Q) 370 | 371 | # load V block into SRAM 372 | V_block = tl.load(V_block_ptr) # (BLOCK_SIZE_KV, HEAD_DIM) 373 | 374 | # compute attention scores 375 | # S[i,j] 376 | S_block = ( 377 | tl.dot(Q_block, K_block) 378 | * softmax_scale 379 | + tl.where(causal_mask, 0, -inf) 380 | ) # (BLOCK_SIZE_Q, BLOCK_SIZE_KV) 381 | 382 | # m[i,j] 383 | local_s_max = tl.max(S_block, axis=1) # (BLOCK_SIZE_Q,) 384 | new_s_max = tl.maximum(s_max, local_s_max) 385 | 386 | # corrective factor for previously accumulated denominator 387 | corrective_factor = tl.exp(s_max - new_s_max) # (BLOCK_SIZE_Q,) 388 | 389 | # P[i,j] (exp scores) 390 | P_block = tl.exp(S_block - new_s_max[:, None]) # (BLOCK_SIZE_Q, BLOCK_SIZE_KV) 391 | 392 | # rowsum(P[i,j]) 393 | P_rowsum = tl.sum(P_block, axis=1) # (BLOCK_SIZE_Q,) 394 | 395 | # l[i,j] 396 | softmax_denom = ( 397 | corrective_factor * softmax_denom + P_rowsum # (BLOCK_SIZE_Q,) 398 | ) 399 | 400 | # apply corrective factor to O block 401 | # O[i,j] 402 | O_block = O_block * corrective_factor[:, None] # (BLOCK_SIZE_Q, HEAD_DIM) 403 | O_block = O_block + tl.dot(P_block, V_block) # (BLOCK_SIZE_Q, HEAD_DIM) 404 | 405 | # m[i] -- update global max 406 | s_max = tl.maximum(s_max, local_s_max) 407 | 408 | # move to next K,V blocks 409 | K_block_ptr = tl.advance(K_block_ptr, (0, BLOCK_SIZE_KV)) 410 | V_block_ptr = tl.advance(V_block_ptr, (BLOCK_SIZE_KV, 0)) 411 | 412 | # normalize scores to finalize softmax block 413 | O_block = O_block / softmax_denom[:, None] # (BLOCK_SIZE_Q, HEAD_DIM) 414 | 415 | # store O block output in HBM 416 | tl.store(O_block_ptr, O_block) 417 | 418 | # store m_i + log(l_i) which can be used to recompute softmax in backward pass 419 | # using the logsumexp trick. 420 | s_max += tl.math.log(softmax_denom) # (BLOCK_SIZE_Q,) 421 | 422 | offs_m = offs_q + (batch_idx * stride_M_batch) + (head_idx * stride_M_head) 423 | tl.store(M_ptr + offs_m, s_max) 424 | 425 | 426 | def test_op(BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM, dtype=torch.float32): 427 | device = "cuda" if torch.cuda.is_available() else "cpu" 428 | Q = ( 429 | torch.empty( 430 | (BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM), dtype=dtype, device=device 431 | ) 432 | .normal_(mean=0.0, std=0.5) 433 | .requires_grad_() 434 | ) 435 | K = ( 436 | torch.empty( 437 | (BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM), dtype=dtype, device=device 438 | ) 439 | .normal_(mean=0.0, std=0.5) 440 | .requires_grad_() 441 | ) 442 | V = ( 443 | torch.empty( 444 | (BATCH_SIZE, NUM_HEADS, SEQ_LEN, HEAD_DIM), dtype=dtype, device=device 445 | ) 446 | .normal_(mean=0.0, std=0.5) 447 | .requires_grad_() 448 | ) 449 | 450 | softmax_scale = 1 / (HEAD_DIM**0.5) 451 | 452 | # reference implementation 453 | MASK = torch.tril(torch.ones((SEQ_LEN, SEQ_LEN), device=device)) 454 | P = torch.matmul(Q, K.transpose(2, 3)) * softmax_scale 455 | P[:, :, MASK == 0] = float("-inf") 456 | P = torch.softmax(P.float(), dim=-1) 457 | ref_O = torch.matmul(P, V) 458 | 459 | # triton implementation 460 | flash_out = FlashAttention.apply(Q, K, V, softmax_scale) 461 | 462 | # compare 463 | rtol = 0.0 464 | atol = 1e-2 465 | if not torch.allclose(ref_O, flash_out, atol=atol, rtol=rtol): 466 | print("want:") 467 | print(ref_O) 468 | print("\ngot:") 469 | print(flash_out) 470 | print("FAILED") 471 | else: 472 | print("PASSED") 473 | 474 | 475 | if __name__ == "__main__": 476 | test_op(BATCH_SIZE=8, NUM_HEADS=4, SEQ_LEN=2048, HEAD_DIM=128) -------------------------------------------------------------------------------- /session_2/flash_attention_[annotated].pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_2/flash_attention_[annotated].pdf -------------------------------------------------------------------------------- /session_2/requirements.txt: -------------------------------------------------------------------------------- 1 | torch==2.4.0 2 | triton==3.0.0 -------------------------------------------------------------------------------- /session_3/README.md: -------------------------------------------------------------------------------- 1 | # Session 3: ZeRO: Memory Optimizations Toward Training Trillion Parameter Models 2 | 3 | In session 3 we covered the paper "ZeRO: Memory Optimizations Toward Training Trillion Parameter Models." 4 | 5 | - [Paper](https://arxiv.org/abs/1910.02054) 6 | - [Slides](https://docs.google.com/presentation/d/12QxDBFdrJeG2DrBuYsHyUIx3fEqKV1zrUeO8vDlaWYk/edit?usp=sharing) 7 | - [Recording](https://youtu.be/azUufxKe5RE?si=X0YefzEi0R62IZR7) 8 | -------------------------------------------------------------------------------- /session_4/README.md: -------------------------------------------------------------------------------- 1 | # Session 4: Ring Attention with Blockwise Transformers for Near-Infinite Context Length 2 | 3 | EleutherAI ML Scalability & Performance Reading Group Session 4 recording, in which we covered the seminal Ring Attention paper. We also cover 2 key pieces of prior work which provide the foundation for ring attention, to understand what the limitations were of those prior approaches and how ring attention built on them to unlock massive gains in max sequence length for transformer models. 4 | 5 | **Presenter**: Daniel Vega-Myhre 6 | 7 | Papers: 8 | 1. Sequence Parallelism: Long Sequence Training from System Perspective (https://aclanthology.org/2023.acl-long.134.pdf) 9 | 2. Blockwise Parallel Transformer for Large Context Models (https://arxiv.org/abs/2305.19370) 10 | 3. Ring Attention with Blockwise Transformers for Near-Infinite Context (https://arxiv.org/abs/2310.01889) 11 | 12 | ### Links: 13 | - [Slides](https://docs.google.com/presentation/d/1mQQJf_aFqKUewRM97d0xAQQrGLmsnMQIjmO_dovYlWs/edit?usp=sharing) 14 | - [Recording](https://youtu.be/fC9L8J7dVFI?si=3pfS2C3p0hTUDX5y) 15 | - [Annotated sequence parallelism paper](./sequence_parallelism_[annotated].pdf) 16 | - [Annotated blockwise transformers paper](./blockwise_transformers_[annotated].pdf) 17 | - [Annotated ring attention paper](./ring_attention_[annotated].pdf) 18 | -------------------------------------------------------------------------------- /session_4/blockwise_transformers_[annotated].pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_4/blockwise_transformers_[annotated].pdf -------------------------------------------------------------------------------- /session_4/ring_attention_[annotated].pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_4/ring_attention_[annotated].pdf -------------------------------------------------------------------------------- /session_4/sequence_parallelism_[annotated].pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_4/sequence_parallelism_[annotated].pdf -------------------------------------------------------------------------------- /session_5/README.md: -------------------------------------------------------------------------------- 1 | # Session 5: Efficient Memory Management for Large Language Model Serving with PagedAttention 2 | 3 | EleutherAI ML Scalability & Performance Reading Group Session 5, in which we covered Paged Attention. 4 | 5 | **Presenter**: Kunjan Patel 6 | 7 | ### Links: 8 | - [Paper](https://arxiv.org/pdf/2501.12948) 9 | - [Recording](https://www.youtube.com/watch?v=ClUD1XokM_A) 10 | -------------------------------------------------------------------------------- /session_5/paged_attention_[annotated].pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_5/paged_attention_[annotated].pdf -------------------------------------------------------------------------------- /session_6/README.md: -------------------------------------------------------------------------------- 1 | # Session 6: Zero Bubble Pipeline Parallelism 2 | 3 | EleutherAI ML Scalability & Performance Reading Group Session 6, in which we did a deep dive on pipeline parallelism. Specifically, we covered 3 papers: 4 | 5 | 1. [GPipe: Efficient Training of Giant Neural Networks using Pipeline Parallelism](https://arxiv.org/abs/1811.06965) 6 | 2. [PipeDream: Fast and Efficient Pipeline Parallel DNN Training](https://arxiv.org/abs/1806.03377) 7 | 3. [Zero Bubble Pipeline Parallelism](https://arxiv.org/abs/2401.10241) 8 | 9 | **Presenter**: Daniel Vega-Myhre 10 | 11 | - [Recording](https://youtu.be/4wTuGkiob7o?si=0220XGvka5GowxVF) 12 | - [Annotated Gpipe paper](./gpipe_[annotated].pdf) 13 | - [Annotated PipeDream paper](./pipe_dream_[annotated].pdf) 14 | - [Annotated Zero Bubble paper](./zero_bubble_pipeline_parallelism_[annotated].pdf) 15 | -------------------------------------------------------------------------------- /session_6/gpipe_[annotated].pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_6/gpipe_[annotated].pdf -------------------------------------------------------------------------------- /session_6/pipe_dream_[annotated].pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_6/pipe_dream_[annotated].pdf -------------------------------------------------------------------------------- /session_6/zero_bubble_pipeline_parallelism_[annotated].pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_6/zero_bubble_pipeline_parallelism_[annotated].pdf -------------------------------------------------------------------------------- /session_7/README.md: -------------------------------------------------------------------------------- 1 | # Session 7: DeepSeek V3 2 | 3 | EleutherAI ML Scalability & Performance Reading Group Session 7, where we covered the DeepSeek V3 paper. We also discussed some parts of the DeepSeek V2 paper for comparison. 4 | 5 | **Presenter**: Daniel Vega-Myhre 6 | 7 | ### Papers: 8 | 1. [DeepSeek V3](https://arxiv.org/abs/2412.19437) 9 | 2. [DeepSeek V2](https://arxiv.org/pdf/2405.04434) 10 | 11 | ### Links: 12 | - [Recording](https://youtu.be/hPXTRZ9A-9M?si=4G3bIc6LFy3yhd6S) 13 | - [Annotated DeepSeek V3 paper](./deepseek-v3_[annotated].pdf) 14 | - [Annotated DeepSeek V2 paper](./deepseek-v2_[annotated].pdf) -------------------------------------------------------------------------------- /session_7/deepseek-v2_[annotated].pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_7/deepseek-v2_[annotated].pdf -------------------------------------------------------------------------------- /session_7/deepseek-v3_[annotated].pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_7/deepseek-v3_[annotated].pdf -------------------------------------------------------------------------------- /session_8/README.md: -------------------------------------------------------------------------------- 1 | # Session 8: Megatron-LM 2 | 3 | EleutherAI ML Scalability & Performance Reading Group Session 8, where we covered the Megatron-LM paper, which introduced tensor parallelism. 4 | 5 | **Presenter**: Daniel Vega-Myhre 6 | 7 | ### Papers: 8 | 1. [Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism](https://arxiv.org/abs/1909.08053) 9 | 10 | ### Links: 11 | - [Recording](https://youtu.be/ImKyR1tsPPE?si=bBfXyagsjk1d8Hd2) 12 | - [Annotated paper](./megatron_annotated.pdf) 13 | - [Excalidraw diagrams](./megatron-diagrams.excalidraw) 14 | -------------------------------------------------------------------------------- /session_8/megatron_annotated.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_8/megatron_annotated.pdf -------------------------------------------------------------------------------- /session_9/README.md: -------------------------------------------------------------------------------- 1 | # Session 9: Reducing Activation Recomputation in Large Transformer Models 2 | 3 | EleutherAI ML Scalability & Performance Reading Group Session 9, which builds on the TP strategy introduced in Megatron-LM with some additional techniques: sequence parallelism and selective activation recomputation. 4 | 5 | **Presenter**: Daniel Vega-Myhre 6 | 7 | ### Papers: 8 | 1. [Reducing Activation Recomputation in Large Transformer Models](https://arxiv.org/abs/2205.05198) 9 | 10 | ### Links: 11 | - [Recording](https://www.youtube.com/watch?v=9o2TXexHUh8) 12 | - [Annotated paper](./reducing_activation_recomputation_[annotated].pdf) 13 | -------------------------------------------------------------------------------- /session_9/reducing_activation_recomputation_[annotated].pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielvegamyhre/ml-perf-reading-group/319c489e02ea75d3634e91544afebc3667be9c5e/session_9/reducing_activation_recomputation_[annotated].pdf --------------------------------------------------------------------------------