{"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/scaling-diffusion-language-models-via","title":"Scaling Diffusion Language Models via Adaptation from Autoregressive Models","arxiv_id":"2410.17891","date":"2024-10-23","proceeding":null,"authors":["Shansan Gong","Shivam Agarwal","Yizhe Zhang","Jiacheng Ye","Lin Zheng","Mukai Li","Chenxin An","Peilin Zhao","Wei Bi","Jiawei Han","Hao Peng","Lingpeng Kong"],"abstract":"Diffusion Language Models (DLMs) have emerged as a promising new paradigm for text generative modeling, potentially addressing limitations of autoregressive (AR) models. However, current DLMs have been studied at a smaller scale compared to their AR counterparts and lack fair comparison on language modeling benchmarks. Additionally, training diffusion models from scratch at scale remains challenging. Given the prevalence of open-source AR language models, we propose adapting these models to build text diffusion models. We demonstrate connections between AR and diffusion modeling objectives and introduce a simple continual pre-training approach for training diffusion models. Through systematic evaluation on language modeling, reasoning, and commonsense benchmarks, we show that we can convert AR models ranging from 127M to 7B parameters (GPT2 and LLaMA) into diffusion models DiffuGPT and DiffuLLaMA, using less than 200B tokens for training. Our experimental results reveal that these models outperform earlier DLMs and are competitive with their AR counterparts. We release a suite of DLMs (with 127M, 355M, and 7B parameters) capable of generating fluent text, performing in-context learning, filling in the middle without prompt re-ordering, and following instructions \\url{https://github.com/HKUNLP/DiffuLLaMA}.","url_abs":"https://arxiv.org/abs/2410.17891v1","url_pdf":"https://arxiv.org/pdf/2410.17891v1.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":"scaling-diffusion-language-models-via","repo_url":"https://github.com/hkunlp/diffullama","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"in-context-learning","task_name":"In-Context Learning"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2410.17891","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.17891"}},"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/HKUNLP/DiffuLLaMA","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/hkunlp/diffullama","reach":{"status":"ok"}}],"summary":{"ran_fixture":1,"ran_draft_wrong":3,"ran":1,"ran_honours":1,"unverified":16},"by_repo_kind":{"official":{"samples":22,"ran":6,"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":22,"samples":[{"code_sha256_prefix":"30d7eec482ebf6b1","entry":"repeat_kv","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/model_llama.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/model_llama.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":2,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"30d7eec482ebf6b1"}},{"code_sha256_prefix":"bac65c3dafaec040","entry":"apply_rotary_pos_emb","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/model_llama.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/model_llama.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"bac65c3dafaec040"}},{"code_sha256_prefix":"fa298642043e1282","entry":"code","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/packed_dataset.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/packed_dataset.py","link_basis":"harvester_set","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":"fa298642043e1282"}},{"code_sha256_prefix":"ce7333f42d88b05d","entry":"maybe_get_set_global_memory_buffer","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/dist_flash_attn/async_communication.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/dist_flash_attn/async_communication.py","link_basis":"plan_row","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ce7333f42d88b05d"}},{"code_sha256_prefix":"ee03eab03d798c57","entry":"maybe_get_set_global_memory_buffer_bwd","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/dist_flash_attn/async_communication.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/dist_flash_attn/async_communication.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ee03eab03d798c57"}},{"code_sha256_prefix":"b99eea6376d1e212","entry":"rotate_half","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/model_llama.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/model_llama.py","link_basis":"harvester_set","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":"b99eea6376d1e212"}},{"code_sha256_prefix":"59adcbbcc9bf1cbc","entry":"checkpoint_end_with_flash_attention","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/dist_flash_attn/monkey_patch.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/dist_flash_attn/monkey_patch.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":"59adcbbcc9bf1cbc"}},{"code_sha256_prefix":"7517e14a19d34e0f","entry":"checkpoint_last_module","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/dist_flash_attn/monkey_patch.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/dist_flash_attn/monkey_patch.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":"7517e14a19d34e0f"}},{"code_sha256_prefix":"64ec6a16fb572f44","entry":"extract_local","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/dist_flash_attn/prepare_input.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/dist_flash_attn/prepare_input.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":"64ec6a16fb572f44"}},{"code_sha256_prefix":"5e09c24645115dd9","entry":"extract_local","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/ulysses_attn/prepare_inputs.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/ulysses_attn/prepare_inputs.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":"5e09c24645115dd9"}},{"code_sha256_prefix":"2d05c810fd8d785d","entry":"generate_samples","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"model.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/model.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":"2d05c810fd8d785d"}},{"code_sha256_prefix":"ee7bd71eac25f44d","entry":"get_anneal_attn_mask","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"evaluation/eval-diffullama.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/evaluation/eval-diffullama.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":"ee7bd71eac25f44d"}},{"code_sha256_prefix":"89e4348b4cb177bd","entry":"get_flash_attn_out_from_global_buffer","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/dist_flash_attn/monkey_patch.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/dist_flash_attn/monkey_patch.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":"89e4348b4cb177bd"}},{"code_sha256_prefix":"4be6bef6c83e9c27","entry":"is_last_time","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/dist_flash_attn/async_communication.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/dist_flash_attn/async_communication.py","link_basis":"plan_row","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":"4be6bef6c83e9c27"}},{"code_sha256_prefix":"d7b82e7e46f9cee8","entry":"maybe_repeat_kv_bwd","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/dist_flash_attn/lightseq_async_attn.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/dist_flash_attn/lightseq_async_attn.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":"d7b82e7e46f9cee8"}},{"code_sha256_prefix":"3d82586ab3888495","entry":"maybe_repeat_kv_fwd","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/dist_flash_attn/lightseq_async_attn.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/dist_flash_attn/lightseq_async_attn.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":"3d82586ab3888495"}},{"code_sha256_prefix":"2fcefe3ddd3fa8eb","entry":"new_decoder_forward","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/ulysses_attn/monkey_patch.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/ulysses_attn/monkey_patch.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":"2fcefe3ddd3fa8eb"}},{"code_sha256_prefix":"9949ec185b470d6e","entry":"new_flash_attn_forward","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/ulysses_attn/monkey_patch.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/ulysses_attn/monkey_patch.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":"9949ec185b470d6e"}},{"code_sha256_prefix":"9daba25cd657ac06","entry":"prepare_dist_flash_attn_inputs","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/dist_flash_attn/prepare_input.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/dist_flash_attn/prepare_input.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":"9daba25cd657ac06"}},{"code_sha256_prefix":"737366305cfbf977","entry":"prepare_ulysses_attn_inputs","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"DiffuLLaMA-training/easy_context/ulysses_attn/prepare_inputs.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/DiffuLLaMA-training/easy_context/ulysses_attn/prepare_inputs.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":"737366305cfbf977"}},{"code_sha256_prefix":"dd2d39c8d8eff4d5","entry":"preprocess","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"evaluation/eval-diffullama.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/evaluation/eval-diffullama.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":"dd2d39c8d8eff4d5"}},{"code_sha256_prefix":"fd2fe76b57111989","entry":"top_p_logits","repo":"HKUNLP/DiffuLLaMA","repo_kind":"official","path":"evaluation/eval-diffullama.py","file_url":"https://github.com/HKUNLP/DiffuLLaMA/blob/HEAD/evaluation/eval-diffullama.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":"fd2fe76b57111989"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}