{"id":15600941,"url":"https://github.com/lucidrains/mmdit","last_synced_at":"2026-01-18T10:24:01.665Z","repository":{"id":238142633,"uuid":"795967513","full_name":"lucidrains/mmdit","owner":"lucidrains","description":"Implementation of a single layer of the MMDiT, proposed in Stable Diffusion 3, in Pytorch","archived":false,"fork":false,"pushed_at":"2025-01-12T18:04:29.000Z","size":160,"stargazers_count":449,"open_issues_count":3,"forks_count":12,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-25T02:22:11.863Z","etag":null,"topics":["artificial-intelligence","attention-mechanisms","deep-learning","multi-modal-attention"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucidrains.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-04T14:38:14.000Z","updated_at":"2025-09-24T23:01:42.000Z","dependencies_parsed_at":"2024-05-04T15:50:54.143Z","dependency_job_id":"4e421f33-f959-4f33-b11b-a6764c3e745c","html_url":"https://github.com/lucidrains/mmdit","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"2c7137e8e5be8ec345d9beaeec6d26fcea31d83e"},"previous_names":["lucidrains/mmdit"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/lucidrains/mmdit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fmmdit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fmmdit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fmmdit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fmmdit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucidrains","download_url":"https://codeload.github.com/lucidrains/mmdit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fmmdit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T10:13:46.436Z","status":"ssl_error","status_checked_at":"2026-01-18T10:13:11.045Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","attention-mechanisms","deep-learning","multi-modal-attention"],"created_at":"2024-10-03T02:09:52.935Z","updated_at":"2026-01-18T10:24:01.638Z","avatar_url":"https://github.com/lucidrains.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./mmdit.png\" width=\"300px\"\u003e\u003c/img\u003e\n\n## MMDiT\n\nImplementation of a single layer of the MMDiT, proposed by Esser et al. in \u003ca href=\"https://arxiv.org/abs/2403.03206\"\u003eStable Diffusion 3\u003c/a\u003e, in Pytorch\n\nBesides a straight reproduction, will also generalize to \u003e 2 modalities, as I can envision an MMDiT for images, audio, and text.\n\nWill also offer an \u003ca href=\"https://github.com/lucidrains/mmdit/blob/main/mmdit/adaptive_attention.py\"\u003eimprovised variant of self attention\u003c/a\u003e that adaptively selects the weights to use through learned gating. This idea came from adaptive convolutions applied by Kang et al. for GigaGAN.\n\n## Install\n\n```bash\n$ pip install mmdit\n```\n\n## Usage\n\n```python\nimport torch\nfrom mmdit import MMDiTBlock\n\n# define mm dit block\n\nblock = MMDiTBlock(\n    dim_cond = 256,\n    dim_text = 768,\n    dim_image = 512,\n    qk_rmsnorm = True\n)\n\n# mock inputs\n\ntime_cond = torch.randn(2, 256)\n\ntext_tokens = torch.randn(2, 512, 768)\ntext_mask = torch.ones((2, 512)).bool()\n\nimage_tokens = torch.randn(2, 1024, 512)\n\n# single block forward\n\ntext_tokens_next, image_tokens_next = block(\n    time_cond = time_cond,\n    text_tokens = text_tokens,\n    text_mask = text_mask,\n    image_tokens = image_tokens\n)\n```\n\nA generalized version can be used as so\n\n```python\nimport torch\nfrom mmdit.mmdit_generalized_pytorch import MMDiT\n\nmmdit = MMDiT(\n    depth = 2, \n    dim_modalities = (768, 512, 384),\n    dim_cond = 256,\n    qk_rmsnorm = True\n)\n\n# mock inputs\n\ntime_cond = torch.randn(2, 256)\n\ntext_tokens = torch.randn(2, 512, 768)\ntext_mask = torch.ones((2, 512)).bool()\n\nvideo_tokens = torch.randn(2, 1024, 512)\n\naudio_tokens = torch.randn(2, 256, 384)\n\n# forward\n\ntext_tokens, video_tokens, audio_tokens = mmdit(\n    modality_tokens = (text_tokens, video_tokens, audio_tokens),\n    modality_masks = (text_mask, None, None),\n    time_cond = time_cond,\n)\n```\n\n## Citations\n\n```bibtex\n@article{Esser2024ScalingRF,\n    title   = {Scaling Rectified Flow Transformers for High-Resolution Image Synthesis},\n    author  = {Patrick Esser and Sumith Kulal and A. Blattmann and Rahim Entezari and Jonas Muller and Harry Saini and Yam Levi and Dominik Lorenz and Axel Sauer and Frederic Boesel and Dustin Podell and Tim Dockhorn and Zion English and Kyle Lacey and Alex Goodwin and Yannik Marek and Robin Rombach},\n    journal = {ArXiv},\n    year    = {2024},\n    volume  = {abs/2403.03206},\n    url     = {https://api.semanticscholar.org/CorpusID:268247980}\n}\n```\n\n```bibtex\n@inproceedings{Darcet2023VisionTN,\n    title   = {Vision Transformers Need Registers},\n    author  = {Timoth'ee Darcet and Maxime Oquab and Julien Mairal and Piotr Bojanowski},\n    year    = {2023},\n    url     = {https://api.semanticscholar.org/CorpusID:263134283}\n}\n```\n\n```bibtex\n@article{Zhu2024HyperConnections,\n    title   = {Hyper-Connections},\n    author  = {Defa Zhu and Hongzhi Huang and Zihao Huang and Yutao Zeng and Yunyao Mao and Banggu Wu and Qiyang Min and Xun Zhou},\n    journal = {ArXiv},\n    year    = {2024},\n    volume  = {abs/2409.19606},\n    url     = {https://api.semanticscholar.org/CorpusID:272987528}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fmmdit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucidrains%2Fmmdit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fmmdit/lists"}