---
title: 'Stable-GFN: Stability in Fluid Networks & GFlowNets'
url: https://www.emergentmind.com/topics/stable-gfn-s-gfn
type: topic
---

# Stable-GFN: Stability in Fluid Networks & GFlowNets

Stable-GFN (S-GFN) is not a single universally fixed designation. In the fluid-network literature it denotes, informally, a **stable strict generic fluid network model** admitting a state-dependent Lyapunov function [1111.1990]. In recent GFlowNet research it names at least two explicit training frameworks: **“Stable GFlowNets with Probabilistic Guarantees,”** which stabilizes Trajectory Balance by reference flow and TV certificates [2605.01729], and **“Stable-GFlowNet,”** a red-teaming framework that replaces partition-function estimation with contrastive trajectory balance and adds masking and fluency filtering [2605.00553]. The same label is also used informally for stability-focused GFlowNets whose rewards prefer low-energy objects, as in crystal generation and Boltzmann conformational sampling [2310.04925] [2507.11759]. Accordingly, the meaning of S-GFN depends on whether “stability” refers to Lyapunov stability, optimization stability, or thermodynamic stability.

## 1. Nomenclature and scope

The literature uses the label in several technically distinct ways. In one lineage, **GFN** means **generic fluid network**, not **Generative Flow Network**; in another, it denotes a family of reward-proportional generative models on DAGs. This suggests that “Stable-GFN” is best treated as a context-dependent term rather than a single canonical method.

| Usage | Meaning of “stability” | Representative source |
|---|---|---|
| Stable strict GFN model | Stability of fluid-network paths; state-dependent Lyapunov characterization | [1111.1990] |
| Stable GFlowNets | Stability of GFlowNet optimization with probabilistic TV guarantees | [2605.01729] |
| Stable-GFlowNet | Stable and robust LLM red-teaming training | [2605.00553] |
| Stability-focused GFlowNet | Sampling low-energy crystals or conformations | [2310.04925], [2507.11759] |

A further source of ambiguity is the proximity of the acronym to **graph neural flow** work. The paper **“Lyapunov Stable Graph Neural Flow”** explicitly states that it does **not** introduce the acronym “Stable-GFN” or “S-GFN”; its own terms are **IL-GNN** and **FL-GNN** [2603.12557]. That distinction matters, because graph neural flows and GFlowNets solve different problems even when both are phrased in terms of “flow.”

## 2. Stable strict GFN models in fluid-network theory

In the earliest usage represented here, a **GFN model** is a nonempty set \(\mathcal{Q}\) of paths \(Q(\cdot):\mathbb{R}_+\to\mathbb{R}^K_+\) satisfying Lipschitz, scaling, and shift properties, with **closed GFN models** additionally satisfying closedness under uniform convergence on compact sets [1111.1990]. Stability is defined by the existence of \(T>0\) such that
\[
Q(T+\cdot)\equiv 0
\]
for every path \(Q(\cdot)\in\mathcal{Q}(1)\), where \(\mathcal{Q}(1)\) denotes paths with unit initial norm. The paper shows that this is equivalent to asymptotic stability of the zero path in the Lyapunov sense.

The central obstruction in general closed GFN models is that path-wise decay functionals do not automatically yield a **state-dependent** Lyapunov function. The candidate
\[
V(x):=\sup_{Q(\cdot)\in\mathcal{Q}_x}\int_0^\infty \|Q(s)\|\,ds
\]
is well-defined and upper semicontinuous for stable closed GFN models, but counterexamples show that it need not be lower semicontinuous, and concatenations of admissible paths need not remain admissible [1111.1990]. Those failures block a general converse Lyapunov theorem.

