Generative Flow Networks (GFlowNets) have emerged as a powerful family of algorithms for training sequential samplers of discrete objects, such as molecular graphs or DNA sequences. They are designed to sample these objects with a probability proportional to a given unnormalized target density (or reward). However, training GFlowNets effectively has historically been hindered by a fundamental bias-variance tradeoff in their training objectives.
This paper introduces Subtrajectory Balance (SubTB), a novel training objective inspired by the TD($\lambda$) algorithm in reinforcement learning. By learning from partial sequences of varying lengths, SubTB effectively balances this tradeoff, leading to faster convergence, better stability, and superior performance in complex, long-sequence tasks like drug discovery and protein design.
The Credit Assignment Problem: Local vs. Global Objectives
Training a GFlowNet requires assigning credit to the sequential actions that lead to a final generated object. Existing methods typically fall into two extremes:
- Detailed Balance (DB): These objectives are strictly "local," evaluating single transitions. While they benefit from low variance, they suffer from high bias and slow credit assignment. It takes a significant amount of time for the reward signal at the end of a sequence to propagate back to the initial steps.
- Trajectory Balance (TB): In contrast, TB looks at the entire episode. This allows for rapid credit assignment (low bias) but introduces extremely high gradient variance. In environments with long sequences or sparse reward landscapes, the training signal becomes too noisy to be effective.
The authors identify this dynamic as a classic bias-variance tradeoff and propose a solution that captures the advantages of both approaches.
Subtrajectory Balance: A "Goldilocks" Solution
To bridge the gap between DB and TB, the authors propose Subtrajectory Balance (SubTB($\lambda$)). Instead of forcing a choice between a single step and the entire path, SubTB considers all possible subtrajectories within an episode.
The objective enforces a consistency constraint: the flow at the start of a sub-sequence, multiplied by the forward transition probabilities, must equal the flow at the end of that sub-sequence multiplied by the backward transition probabilities.
Similar to TD($\lambda$) in reinforcement learning, SubTB utilizes a hyperparameter $\lambda$ to weight these subtrajectories:
- As $\lambda \to 0$, the objective recovers the local DB approach.
- As $\lambda \to \infty$, it recovers the global TB approach.
Crucially, while there are a quadratic number of subtrajectories ($O(n^2)$) in an episode of length $n$, the authors demonstrate that calculating the gradient requires only a single forward and backward pass through the neural network. This makes SubTB highly computationally efficient.
Key Insights: Why SubTB Excels
The theoretical and empirical analysis of SubTB reveals several reasons for its success:
- Variance Reduction: The authors mathematically prove that SubTB gradients act as better estimators of the "true" trajectory gradient than TB gradients. By replacing a noisy stochastic term with a learned estimate (the state flow), SubTB reduces variance in a manner akin to actor-critic methods in RL.
- Faster Credit Assignment: By evaluating segments longer than a single step, SubTB propagates reward signals much faster than DB.
- State Flow Generalization: The model learns a "state flow" function that generalizes across the state space faster than the complex policy itself. This helps the model learn effectively even in rarely visited regions.
- Hyperparameter Robustness: SubTB is significantly less sensitive to hyperparameter tuning (such as learning rates) compared to TB, making it much more reliable in practice.
Experimental Validation
The researchers evaluated SubTB across a diverse set of synthetic and real-world benchmarks, including 2D and 4D Hypergrids, small molecule synthesis (binding to the sEH protein), 120-bit sequence generation, and biological sequence design (Antimicrobial Peptides and Green Fluorescent Proteins).
Key Results: * Superior Convergence: On the Hypergrid tasks, SubTB converged faster than TB across all grid sizes. In challenging sparse-reward settings, TB often failed to find all reward modes, whereas SubTB succeeded. * State-of-the-Art in Drug Discovery & Proteins: For molecule and protein generation, SubTB consistently discovered higher-reward and more diverse candidates than TB, DB, and standard RL baselines like Soft Actor-Critic (SAC) or MCMC. * Scalability to Longer Sequences: The advantages of SubTB became increasingly pronounced as sequence lengths grew (e.g., the 237-length GFP task). This establishes SubTB as a highly effective approach for long-form discrete generation.
Future Directions
The introduction of SubTB opens several promising avenues for future research. While the current work uses a specific power-law weighting ($\lambda^{j-i}$) for subtrajectories, exploring alternative weighting schemes could yield further improvements. Additionally, developing a dynamic $\lambda$ parameter—automatically adjusting from low-variance local updates early in training to low-bias global updates later—presents an exciting "learning to learn" opportunity. Finally, because SubTB can learn from partial sequences, it paves the way for training GFlowNets on incomplete episodes, allowing models to learn from fragmented real-world data.
Summary updated