Learning GFlowNets from partial episodes for improved convergence and stability

Kanika Madan, Jarrid Rector-Brooks, Maksym Korablyov, Emmanuel Bengio, Moksh Jain, Andrei Cristian Nica, Tom Bosc, Yoshua Bengio, Nikolay Malkin · DOI

Abstract

Generative Flow Networks (GFlowNets) are powerful tools for sampling discrete objects with probabilities proportional to a reward function. However, training them effectively is often hindered by a fundamental credit assignment problem. Existing training objectives typically fall into two extremes: local objectives like Detailed Balance (DB), which are stable but biased, and global objectives like Trajectory Balance (TB), which are unbiased but suffer from high variance in long sequences. This paper introduces Subtrajectory Balance (SubTB($\lambda$)), a novel training objective that bridges this gap by learning from partial action sequences. SubTB($\lambda$) effectively manages the bias-variance tradeoff, leading to faster convergence, improved stability, and superior performance in complex environments with sparse rewards.

Introduction

The primary challenge in training GFlowNets lies in the "bias-variance" tug-of-war. Local objectives focus on individual transitions, resulting in low variance but slow reward propagation from the end of a sequence back to the start. Conversely, global objectives consider entire episodes; while unbiased, they introduce high gradient variance as sequence lengths increase. This instability often leads to noisy training and poor convergence in practical applications like molecular design or protein sequence generation.

Methodology: Subtrajectory Balance (SubTB($\lambda$))

To address these limitations, we propose SubTB($\lambda$), inspired by the TD($\lambda$) algorithm in reinforcement learning. Instead of choosing between single steps or full paths, SubTB enforces a balance constraint on every possible subtrajectory within an episode.

The objective incorporates a hyperparameter $\lambda$ to weight these subtrajectories:

  • As $\lambda \to 0$, the objective reduces to the local Detailed Balance.
  • As $\lambda \to \infty$, it becomes the global Trajectory Balance.

While a sequence of length $n$ contains $O(n^2)$ subtrajectories, we demonstrate that the gradient can be computed efficiently. The computation requires only a single forward and backward pass through the neural network, with the quadratic complexity limited to simple linear operations on resulting scalars.

Experimental Evaluation

We evaluated SubTB across several challenging benchmarks:

  • Synthetic Hypergrid: A grid-world task testing the ability to discover multiple modes in a sparse reward landscape.
  • Small Molecule Synthesis: Generating molecular graphs that bind to the sEH protein.
  • Biological Sequence Design: Designing antimicrobial peptides (AMP) and green fluorescent proteins (GFP), with sequences up to 237 residues.
  • Inverse Protein Folding: Predicting amino acid sequences for specific 3D protein backbones.

Key Results and Analysis

Empirical results show that SubTB($\lambda$) acts as a powerful variance reduction technique. By learning "state flows" (estimates of total future reward from a given state), the model can "fill in" parts of the trajectory, reducing the noise inherent in pure Monte Carlo sampling used by TB.

Comparison of mode discovery on a grid task. SubTB(0.9) (right) recovers the target distribution more accurately than standard Trajectory Balance (middle).

In the Hypergrid task, SubTB($\lambda$) reached the target distribution significantly faster than TB. In "hard" versions with extreme reward sparsity, TB often failed to find all modes, whereas SubTB($\lambda$) successfully discovered them.

Convergence performance on a 20x20 hard grid task. SubTB($\lambda$) (orange) demonstrates significantly faster convergence compared to baselines.

In real-world biological tasks, SubTB($\lambda$) achieved higher rewards and greater sequence diversity than all baselines, including standard GFlowNets and Reinforcement Learning methods like Soft Actor-Critic (SAC). Furthermore, SubTB proved to be less sensitive to hyperparameter choices, such as learning rates, compared to previous objectives.

Conclusion

SubTB($\lambda$) provides a robust middle ground for GFlowNet training, combining the stability of local updates with the efficient credit assignment of global ones. Future work includes exploring learnable or dynamic $\lambda$ schedules and integrating SubTB with advanced exploration strategies. The ability to learn from partial episodes also suggests potential applications in standard Reinforcement Learning settings where intermediate rewards are available.

Summary updated

BibTeX
@inproceedings{madan2023learning,
  author = {Kanika Madan and Jarrid Rector-Brooks and Maksym Korablyov and Emmanuel Bengio and Moksh Jain and Andrei Cristian Nica and Tom Bosc and Yoshua Bengio and Nikolay Malkin},
  title = {{Learning GFlowNets from partial episodes for improved convergence and stability}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=LBduMwGCqUC},
}
Figure