To restore a state-dependent theory, the paper introduces **strict GFN models** by augmenting closed GFNs with two additional conditions: **concatenation** and **lower semicontinuity** of the set-valued map \(x\mapsto \mathcal{Q}_x|_{[0,T]}\). For stable strict GFNs, the same \(V\) becomes continuous, and the main converse theorem states that a strict GFN model is stable **if and only if** it admits a Lyapunov function in the sense of Definition 2.5, with the explicit construction above [1111.1990]. The comparison functions can be chosen as
\[
\omega_1(r)=\frac{r^2}{2L},\qquad
\omega_2(r)=r^2(1+LT)T,\qquad
\omega_3(r)=r.
\]

The paper further shows that **general work-conserving fluid networks** and **priority fluid networks** define strict GFN models, so each is stable **if and only if** it admits a continuous Lyapunov function [1111.1990]. By contrast, for **linear Skorokhod problems** the lower semicontinuity property is not established, and the result is only an **upper semicontinuous** Lyapunov function. In this lineage, what is informally called **S-GFN** is therefore not a new algorithmic variant but a strengthened structural class of fluid-network models for which converse Lyapunov theory becomes state dependent.

## 3. Stability-targeted GFlowNets in materials and molecular sampling

A different usage treats S-GFN as a **stability-focused GFlowNet**: a model whose reward is constructed from an energy or energy proxy so that low-energy objects are sampled more often. The crystal-generation paper does not use the term “Stable-GFN” explicitly, but it states that **Crystal-GFN is essentially a “stability-targeted” GFlowNet for crystals** [2310.04925]. Crystal-GFN generates a crystal structure \(x\) sequentially by choosing a space group, constructing a composition, and sampling lattice parameters, with terminal sampling distribution satisfying
\[
\pi_\theta(x)\propto R(x).
\]
Its reward is a Boltzmann transformation of predicted formation energy per atom,
\[
R(x)=\exp\!\Big(-\frac{\mathrm{FE}_{\mathrm{pred}}(x)}{T}\Big),
\]
with \(T=8\), so lower formation energy yields higher reward. The model uses the **Trajectory Balance** objective, enforces hard constraints by masking invalid actions, and structures the state space as
\[
\mathcal{S}=\mathcal{S}_{SG}\times \mathcal{S}_C\times \mathcal{S}_{LP}.
\]

The crystallographic constraints are a defining part of that design. Compatibility among crystal-lattice system, point symmetry, and space group is enforced in the space-group subspace; charge neutrality and Wyckoff compatibility constrain composition actions; and the lattice system implied by the space group imposes equalities such as \(a=b=c\) and \(\alpha=\beta=\gamma=90^\circ\) for cubic cells [2310.04925]. In the reported setup, the search is restricted to **113 space groups**, **12 common elements**, **max 5 unique elements per composition**, and **up to 50 total atoms**, with the forward and backward policies implemented as **3-layer MLPs with 256 hidden units per layer**. Crystal-GFN is trained for **50,000** iterations, with **10%** uniformly random actions, **500,000** proxy calls, and approximately **12 hours on CPU**. The reported median predicted formation energy of generated crystals is approximately **\(-3.1\) eV/atom**, and approximately **95%** of generated structures have predicted FE \(< -2\) eV/atom [2310.04925].

A closely related molecular instance is **Torsional-GFN**, which targets the Boltzmann distribution over torsion angles conditioned on a molecular graph \(G\) and local structure \(L\) [2507.11759]. Conformations are written as \(c=c(L,\Phi)\), with torsions \(\Phi\in[0,2\pi]^m\), and the target conditional is
\[
p(\Phi\mid G,L)=\frac{1}{Z(G,L)}\exp\!\left(-\frac{E(c(\Phi,L))}{k_B T}\right).
\]
The reward is therefore
\[
R(\Phi\mid G,L)=\exp\!\left(-\frac{E(c(\Phi,L))}{k_B T}\right).
\]
Torsional-GFN uses a continuous-state GFlowNet with fixed-length trajectories, **von Mises mixtures** for periodic torsion updates, and a **VectorGNN** that predicts mixture parameters from graph and geometry. Training is based on the **VarGrad** objective,
\[
\mathcal{L}_{\mathrm{VG}}(B_\tau;\theta\mid G,L)
=
\mathbb{E}_{\tau\in B_\tau}
\Big[
\log Z_\theta(G,L)-\log \mathcal{C}_\theta(\tau\mid G,L)
\Big]^2,
\]
where
\[
\mathcal{C}_\theta(\tau\mid G,L)=
\frac{P_B^\theta(\tau\mid \Phi_n,G,L)\,R(\Phi_n\mid G,L)}
{P_F^\theta(\tau\mid G,L)}.
\]

