Official implementation of Modular Flow Matching. This framework leverages a Mixture of Experts (MoE) backbone to decompose complex vector fields into
Core concept: Unlike standard Flow Matching, the architecture partitions the generative process. Each expert specializes in a specific region of the manifold, allowing for Expert Knock-out—the ability to disable specific experts during inference to generate incomplete or ablated vector fields.
🚀 Key Features
Regional Specialization: Using a Gumbel-Softmax gate, the model learns to partition the 2D/3D space so that experts do not overlap in their responsibilities.
Expert Ablation (Knock-out): Since experts are modular, you can manually zero out specific experts during inference to see how the vector field collapses or which parts of the distribution are lost.
Diverse Vector Fields: Implements a Cosine Diversity Loss to ensure experts learn unique directional strategies rather than redundant ones.
Dynamic Gating: Features a temperature-scheduled Gumbel-Softmax to transition from soft exploration to hard, decisive routing during training.
🧠 Architecture Overview
The core model consists of a shared backbone that processes position and time embeddings, followed by a gating network and a set of independent expert heads.
The model learns a vector field
MoE IntegrationThe final velocity is a weighted sum of
Where
🔧 Loss Functions
The training objective is a multi-objective loss designed for modularity:
Flow Matching Loss (
Coefficient of Variation (
Cosine Diversity (
Magnitude Regularization (
📊 Results on 2D Checkerboard
📊 Results On 3D Swiss Roll Data


