{"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/packing-input-frame-context-in-next-frame","title":"Packing Input Frame Context in Next-Frame Prediction Models for Video Generation","arxiv_id":"2504.12626","date":"2025-04-17","proceeding":null,"authors":["Lvmin Zhang","Maneesh Agrawala"],"abstract":"We present a neural network structure, FramePack, to train next-frame (or next-frame-section) prediction models for video generation. The FramePack compresses input frames to make the transformer context length a fixed number regardless of the video length. As a result, we are able to process a large number of frames using video diffusion with computation bottleneck similar to image diffusion. This also makes the training video batch sizes significantly higher (batch sizes become comparable to image diffusion training). We also propose an anti-drifting sampling method that generates frames in inverted temporal order with early-established endpoints to avoid exposure bias (error accumulation over iterations). Finally, we show that existing video diffusion models can be finetuned with FramePack, and their visual quality may be improved because the next-frame prediction supports more balanced diffusion schedulers with less extreme flow shift timesteps.","url_abs":"https://arxiv.org/abs/2504.12626v2","url_pdf":"https://arxiv.org/pdf/2504.12626v2.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":"packing-input-frame-context-in-next-frame","repo_url":"https://github.com/lllyasviel/framepack","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2504.12626","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2504.12626"}},"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/lllyasviel/framepack","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"unverified":14},"by_repo_kind":{"official":{"samples":14,"ran":0,"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":0,"samples":[{"code_sha256_prefix":"17947376b69ae7ea","entry":"FP32LayerNorm_forward","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/dit_common.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/dit_common.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"17947376b69ae7ea"}},{"code_sha256_prefix":"9aefa550d3303fb4","entry":"LayerNorm_forward","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/dit_common.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/dit_common.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"9aefa550d3303fb4"}},{"code_sha256_prefix":"732e021494e2f8c5","entry":"RMSNorm_forward","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/dit_common.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/dit_common.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"732e021494e2f8c5"}},{"code_sha256_prefix":"d28cb0cf9c815511","entry":"center_down_sample_3d","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/models/hunyuan_video_packed.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/models/hunyuan_video_packed.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"d28cb0cf9c815511"}},{"code_sha256_prefix":"01d320e654a2e8ec","entry":"d_resize","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/utils.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"01d320e654a2e8ec"}},{"code_sha256_prefix":"4d63df096ac49302","entry":"find_nearest_bucket","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/bucket_tools.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/bucket_tools.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4d63df096ac49302"}},{"code_sha256_prefix":"afa41a34c296ad8c","entry":"get_cu_seqlens","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/models/hunyuan_video_packed.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/models/hunyuan_video_packed.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"afa41a34c296ad8c"}},{"code_sha256_prefix":"8878ab71c5517be6","entry":"hf_clip_vision_encode","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/clip_vision.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/clip_vision.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"8878ab71c5517be6"}},{"code_sha256_prefix":"4539e91c8bf77422","entry":"make_progress_bar_html","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/gradio/progress_bar.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/gradio/progress_bar.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4539e91c8bf77422"}},{"code_sha256_prefix":"40c2f7e6a842657c","entry":"min_resize","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/utils.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"40c2f7e6a842657c"}},{"code_sha256_prefix":"99503c6805b5ab97","entry":"pad_for_3d_conv","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/models/hunyuan_video_packed.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/models/hunyuan_video_packed.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"99503c6805b5ab97"}},{"code_sha256_prefix":"340c4fad0518eeca","entry":"resize_and_center_crop","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/utils.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"340c4fad0518eeca"}},{"code_sha256_prefix":"2f75f7f751f85b38","entry":"vae_decode","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/hunyuan.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/hunyuan.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"2f75f7f751f85b38"}},{"code_sha256_prefix":"cdadf30b87b895d4","entry":"vae_decode_fake","repo":"lllyasviel/framepack","repo_kind":"official","path":"diffusers_helper/hunyuan.py","file_url":"https://github.com/lllyasviel/framepack/blob/HEAD/diffusers_helper/hunyuan.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"cdadf30b87b895d4"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}