Several design choices are explicitly aimed at stable Boltzmann sampling: log-domain training, off-policy learning without importance sampling, **50% \(\epsilon\)-greedy** exploration with \(\epsilon=0.5\), **50% replay-based backward trajectories**, and reward-prioritized replay with diversity criterion [2507.11759]. The authors also report that training the GNN policy from scratch required considerably more iterations than an MLP per molecule, and therefore pretrain VectorGNN to predict **energy** and **torsion angles** from conformations. The reported result is approximate Boltzmann-proportional sampling for multiple molecules with a single model and **zero-shot generalization to unseen bond lengths and angles** coming from MD simulations [2507.11759]. Taken together with Crystal-GFN, this suggests an informal S-GFN interpretation in which “stability” denotes preference for thermodynamically favorable or Boltzmann-weighted states rather than stabilization of the optimizer itself.

## 4. Stable GFlowNets with probabilistic guarantees

The paper **“Stable GFlowNets with Probabilistic Guarantees”** formalizes S-GFN as a method for stabilizing GFlowNet optimization while retaining distributional guarantees [2605.01729]. Its starting point is a sensitivity analysis of standard objectives—Trajectory Balance (TB), Flow Matching, Detailed Balance, and Subtrajectory Balance—showing that a small total variation distance between the learned terminal distribution \(P_T\) and the target \(\pi_{\text{target}}\) does **not** preclude unbounded training loss. In the regular \(g\)-ary tree example, changing one leaf reward from \(\epsilon\ll 1\) to \(1\) leaves
\[
\mathrm{TV}(P_T,\pi_{\text{target}})\approx \frac{1}{g^h},
\]
yet the local training losses scale as \((\log\epsilon)^2\) and diverge as \(\epsilon\to 0\) [2605.01729]. The paper therefore distinguishes **global fidelity** from **local loss spikes**.

The converse direction is constructive. For TB, if every trajectory satisfies
\[
\mathcal{L}_{\text{TB}}(\tau)\le c^2,
\]
then
\[
\mathrm{TV}(P_T,\pi_{\text{target}})\le 1-\exp(-2c).
\]
For DB and FM, an analogous result holds with dependence on maximum trajectory length \(L\):
\[
\mathrm{TV}(P_T,\pi_{\text{target}})\le 1-\exp(-2Lc).
\]
The paper also derives a sampling-based certificate: if TB losses are bounded on \(m\) trajectories sampled from the target/backward distribution \(\hat\pi\) and \(n\) trajectories sampled from the forward policy, then with confidence \(1-2\alpha\),
\[
\mathrm{TV}(P_T,\pi_{\text{target}})
\le
e^{2c}-1+\frac{\log(1/\alpha)}{m}+\frac{\log(1/\alpha)}{n}.
\]
These are loss-to-TV guarantees: bounded TB loss certifies global distributional fidelity [2605.01729].

The algorithmic mechanism used to enforce bounded loss is **reference flow**. For a trajectory \(\tau\), the target trajectory flow is
\[
\mathcal{R}(\tau)=R(x)P_B(\tau\mid x),
\]
and the augmented flows are
\[
F_{\text{aug}}(\tau)=ZP_F(\tau)+\delta(\tau),\qquad
\mathcal{R}_{\text{aug}}(\tau)=\mathcal{R}(\tau)+\delta(\tau).
\]
The augmented TB loss is
\[
\mathcal{L}_{\text{aug}}(\tau)=
\left(
\log\frac{F_{\text{aug}}(\tau)}{\mathcal{R}_{\text{aug}}(\tau)}
\right)^2.
\]
The minimal \(\delta(\tau)\) that caps the absolute log-ratio by \(c\) is given piecewise in Equation (RF), with \(\delta(\tau)=0\) whenever the raw TB log-ratio already lies within \([-c,c]\) [2605.01729]. A fidelity–stability trade-off then follows:
\[
\mathrm{TV}(P_T,\pi_{\text{target}})
\le
(1-e^{-2c})\left(1+\frac{\Delta}{Z^*}\right),
\qquad
\Delta=\sum_{\tau\in\mathcal{T}}\delta(\tau).
\]

