{"id":27745,"library":"flow-matching","title":"Flow Matching","description":"Flow Matching for Generative Modeling, a library by Meta Research for training continuous normalizing flows via flow matching objectives. Current version 1.0.10, supports Python >=3.9, actively maintained.","status":"active","version":"1.0.10","language":"python","source_language":"en","source_url":"https://github.com/facebookresearch/flow_matching","tags":["flow matching","generative modeling","continuous normalizing flows","conditional flow matching","meta","facebook research"],"install":[{"cmd":"pip install flow-matching","lang":"bash","label":"PyPI installation"}],"dependencies":[{"reason":"Core dependency for tensor operations and neural networks.","package":"torch","optional":false},{"reason":"Used for ODE solvers in sampling.","package":"torchdiffeq","optional":false}],"imports":[{"note":"","wrong":null,"symbol":"FlowMatching","correct":"from flow_matching import FlowMatching"},{"note":"Common mistake: trying to import from submodule `models`","wrong":"from flow_matching.models import CNF","symbol":"CNF","correct":"from flow_matching import CNF"},{"note":"","wrong":null,"symbol":"CondOTFlowMatching","correct":"from flow_matching import CondOTFlowMatching"},{"note":"","wrong":null,"symbol":"FMObjective","correct":"from flow_matching.objectives import FMObjective"}],"quickstart":{"code":"import torch\nfrom flow_matching import CondOTFlowMatching\nfrom flow_matching.objectives import FMObjective\n\ndim = 2\nflow = CondOTFlowMatching(dim=dim)\nobjective = FMObjective(flow)\n\nx0 = torch.randn(100, dim)\nx1 = torch.randn(100, dim)\nt = torch.rand(100)\nloss = objective(x0, x1, t)\nprint(f\"Loss: {loss.item()}\")","lang":"python","description":"Minimal example: create a flow matching model, compute the flow matching objective between random source and target samples."},"warnings":[{"fix":"Update imports: use `from flow_matching import CondOTFlowMatching` instead of old `from flow_matching import FlowMatching`.","message":"As of v1.0.0, the API was completely rewritten. Imports like `from flow_matching import FlowMatching` now return a high-level wrapper, not the old `CNF` class. If upgrading from <1.0, review all imports.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Replace `from flow_matching.models import CNF` with `from flow_matching import CondOTFlowMatching`.","message":"The `models.CNF` class is deprecated since v1.0.0. Use `CondOTFlowMatching` or other specific flow matching classes.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure tensors are float32: `x0 = x0.float()`.","message":"The library expects input tensors (x0, x1) to have dtype `torch.float32`. Using float64 may cause silent errors or performance degradation.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `from flow_matching import CondOTFlowMatching` (or another specific flow class) instead of `from flow_matching import FlowMatching`.","cause":"Importing the high-level wrapper incorrectly after v1.0.0, or using outdated documentation.","error":"AttributeError: module 'flow_matching' has no attribute 'FlowMatching'"},{"fix":"Check the constructor signature: for `CondOTFlowMatching(input_dim=2)`, or simply omit `dim` and set it later.","cause":"Passing the old `dim` parameter to a class that expects different arguments (e.g., `CondOTFlowMatching` does not take `dim` directly; it takes `input_dim` in some versions, or defaults to 2).","error":"TypeError: __init__() got an unexpected keyword argument 'dim'"},{"fix":"Move model and tensors to same device: `model = CondOTFlowMatching(dim=2).to(device); x0 = x0.to(device); x1 = x1.to(device)`.","cause":"Model parameters and input tensors are on different devices (CPU vs GPU).","error":"RuntimeError: Expected all tensors to be on the same device, but found at least two devices"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}