{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/terapipe-token-level-pipeline-parallelism-for","title":"TeraPipe: Token-Level Pipeline Parallelism for Training Large-Scale Language Models","arxiv_id":"2102.07988","date":"2021-02-16","proceeding":null,"authors":["Zhuohan Li","Siyuan Zhuang","Shiyuan Guo","Danyang Zhuo","Hao Zhang","Dawn Song","Ion Stoica"],"abstract":"Model parallelism has become a necessity for training modern large-scale deep language models. In this work, we identify a new and orthogonal dimension from existing model parallel approaches: it is possible to perform pipeline parallelism within a single training sequence for Transformer-based language models thanks to its autoregressive property. This enables a more fine-grained pipeline compared with previous work. With this key idea, we design TeraPipe, a high-performance token-level pipeline parallel algorithm for synchronous model-parallel training of Transformer-based language models. We develop a novel dynamic programming-based algorithm to calculate the optimal pipelining execution scheme given a specific model and cluster configuration. We show that TeraPipe can speed up the training by 5.0x for the largest GPT-3 model with 175 billion parameters on an AWS cluster with 48 p3.16xlarge instances compared with state-of-the-art model-parallel methods. The code for reproduction can be found at https://github.com/zhuohan123/terapipe","url_abs":"https://arxiv.org/abs/2102.07988v2","url_pdf":"https://arxiv.org/pdf/2102.07988v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"terapipe-token-level-pipeline-parallelism-for","repo_url":"https://github.com/zhuohan123/terapipe","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[],"methods":[{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"cosine-annealing","method_name":"Cosine Annealing"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"gpt-3","method_name":"GPT-3"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-cosine-annealing","method_name":"Linear Warmup With Cosine Annealing"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"weight-decay","method_name":"Weight Decay"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2102.07988","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2102.07988"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/zhuohan123/terapipe","reach":null}],"summary":{"ran":3,"ran_draft_wrong":3,"ran_fixture":1,"unverified":1},"by_repo_kind":{"official":{"samples":8,"ran":7,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":8,"samples":[{"code_sha256_prefix":"450bef055393e141","entry":"PipelineRecvOperator","repo":"zhuohan123/terapipe","repo_kind":"official","path":"terapipe.py","file_url":"https://github.com/zhuohan123/terapipe/blob/HEAD/terapipe.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"450bef055393e141"}},{"code_sha256_prefix":"6260211b3b29a9a8","entry":"PipelineSendOperator","repo":"zhuohan123/terapipe","repo_kind":"official","path":"terapipe.py","file_url":"https://github.com/zhuohan123/terapipe/blob/HEAD/terapipe.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6260211b3b29a9a8"}},{"code_sha256_prefix":"f1c69fa3f4d3535a","entry":"TeraPipeBackwardPassHook","repo":"zhuohan123/terapipe","repo_kind":"official","path":"terapipe.py","file_url":"https://github.com/zhuohan123/terapipe/blob/HEAD/terapipe.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f1c69fa3f4d3535a"}},{"code_sha256_prefix":"6f9e8b5bfc4cea67","entry":"grid_slice_batch_and_sequence","repo":"zhuohan123/terapipe","repo_kind":"official","path":"terapipe.py","file_url":"https://github.com/zhuohan123/terapipe/blob/HEAD/terapipe.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6f9e8b5bfc4cea67"}},{"code_sha256_prefix":"49e2a4eb90f7b049","entry":"loss_func","repo":"zhuohan123/terapipe","repo_kind":"official","path":"terapipe.py","file_url":"https://github.com/zhuohan123/terapipe/blob/HEAD/terapipe.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"49e2a4eb90f7b049"}},{"code_sha256_prefix":"b2bdcb303f86d948","entry":"parse_json","repo":"zhuohan123/terapipe","repo_kind":"official","path":"latency_model.py","file_url":"https://github.com/zhuohan123/terapipe/blob/HEAD/latency_model.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b2bdcb303f86d948"}},{"code_sha256_prefix":"6e0fd7b6636892a2","entry":"terapipe_backward_hook","repo":"zhuohan123/terapipe","repo_kind":"official","path":"terapipe.py","file_url":"https://github.com/zhuohan123/terapipe/blob/HEAD/terapipe.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6e0fd7b6636892a2"}},{"code_sha256_prefix":"6ec37d04aa8c8f4e","entry":"TeraPipe","repo":"zhuohan123/terapipe","repo_kind":"official","path":"terapipe.py","file_url":"https://github.com/zhuohan123/terapipe/blob/HEAD/terapipe.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6ec37d04aa8c8f4e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}