Stable-GFN operationalizes these results by maintaining a top-\(K\) buffer \(\mathcal{X}_{\text{sub}}\) of high-reward terminal states, splitting each batch between forward samples and backward samples from \(\mathcal{X}_{\text{sub}}\), and updating the loss threshold online via
\[
c_{t+1}\leftarrow
(1-\beta)c_t+\beta\max_{\tau\in\mathcal{T}_{\text{batch}}}\sqrt{\mathcal{L}_{\text{TB}}(\tau)},
\]
with \(\beta=0.05\) [2605.01729]. In the reported experiments, Stable-GFN matches the best baselines on Hypergrid \(D=4,H=16\), achieves the best \(L_1\) error on Hypergrid \(D=4,H=32\) with **\(0.663\pm0.001\)**, and on L14-RNA1 attains **3483 / 704** train/test modes, which is the best reported test coverage among the listed baselines [2605.01729]. In extended experiments, **StableTeacher** discovers approximately **8,858 of 8,967 modes**—approximately **98.8% coverage**—while sampling only approximately **5.36%** of the end-state space. In this usage, S-GFN is fundamentally an **optimization-stability** framework for reward-proportional generative training.

## 5. Stable-GFlowNet for LLM red-teaming

The red-teaming paper uses **Stable-GFlowNet (S-GFN)** as the explicit name of a framework for generating diverse and robust jailbreak prompts for a safety-aligned victim LLM [2605.00553]. The attacker policy \(T_\theta\) emits a prompt \(y\), the victim model \(T_0(z\mid y)\) generates a response \(z\), a toxicity classifier \(\mathcal{T}_\phi(y,z)\in[0,1]\) scores the pair, and the reward is
\[
R(y)=\mathbb{E}_{z\sim T_0(\cdot\mid y)}[\mathcal{T}_\phi(y,z)].
\]
The paper argues that standard TB is unstable in this setting because it requires estimating a single global partition function \(Z_\theta\) over an enormous combinatorial space and because rewards are noisy. Its solution is **Contrastive Trajectory Balance (CTB)**,
\[
\mathcal{L}_{\text{CTB}}(y_1,y_2;\theta)=
\left(
\log\frac{T_\theta(y_1)}{T_\theta(y_2)}
-
\log\frac{R(y_1)}{R(y_2)}
\right)^2,
\]
which algebraically removes \(Z\) by comparing pairs of trajectories rather than regressing each trajectory to \(\log R(y)-\log Z\) [2605.00553].

The theoretical claim is exact: if \(R(y)>0\) for all \(y\) and \(T_\theta\) has full support, then
\[
J_{\text{CTB}}(\theta)=0
\quad\Longleftrightarrow\quad
T_\theta(y)=\frac{R(y)}{Z}.
\]
Thus CTB preserves the same optimal policy as TB without explicit partition-function estimation [2605.00553]. The paper further introduces **Noisy Gradient Pruning (NGP)**,
\[
\mathcal{L}_{\text{NGP}}(y_1,y_2;\theta)=
\mathbf{1}\{|\log R(y_1)-\log R(y_2)|>\sigma\}
\cdot
\mathcal{L}_{\text{CTB}}(y_1,y_2;\theta),
\]
and shows that if the saliency graph \(G_\sigma\) is connected, the global minimum still satisfies \(T_\theta(y)\propto R(y)\). This is a robustness mechanism against noisy or nearly indistinguishable reward pairs.

