{"id":17795601,"url":"https://github.com/dirmeier/consistency-flow-matching","last_synced_at":"2025-06-25T00:02:49.837Z","repository":{"id":258183217,"uuid":"853534469","full_name":"dirmeier/consistency-flow-matching","owner":"dirmeier","description":"Flow and consistency matching in Flax","archived":false,"fork":false,"pushed_at":"2024-10-16T11:05:50.000Z","size":1033,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T17:24:25.840Z","etag":null,"topics":["consistency-matching","flax","flow-matching","jax","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/dirmeier.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-09-06T21:14:57.000Z","updated_at":"2025-02-14T16:39:56.000Z","dependencies_parsed_at":"2024-10-17T23:41:59.519Z","dependency_job_id":"ee3a4a00-0910-4df6-95d5-8cc64f9f882e","html_url":"https://github.com/dirmeier/consistency-flow-matching","commit_stats":null,"previous_names":["dirmeier/consistency-flow-matching"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dirmeier/consistency-flow-matching","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fconsistency-flow-matching","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fconsistency-flow-matching/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fconsistency-flow-matching/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fconsistency-flow-matching/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirmeier","download_url":"https://codeload.github.com/dirmeier/consistency-flow-matching/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fconsistency-flow-matching/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261777416,"owners_count":23208113,"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":["consistency-matching","flax","flow-matching","jax","python"],"created_at":"2024-10-27T11:35:22.458Z","updated_at":"2025-06-25T00:02:49.602Z","avatar_url":"https://github.com/dirmeier.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Consistency flow matching\n\n[![status](http://www.repostatus.org/badges/latest/concept.svg)](http://www.repostatus.org/#concept)\n[![ci](https://github.com/dirmeier/consistency-flow-matching/actions/workflows/ci.yaml/badge.svg)](https://github.com/dirmeier/consistency-flow-matching/actions/workflows/ci.yaml)\n\n\u003e Flow-matching, consistency-matching, and consistency-flow-matching implementations in Flax\n\n## About\n\nThis repository implements\n\n- Rectified flow matching (from [Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow](https://arxiv.org/abs/2209.03003)),\n- Consistency matching (from [Consistency models](https://arxiv.org/abs/2303.01469)),\n- Consistency flow matching (from [Consistency Flow Matching: Defining Straight Flows with Velocity Consistency](https://arxiv.org/abs/2407.02398)),\n- Elucidated denoising diffusion (from [Elucidating the Design Space of Diffusion-Based Generative Models](https://arxiv.org/abs/2206.00364))\n\nusing JAX and Flax. The methods are mainly implemented to compare consistency flow matching\nwith the other three approaches, so there is only some limited functionality. As score network architectures (or vector fields), we provide implementations of the U-Net\nused in [DDPM++](https://arxiv.org/abs/2011.13456) and the [diffusion transformer](https://arxiv.org/abs/2212.09748).\n\n## Example usage\n\nThe `experiments` folder contains example code that can be used to train one of the generative models on CIFAR10.\nDepending on what method you want to use, call:\n\n```bash\ncd experiments/cifar10\npython main.py\n  --config=config.py\n  --config.model=\u003cdenoising_diffusion|flow_matching|consistency_matching|consistency_flow_matching\u003e\n  --config.score_net=\u003cunet|dit\u003e\n  --workdir=\u003cdir\u003e\n  (--usewand)\n```\n\nI compared samples from a consistency flow matcher (CFM) to those of a rectified flow matcher (RFM) and a elucidated diffusion model (EDM).\nAs a baseline, the EDM uses a Heun solver using 25 steps (i.e., 50 function evaluations (FEs)).\nThe RFM uses an Euler solver with 25 steps (which is technically not necessary since the trajectories are linear).\nThe CFM uses an Euler solver with 10 steps (which is fair since it is the entire point of using consistency matching).\n\nI tested various parameterizations for all three models (including the ones described in the original publications).\nIn the end, I trained all models for\n\n- 500 000 steps using an Adam optimizer with 1000 linear steps of warmup and a cosine decay schedule,\n- batch size of 512,\n- a U-Net with 128 base channels, and which uses attention at a resolution of 16 and [1, 2, 2, 2] channel multipliers.\n- EMA decay rates of 0.999 and 0.999999 (as in the CFM paper).\n\nSome observations:\n\n- Both the EDM and RFM generate high-quality samples after as few as 50k training steps.\n- The EDM and RFM are extremely robust to different parameterizations.\n- No matter the parameterization of the CFM (including the EMA decay rate) I **cannot reproduce the results of the paper**.\n  The parameterization is either very fragile or I have a bug (if you find one [here](cfm/consistency_flow_matching.py), please report it).\n- The CFM, at least in my experiments, does not converge faster than EDM/RFM (which is one of the claims of the paper).\n\nBelow are some samples from a trained RFM after 100 000 steps. The samples if an EDM have visually the same quality:\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"experiments/cifar10/figures/rfm-samples.png\" width=\"700\"\u003e\n\u003c/div\u003e\n\n## Installation\n\nTo install the latest GitHub \u003cRELEASE\u003e, just call the following on the command line:\n\n```bash\npip install git+https://github.com/dirmeier/consistency-flow-matching@\u003cRELEASE\u003e\n```\n\nYou can also download the latest \u003cRELEASE\u003e and install using `rye`\n```shell\nrye sync\n```\n\n## Author\n\nSimon Dirmeier \u003ca href=\"mailto:sfyrbnd @ pm me\"\u003esfyrbnd @ pm me\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirmeier%2Fconsistency-flow-matching","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirmeier%2Fconsistency-flow-matching","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirmeier%2Fconsistency-flow-matching/lists"}