{"id":21135245,"url":"https://github.com/cloneofsimo/minrf","last_synced_at":"2025-07-15T16:31:56.260Z","repository":{"id":238069606,"uuid":"795806214","full_name":"cloneofsimo/minRF","owner":"cloneofsimo","description":"Minimal implementation of scalable rectified flow transformers, based on SD3's approach","archived":false,"fork":false,"pushed_at":"2024-07-01T20:26:13.000Z","size":119755,"stargazers_count":519,"open_issues_count":11,"forks_count":47,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-07T16:12:12.563Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloneofsimo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-05-04T05:36:50.000Z","updated_at":"2025-05-06T15:03:12.000Z","dependencies_parsed_at":"2025-04-12T00:45:48.585Z","dependency_job_id":null,"html_url":"https://github.com/cloneofsimo/minRF","commit_stats":null,"previous_names":["cloneofsimo/minrf"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cloneofsimo/minRF","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2FminRF","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2FminRF/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2FminRF/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2FminRF/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloneofsimo","download_url":"https://codeload.github.com/cloneofsimo/minRF/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2FminRF/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265445310,"owners_count":23766447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-20T06:46:54.273Z","updated_at":"2025-07-15T16:31:56.235Z","avatar_url":"https://github.com/cloneofsimo.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minimal Implementation of Scalable Rectified Flow Transformers\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"contents/51.gif\" alt=\"large\" width=\"300\"\u003e\n  \u003cimg src=\"contents/51_ln.gif\" alt=\"large\" width=\"300\"\u003e\n\u003c/p\u003e\n\n\u003e Left is the naive RF, right is the logit-normal time-sampling RF. Both are trained on MNIST.\n\n\nThis repository contains a minimal implementation of the rectified flow models. I've taken [SD3](https://arxiv.org/abs/2403.03206) approach of training along with [LLaMA-DiT](https://github.com/Alpha-VLLM/LLaMA2-Accessory) architecture. [Unlike my previous repo](https://github.com/cloneofsimo/minDiffusion) this time I've decided to split the file into 2: The model implementation and actual code, but you don't have to look at the model code.\n\nEverything is still self-contained, minimal, and hopefully easy to hack. There is nothing complicated goin on if you understood the math.\n\n# 1. *Simple* Rectified Flow, for beginners\n\nInstall torch, pil, torchvision\n\n```\npip install torch torchvision pillow\n```\n\nRun\n\n```bash\npython rf.py\n```\n\nto train the model on MNIST from scratch.\n\nIf you are cool and want to train CIFAR instead, you can do that.\n\n```bash\npython rf.py --cifar\n```\n\nOn 63'th epoch, your output should be something like:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"contents/cifar_63.gif\" alt=\"large\" width=\"300\"\u003e\n  \u003cimg src=\"contents/cifar_63.png\" alt=\"large\" width=\"300\"\u003e\n\u003c/p\u003e\n\n\n# 2. *Massive* Rectified Flow, muP Support\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"advanced/contents/out_IN5.gif\" alt=\"large\" width=\"300\"\u003e\n\u003c/p\u003e\n\nThis is for gigachads who wants to train Imagenet instead. Don't worry! IMO Imagenet is the new MNIST, and we will use my [imagenet.int8](https://huggingface.co/datasets/cloneofsimo/imagenet.int8) dataset for this.\n\nFirst go to advanced dir, download the dataset.\n\n```bash\ncd advanced\npip install hf_transfer # just do install this.\nbash download.sh\n```\n\nThis shouldn't take more than 5 min if your network is decent.\n\nRun\n\n```bash\nbash run.sh\n```\n\nto train the model. This will train Imagenet from scratch, do a muP grid search to find the aligned basin for the loss function, you unlock the zero-shot LR transfer for Rectified Flow models!\n\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"advanced/contents/mup.png\" alt=\"large\" width=\"500\"\u003e\n\u003c/p\u003e\n\nThis uses multiple techniques and codebases I have developed over the year. Its a natural mixture of [min-max-IN-dit](https://github.com/cloneofsimo/min-max-in-dit), [min-max-gpt](https://github.com/cloneofsimo/min-max-gpt), [ez-muP](https://github.com/cloneofsimo/ezmup)\n\n# Citations\n\nIf you use this material, please cite this repository with the following:\n\n```bibtex\n@misc{ryu2024minrf,\n  author       = {Simo Ryu},\n  title        = {minRF: Minimal Implementation of Scalable Rectified Flow Transformers},\n  year         = 2024,\n  publisher    = {Github},\n  url          = {https://github.com/cloneofsimo/minRF},\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloneofsimo%2Fminrf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloneofsimo%2Fminrf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloneofsimo%2Fminrf/lists"}