A third component, the **Min-K Fluency Stabilizer (MKS)**, addresses reward hacking through gibberish prompts. Using a frozen reference model \(T_{\text{ref}}\), the paper defines
\[
M_k(y)=\frac{1}{k}\sum_{w\in K}\log T_{\text{ref}}(y_w\mid y_{<w}),
\]
where \(K\) is the set of the \(k\) least likely tokens in the sequence, and filters rewards by
\[
R_{\text{MKS}}(y)=\mathbf{1}\{M_k(y)\ge \tau_{\text{MKS}}\}\cdot R(y).
\]
This differs from KL regularization because it removes clearly non-fluent sequences without reshaping the target among fluent ones [2605.00553].

The empirical results are reported on Qwen-based attacker and victim models, with Meta-Llama-Guard-3-8B as toxicity classifier. Against the target victim **Qwen2.5-1.5B-Instruct**, S-GFN achieves **UA = 134.00 ± 12.77** and **ASR = 92.55 ± 2.87%**, whereas **GFN-TB** yields **UA = 17.67 ± 6.51** and **ASR = 93.75 ± 4.40%**, and **PPO** yields **UA = 3.00 ± 1.00** and **ASR = 91.70 ± 2.95%** [2605.00553]. In the cross-attack defense matrix, a defense trained on S-GFN attacks drives GFN attacks to **0.03%** ASR and reduces S-GFN self-attack to **0.75%** ASR. On unseen victims such as **Gemma3-4B-Instruct** and **Llama3.2-3B-Instruct**, S-GFN also shows the highest reported transfer ASR and UA among the listed GFN and QD baselines. Here, S-GFN denotes a concrete **contrastive** GFlowNet variant tailored to noisy sequence-level rewards.

## 6. Related “stable flow” terminology and conceptual distinctions

The phrase can be confused with the control-theoretic paper **“Lyapunov Stable Graph Neural Flow,”** but that work is not a GFlowNet paper and does not introduce the acronym “Stable-GFN” or “S-GFN” explicitly [2603.12557]. Its objects are **continuous-depth GNNs** whose state \(\mathbf{U}(t)\) evolves according to an integer-order ODE or a fractional-order Caputo system,
\[
\frac{d\mathbf{U}(t)}{dt}=\mathcal{F}(t,\mathbf{U}(t);\mathbf{W}),
\qquad
D_t^\beta\mathbf{U}(t)=\mathcal{F}(t,\mathbf{U}(t);\mathbf{W}),
\]
and whose stability is enforced by a learned Lyapunov function built from an **Input Convex Neural Network**,
\[
V(\mathbf{U}^\star)=
\sigma(\mathrm{ICNN}(\mathbf{U}^\star)-\mathrm{ICNN}(\mathbf{0}))
+
\|\mathbf{U}^\star\|^2.
\]
A projection operator modifies the vector field so that \(\dot V\le -cV\) in the integer-order case or the corresponding fractional inequality holds in the Caputo case [2603.12557]. The resulting models are named **IL-GNNs** and **FL-GNNs**, and the reported empirical effect is robustness against adversarial graph perturbations.

This neighboring usage clarifies a persistent ambiguity. Across the sources considered here, “stability” may denote at least four different objects: extinction and Lyapunov decay of fluid-network paths, descent of a learned Lyapunov function in graph neural flows, thermodynamic favorability or Boltzmann weighting of generated scientific objects, and bounded-loss optimization with probabilistic fidelity guarantees in GFlowNets [1111.1990] [2603.12557] [2310.04925] [2507.11759] [2605.01729] [2605.00553]. A plausible implication is that the term **S-GFN** is most informative only when accompanied by its target domain and the operative notion of stability. Without that qualifier, it spans structurally different theories: converse Lyapunov theorems for strict GFNs, reward-proportional sampling of stable crystals or conformers, certification-oriented stabilization of Trajectory Balance, and contrastive partition-free red-teaming.

Source: https://www.emergentmind.com/topics/stable-gfn-s-gfn