Soft Q-Learning Breaks for GFlowNets When the Environment Is Random

Generative flow networks (GFlowNets) are samplers that build an object step by step, such as a molecule, a DNA sequence, or a grid path, so that finished objects appear with probability proportional to a reward. A recent line of work shows that training a GFlowNet is the same as entropy-regularized, or "soft", reinforcement learning (RL) on a slightly modified problem. In soft RL, the agent is paid for reward and also for keeping its action choices random. Because of this equivalence, off-the-shelf methods like Soft DQN and Munchausen DQN can replace specialized GFlowNet losses. Every such result assumes that an action always leads to the same next state. We argue that when transitions are random, the equivalence splits in two. GFlowNet-style flow conservation averages downstream reward before taking the logarithm. Standard soft RL averages after taking it. With sparse rewards, the second choice is badly wrong: it shrinks the probability of any action that carries a chance of landing in a zero-reward region by a factor that is exponential in how sparse the reward is.

We propose to prove this split and measure its size. We then give a model-free soft Q-learning algorithm that performs the GFlowNet-correct backup, the "log of an expectation", without a learned dynamics model and without resetting the simulator. The target setting is sparse-reward generation under noisy transitions, such as synthesis errors in sequence design or slippery grids. A practitioner who follows the current "just use soft RL" advice would get quietly distorted samples in exactly this setting.

Core Claim

Write $V(s)$ for the log-flow, or soft value, of state $s$. Write $U(s,a)$ for the value of the "afterstate" reached right after choosing action $a$ in state $s$ but before the environment's random response. Tiapkin et al. and Deleu et al. showed that, under deterministic dynamics, GFlowNet training is soft RL with a per-step reward $\log P_B(s\mid s')$, where $P_B$ is a fixed backward policy that corrects for objects reachable by many paths, plus a terminal reward $\log R(x)$. Once transitions are random, there are two candidate afterstate backups:

$$U_{\text{RL}}(s,a) = \mathbb{E}_{s'\sim P(\cdot\mid s,a)}\big[r(s,s') + V(s')\big], \qquad U_{\text{flow}}(s,a) = \log \mathbb{E}_{s'\sim P(\cdot\mid s,a)}\big[e^{\,r(s,s') + V(s')}\big].$$

In both cases the state value is $V(s)=\log\sum_a e^{U(s,a)}$, and the policy picks actions with probability proportional to $e^{U(s,a)}$.

Applying Soft DQN or Munchausen DQN to sampled transitions implements $U_{\text{RL}}$. Flow conservation in expectation, the Expected Detailed Balance objective of Expected Flow Networks, implements $U_{\text{flow}}$. Under $U_{\text{flow}}$, in tree-structured problems each action is chosen in proportion to the expected reward mass downstream. Under $U_{\text{RL}}$, actions are chosen in proportion to a geometric mean of downstream reward.

Take an action that leads with probability $p$ to a region of background reward $\epsilon$ and otherwise to a region of reward $R^\star$. The two backups weight it as $pR^\star$ plus a small term, versus $(R^\star)^{1-p}\epsilon^{p}$. The ratio therefore diverges as $\epsilon^{-p}$ when the reward becomes sparser; the exponent comes straight from Jensen's gap on a two-point distribution.

This is the precise sense in which stochastic GFlowNets are not soft RL. It also sharpens the "unsatisfiable constraints" observation of Jiralerspong et al. into a quantitative prediction about sparse rewards.

The algorithmic claim is that $U_{\text{flow}}$ can be learned from single sampled transitions. Consider the convex loss

