{"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/practical-and-asymptotically-exact-1","title":"Practical and Asymptotically Exact Conditional Sampling in Diffusion Models","arxiv_id":"2306.17775","date":"2023-06-30","proceeding":"NeurIPS 2023 11","authors":["Luhuan Wu","Brian L. Trippe","Christian A. Naesseth","David M. Blei","John P. Cunningham"],"abstract":"Diffusion models have been successful on a range of conditional generation tasks including molecular design and text-to-image generation. However, these achievements have primarily depended on task-specific conditional training or error-prone heuristic approximations. Ideally, a conditional generation method should provide exact samples for a broad range of conditional distributions without requiring task-specific training. To this end, we introduce the Twisted Diffusion Sampler, or TDS. TDS is a sequential Monte Carlo (SMC) algorithm that targets the conditional distributions of diffusion models through simulating a set of weighted particles. The main idea is to use twisting, an SMC technique that enjoys good computational efficiency, to incorporate heuristic approximations without compromising asymptotic exactness. We first find in simulation and in conditional image generation tasks that TDS provides a computational statistical trade-off, yielding more accurate approximations with many particles but with empirical improvements over heuristics with as few as two particles. We then turn to motif-scaffolding, a core task in protein design, using a TDS extension to Riemannian diffusion models. On benchmark test cases, TDS allows flexible conditioning criteria and often outperforms the state of the art.","url_abs":"https://arxiv.org/abs/2306.17775v2","url_pdf":"https://arxiv.org/pdf/2306.17775v2.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":"practical-and-asymptotically-exact-1","repo_url":"https://github.com/blt2114/twisted_diffusion_sampler","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"practical-and-asymptotically-exact-1","repo_url":"https://github.com/matsagad/mres-project","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"computational-efficiency","task_name":"Computational Efficiency"},{"task_slug":"conditional-image-generation","task_name":"Conditional Image Generation"},{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"image-inpainting","task_name":"Image Inpainting"},{"task_slug":"protein-design","task_name":"Protein Design"},{"task_slug":"text-to-image-generation-1","task_name":"Text to Image Generation"},{"task_slug":"text-to-image-generation","task_name":"Text-to-Image Generation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2306.17775","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2306.17775"}},"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":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/blt2114/twisted_diffusion_sampler","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/matsagad/mres-project","reach":{"status":"ok"}}],"summary":{"ran":1,"ran_fixture":4,"ran_honours":1,"ran_draft_wrong":3,"unverified":6},"by_repo_kind":{"official":{"samples":15,"ran":9,"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":15,"samples":[{"code_sha256_prefix":"3701427da0a38721","entry":"GaussianDiffusion","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/feynman_kac_image_ddpm.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/feynman_kac_image_ddpm.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":"3701427da0a38721"}},{"code_sha256_prefix":"b079bc5f66fa6be1","entry":"_gaussian_sample","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/feynman_kac_image_ddpm.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/feynman_kac_image_ddpm.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b079bc5f66fa6be1"}},{"code_sha256_prefix":"6cdc8772f5db6f48","entry":"betas_for_alpha_bar","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/smc_diffusion.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/smc_diffusion.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6cdc8772f5db6f48"}},{"code_sha256_prefix":"808add5294122a1b","entry":"get_named_beta_schedule","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/smc_diffusion.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/smc_diffusion.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"808add5294122a1b"}},{"code_sha256_prefix":"ed42e50405c37f23","entry":"log_normal_density","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/feynman_kac_image_ddpm.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/feynman_kac_image_ddpm.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ed42e50405c37f23"}},{"code_sha256_prefix":"76f3e6b2f21ead25","entry":"register_smc_ddpm","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/feynman_kac_image_ddpm.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/feynman_kac_image_ddpm.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"76f3e6b2f21ead25"}},{"code_sha256_prefix":"8ef8149df933accb","entry":"safe_cat","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/feynman_kac_image_ddpm.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/feynman_kac_image_ddpm.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8ef8149df933accb"}},{"code_sha256_prefix":"8a90ea07fbd9c07f","entry":"space_timesteps","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/smc_diffusion.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/smc_diffusion.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8a90ea07fbd9c07f"}},{"code_sha256_prefix":"a466f15d1bc14d6d","entry":"toU8","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/feynman_kac_image_ddpm.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/feynman_kac_image_ddpm.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a466f15d1bc14d6d"}},{"code_sha256_prefix":"7f0e6aaeb9dc3ee6","entry":"SMCDiffusion","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/feynman_kac_image_ddpm.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/feynman_kac_image_ddpm.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":"7f0e6aaeb9dc3ee6"}},{"code_sha256_prefix":"92ef673835824b55","entry":"SpacedDiffusion","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/feynman_kac_image_ddpm.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/feynman_kac_image_ddpm.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":"92ef673835824b55"}},{"code_sha256_prefix":"16fd5c664243407d","entry":"TwistedDDPM","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/feynman_kac_image_ddpm.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/feynman_kac_image_ddpm.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":"16fd5c664243407d"}},{"code_sha256_prefix":"6dc16bb5110560e8","entry":"imwrite","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/feynman_kac_image_ddpm.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/feynman_kac_image_ddpm.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":"6dc16bb5110560e8"}},{"code_sha256_prefix":"ca226e96f524b276","entry":"smc_FK","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"smc_utils/feynman_kac_pf.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/smc_utils/feynman_kac_pf.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":"ca226e96f524b276"}},{"code_sha256_prefix":"7b4d7a725b4e36e8","entry":"visualize_weights","repo":"blt2114/twisted_diffusion_sampler","repo_kind":"official","path":"image_exp/image_diffusion/feynman_kac_image_ddpm.py","file_url":"https://github.com/blt2114/twisted_diffusion_sampler/blob/HEAD/image_exp/image_diffusion/feynman_kac_image_ddpm.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":"7b4d7a725b4e36e8"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}