$$\mathcal{L}(U) = \mathbb{E}_{s'\sim P(\cdot\mid s,a)}\Big[e^{\,y(s') - U} + U\Big], \qquad y(s') = r(s,s') + \bar V(s'),$$

where $\bar V$ is a target network. Setting its derivative to zero gives $\mathbb{E}[e^{y-U}]=1$, so the loss is minimized exactly at $U=\log\mathbb{E}[e^{y}]$. Stochastic gradients from one sample are therefore unbiased, which is not true of plugging a sampled log-mean-exp into a squared loss. We call the resulting method Expected-Flow Soft Q-learning (EF-SQL).

Research Program

The theory component extends the reduction of Tiapkin et al. to afterstate-augmented problems, using the even/odd state split of Stochastic GFlowNets. It has four parts. First, we prove that the fixed point of EF-SQL coincides with the Expected Detailed Balance solution, including the $\log P_B$ correction that keeps multi-path objects from being over-sampled. Second, we prove that the fixed point of Munchausen or Soft DQN on sampled transitions is the $U_{\text{RL}}$ solution. We expect this to correspond to reverse-KL inference with the dynamics held fixed, the known "optimism versus fixed dynamics" split from control-as-inference. Third, we bound the terminal-distribution gap between the two solutions in terms of the log reward range and the entropy of each transition. Fourth, we identify when the gap vanishes: deterministic dynamics, or noise that never changes which reward region is reachable.

The algorithm component builds EF-SQL on the Munchausen DQN recipe that performed best in Tiapkin et al.. It uses two heads: a state-action head for the agent's choice, and an afterstate head trained with the loss above. The exponential term is dangerous when $y-U$ is large, which is common with sparse rewards. We therefore normalize by a running per-batch log-sum-exp shift, which leaves the minimizer unchanged, and we clip gradients rather than values. We will report how often clipping activates.

As an extension aimed at slow credit propagation over long sparse horizons, we will test an $n$-step version. It nests the loss over afterstates along a sampled subtrajectory, which gives a first practical form of the "expected subtrajectory balance" that Jiralerspong et al. leave open, in the spirit of SubTB(λ). We treat this as secondary. It is only worth pursuing if the one-step method already shows the predicted gap.

Baselines

The naive reference point is a standard deterministic GFlowNet trained with trajectory balance and simply run on the noisy environment. Pan et al. report this finds 3.0 modes on the stochastic antimicrobial peptide (AMP) task, against 4.3 for Soft Actor-Critic.

The most important competitor is Munchausen DQN with the $\log P_B$ reward, applied directly to sampled stochastic transitions. This is exactly what the current GFlowNet-as-soft-RL guidance recommends. It is the $U_{\text{RL}}$ arm, and it is the ablation that isolates our key ingredient. It shares EF-SQL's network, replay buffer, target updates, Munchausen term and exploration schedule, and differs only in the afterstate loss. Any performance difference between the two is attributable to log-of-expectation versus expectation-of-log.

The strongest existing stochastic GFlowNets are Stochastic GFlowNets with a learned maximum-likelihood dynamics model (Pan et al.) and Expected Flow Networks with Expected Detailed Balance (Jiralerspong et al.). On AMP, Stoch-GFN is reported at an average of 19.5 modes. That is the number to beat, and it is the only concrete stochastic-benchmark figure we have. For Expected Flow Networks on TFBind8, no reported result was found on Lacuna, so we will rerun them.

We will also include an oracle arm. It computes $U_{\text{flow}}$ exactly from the known dynamics on small grids, or from $K$ simulator resets per afterstate. This separates estimation error from objective choice.

All methods get the same environment steps, the same network size, and the same hyperparameter search budget, 20 configurations per method chosen by validation $L_1$ error, with 5 seeds each. For EF-SQL, beating Munchausen DQN means lower $L_1$ error to the $U_{\text{flow}}$ target distribution, with a gap that grows as reward sparsity increases. Beating the stochastic GFlowNets means matching their mode counts without a dynamics model, or exceeding them at equal sample budgets.

Why not just…?

Why not just run Munchausen DQN as-is, since it already beat GFlowNet losses? Its advantage in Tiapkin et al. was measured only on deterministic tasks. Our analysis predicts it converges to a different, geometric-mean target under noise. This is a real threat if the gap turns out small in practice, for example when slip rarely changes which mode is reachable. The sparsity-by-slip sweep below settles it. If Munchausen DQN matches EF-SQL at every tested sparsity, the theoretical gap is practically irrelevant and we will say so.

Why not just use Expected Flow Networks with a learned dynamics model? By our first theorem, EF-SQL has the same fixed point, so the question is purely empirical. EF-SQL's claim is that it avoids the separately trained transition model. The file flags that such models accumulate errors over long horizons, and they are costly for 21-token actions over length-60 sequences. If the model-based variant matches EF-SQL at equal sample and compute budgets, the contribution narrows to the theory and to the diagnosis of soft RL's failure. We will report that outcome plainly.

Why not just sample several next states per afterstate and take a log-mean-exp? A finite-sample log-mean-exp is biased downward toward $U_{\text{RL}}$ by Jensen's inequality. It also needs a resettable simulator. We include it as the oracle arm precisely to measure how much EF-SQL's single-sample estimator loses against it.

Why not just add an exploration bonus or raise the entropy temperature? Neither changes the direction of the Jensen distortion. A uniform bonus leaves the $\epsilon^{p}$ penalty on risky actions intact. Intrinsic bonuses based on random network distillation, as in GAFlowNets, are drawn toward unpredictable transitions in noisy environments. We will run Munchausen DQN with a tuned temperature to show the distortion persists.

Proposed Experiments

The core experiment is a two-way sweep on the torchgfn HyperGrid, with slip probability as in the stochastic GridWorld of Pan et al.. We cross slip probability in $\{0, 0.05, 0.1, 0.25\}$ with background reward $\epsilon$ spanning four orders of magnitude. The grids are small enough to compute both the $U_{\text{flow}}$ and $U_{\text{RL}}$ target distributions exactly by dynamic programming.

We report $L_1$ error of each method's samples to both targets, and the fraction of sampled mass that lands on modes reachable only through risky corridors. The decisive check is whether Munchausen DQN's under-weighting of risky modes follows the predicted $\epsilon^{-p}$ scaling while EF-SQL tracks the oracle. At zero slip, all value-based arms should coincide, which also serves as a sanity check.

We then move to stochastic TFBind8 and stochastic AMP from Pan et al. and Jiralerspong et al.. There we report modes discovered, reward of the top-100 sequences, diversity, and wall-clock time against the 19.5-mode Stoch-GFN figure on AMP. We also measure how often gradient clipping activates, to test whether exponential weighting is stable at realistic sparsity.

The result would be negative in an informative way if Munchausen DQN and EF-SQL agree on the sparse, high-slip grid cells. That would mean the soft RL reduction survives stochasticity in practice even though it fails in principle.