Real networks are sparse overall but dense in pockets: most pairs of people are strangers, yet your friends tend to know each other. Neural graph generators struggle with this mix. Models that score every possible node pair hit a memory wall at a few hundred nodes. Models that avoid that wall, either by predicting edges nearly independently or by writing the graph out one edge at a time, tend to lose triangles or copy them from the training data. Decades-old statistical generators such as the Block Two-Level Erdős–Rényi model (BTER) handle the mix by splitting generation into two phases: first build small dense clusters, then wire the clusters together sparsely. That wiring step is random and learns nothing, so global structure such as path lengths and which communities connect to which is left to chance.
This note proposes a learned two-phase generator built on one observation. The scores produced by linear attention, the variant of transformer attention that avoids the $N \times N$ score matrix, form a low-rank, nonnegative matrix. Edges can be sampled from that matrix exactly, and its likelihood can be normalized exactly, in time linear in the number of nodes. Phase 1 generates dense blocks in parallel with full attention inside each small block. Phase 2 uses a linear graph transformer, which reads all nodes, both to embed nodes and to act directly as the probability distribution over edges between blocks. Nothing quadratic is ever built. Triangles come from blocks where edges can depend on each other freely, and long-range wiring comes from a learned global model rather than a random configuration model.
Core Claim
Treating the linear-attention kernel as an edge distribution, rather than only as a way to mix features, gives three things at once. First, Phase 2 has an exactly normalized edge likelihood computable in $O(Nd)$, where $d$ is the feature dimension, so it needs no subsampling of non-edges. Second, sampling costs $O(d + \log N)$ per edge. Third, the generator falls cleanly into the edge-dependency classes analysed by On the Role of Edge Dependency in Graph Generative Models. That paper proves that how many triangles a model can produce without copying training data depends on how strongly its edges depend on each other. Our Phase 2 is "node independent" in their sense: edges depend on each other only through sampled node embeddings. It would therefore pay their triangle penalty if it had to produce triangles alone. It does not, because Phase 1 blocks are arbitrarily dependent and supply the local triangles. The testable prediction is that this split matches clustering at low training-set overlap, as clique-planting models do. Unlike those models, it should also match characteristic path length and connected-pair statistics, which On the Role of Edge Dependency in Graph Generative Models reports clique planting fails to capture.
The mechanism is as follows. Let $\phi(\cdot)$ be a nonnegative feature map, such as elu+1 or positive features. Let $q_u$ and $k_v$ be query and key vectors that the global transformer produces for nodes $u$ and $v$, and let $S = \sum_v \phi(k_v)$ be the summed key features. Phase 2 defines the target of an edge leaving $u$ as
$$p(v \mid u) = \frac{\phi(q_u)^\top \phi(k_v)}{\phi(q_u)^\top S} = \sum_{r=1}^{d} \underbrace{\frac{\phi(q_u)_r S_r}{\phi(q_u)^\top S}}_{\pi_r(u)} \cdot \frac{\phi(k_v)_r}{S_r}.$$
Read this way, it is a mixture of $d$ distributions over nodes, each fixed for the whole graph. To sample a target, first draw a feature index $r$ from $\pi(u)$ in $O(d)$. Then draw $v$ from the $r$-th per-feature table of key values using prefix sums in $O(\log N)$. The tables cost $O(Nd)$ to build. The denominator is likewise exact and costs $O(d)$ per source node once $S$ is known.
Because we define the model by this kernel instead of approximating softmax, the variance of random features noted for NodeFormer does not arise.
Relation to Prior Work
Several papers motivate the gap. The BTER Graph Model and Scalable Methods for Characterizing and Generating Large Graphs show that separating clusters from global wiring avoids conflicts between the parameters that control clustering and those that control the degree distribution, and that it scales to billions of edges. Their Phase 2, however, is a Chung–Lu model, which wires each edge with probability proportional to the product of the endpoints' target degrees and has no learned preferences. On CA-HepPh, BTER's global clustering coefficient is 0.36 against a true 0.66, though still far above the 0.01 of Kronecker graphs. That shortfall suggests the dense blocks themselves are too crude. We keep BTER's skeleton and its residual-degree bookkeeping, and replace both phases with learned models.
The edge-dependency theory in On the Role of Edge Dependency in Graph Generative Models constrains the design. It tells us that no node-independent model, including any kernelized attention edge model, can be responsible for triangles at low overlap. That is why all local density lives in Phase 1. We also avoid its maximal-clique mining, which is NP-hard. Training graphs are partitioned with fast degree-ordered affinity blocks in the style of BTER, or with an off-the-shelf community detector.
The methods that supply our machinery come from discriminative graph transformers. GraphGPS and SGFormer pair a local message-passing channel with a linear global attention channel, and SGFormer shows that one global layer suffices and trains on ogbn-papers100M in about 3.5 GPU-hours. NodeFormer uses kernelized attention to learn latent edges. All three work on fixed input graphs for prediction. Our contribution is to turn the global channel into a generative edge sampler with a tractable likelihood. NodeFormer's Gumbel-Softmax edges are a relaxation trained for classification. Ours are exact samples trained by maximum likelihood.
Four deep generators break the quadratic wall without a two-phase structure, and these are our competitors. EDGE diffuses by removing edges and predicts only among a small set of active nodes. SparseDiff trains a sparse graph transformer on a subsample of node pairs and fills the adjacency matrix chunk by chunk at inference. BiGG generates edges autoregressively through binary trees. AutoGraph flattens graphs into Eulerian-trail token sequences for a decoder-only transformer. None separates blocks from global wiring, and both autoregressive models need $O(M)$ sequential steps for $M$ edges.
The closest work is LGDC. It is hierarchical: it runs diffusion on a coarsened graph and then expands back to full size in one shot with message-passing networks. It has been evaluated only up to about 200 nodes, and its expansion step cannot correct its own mistakes and is memory-heavy. Our direction of construction is the reverse: we build fine blocks first and then wire them, rather than coarse structure first and then expand. Our global step is an exactly normalized linear-time sampler, and we alternate the two phases so that errors can be revised.
Research Program
The generator runs in three stages.
Stage 0: the blueprint. A small model samples the number of nodes, a degree sequence, and a partition into blocks of size at most $B$. The degree sequence borrows EDGE's idea of drawing target degrees first. The partition can follow the degree-ordered affinity rule from BTER or be learned.
Phase 1: the blocks. For each block, a dense discrete denoiser with full attention among the block's at most $B$ nodes generates the block's internal edges. All blocks run in parallel, so the cost is $O(NB)$ rather than $O(N^2)$. Each block is conditioned on a block summary token produced by the global transformer.
Phase 2: the wiring. Each node's residual degree, its target degree minus its within-block degree, sets how many cross-block edges it should receive. The global linear transformer embeds every node from three inputs: its Phase 1 local structure, passed through a message-passing channel; its residual degree; and its block identity. It then emits $q_u$ and $k_v$. Source nodes are drawn in proportion to residual degree and targets from $p(v \mid u)$. Samples that land inside the source's own block or duplicate an existing edge are rejected.
Refinement. The two phases alternate for a small number of rounds $R$. After wiring, blocks are re-denoised conditioned on their new neighbourhood, and wiring is resampled. This is the error-correction step LGDC lacks.
The total cost is $O(R(Nd^2 + NB^2 + Md\log N))$. Each term is linear in nodes or edges for a fixed block size $B$.
Training. Each training graph is partitioned once. Phase 1 is trained as a standard dense discrete diffusion on blocks. Phase 2 is trained by exact maximum likelihood on the observed cross-block edges, using the normalizer above, with no non-edge sampling. The cost is $O(Nd^2 + M_{\text{cross}} d)$ per graph, where $M_{\text{cross}}$ is the number of cross-block edges.
Analysis. Beyond benchmark metrics, we will measure the triangle-versus-overlap curve defined in On the Role of Edge Dependency in Graph Generative Models for our model and for every baseline. The theory predicts that our curve should be close to linear in overlap, because blocks are arbitrarily dependent. Flat neural generators should fall off faster.
Baselines
Naive reference: BTER fitted to each training graph. This is the do-nothing reference for two-phase generation: same partitioning rule, Erdős–Rényi blocks, and Chung–Lu wiring. It costs nothing to tune. It shows what the learned components add. On CA-HepPh it should be matched or beaten on clustering, where the BTER paper reports 0.36 against a true 0.66, without losing its degree fit.
Strongest flat sparse generator on large single graphs: EDGE. EDGE is the strongest competitor on graphs with thousands of nodes. It runs where GDSS and DiGress run out of memory on Polblogs, Cora, Road-Minnesota, and PPI, and it samples Cora in 1.7 seconds. On Community-20 it reports a degree MMD of 0.0175 against 0.0409 for DiGress. MMD is maximum mean discrepancy, a distance between the distributions of a graph statistic in generated and real graphs. We will run the released EDGE configuration on the same splits and with the same GPU budget, and tune both models with an equal number of hyperparameter trials. Beating it means a degree MMD at or below 0.0175 on Community-20, together with lower clustering, orbit, and path-length discrepancy at equal or lower training-set overlap on the large graphs. The orbit statistic counts small subgraph patterns around each node. For those large-graph datasets no MMD values were found on Lacuna, so we will rerun EDGE ourselves.
Strongest sequence generator: AutoGraph. It reports the best MMD ratios on Proteins and Point Clouds and samples about 100 times faster than DiGress, but no reported numeric MMD for AutoGraph was found on Lacuna. We will train it at a matched parameter count. Beating it means better clustering and path-length MMD, together with lower wall-clock sampling time on graphs above roughly $10^4$ edges, where its $O(M)$ sequential steps should dominate.
SparseDiff and BiGG. SparseDiff covers diffusion with subsampled node pairs. It generated a 1,045-node Facebook graph where dense models failed, though no MMD values were found on Lacuna. BiGG covers scale, modelling 100,000 nodes in about 2 GB. Both are run with their published settings at matched compute.
LGDC with a transformer backbone. This version of LGDC swaps its message-passing backbones for GraphGPS-style layers, so that it does not lose merely because it uses a weaker architecture.
Ablations. Three ablations isolate the key ingredients. The first keeps the learned Phase 1 but uses Chung–Lu for Phase 2; this is the critical test of whether learned wiring matters. The second keeps learned wiring but uses Erdős–Rényi blocks. The third sets $R=1$ to isolate the refinement step.
Why not just…?
Why not just use BTER? BTER already scales and already separates clusters from wiring. Its own reported numbers, however, show a clustering shortfall on CA-HepPh. Its global wiring knows only degrees, so it cannot reproduce which communities preferentially connect, or path lengths that differ from a degree-matched random graph. The experiments include BTER directly. If it matches us on path length and connected pairs, the global learned component has no case.
Why not just learn the blocks and keep Chung–Lu wiring? This is the most serious threat, since it is cheaper and may capture most of the degree and clustering statistics. We run it as the first ablation and judge it mainly on characteristic path length, connected-pair distribution, and inter-community mixing, the global quantities that clique planting is reported to miss. If learned wiring does not improve these on Polblogs, PPI, and Cora, we will report the simpler model as the result and drop the claim about the global transformer.
Why not just scale EDGE or SparseDiff? Both already handle thousands of nodes. Their edges, however, interact only through message passing or sparse attention, which places them in the regime where the edge-dependency theory predicts that triangles vanish or are copied from training data at low overlap. EDGE also reports convergence trouble when the active node set becomes tiny. The triangle-versus-overlap curves settle this empirically: if EDGE's curve matches ours, the two-phase argument fails.
Why not just use AutoGraph-style sequences? Sequences scale as $O(M)$ and sample quickly, but strictly sequentially, and an early mistake cannot be undone. Our blocks are generated in parallel and the refinement rounds revise errors. Wall-clock scaling curves from $10^3$ to $10^5$ nodes, together with path-length MMD, will show whether that matters in practice or whether a strong sequence model is simply good enough.
Proposed Experiments
Small-graph benchmarks. We evaluate on Community-20, Ego, Proteins, and 3D Point Clouds with the standard degree, clustering, and orbit MMDs. This checks that the model is competitive where dense models still run.
Large single-graph benchmarks. On Polblogs, Cora, Road-Minnesota, PPI, Facebook-1045, and CA-HepPh, we add global clustering coefficient, characteristic path length, connected-pair fraction, and overlap with the training graph. Road-Minnesota serves as a negative control: it has little clustering, so blocks should shrink to near-trivial and the model should reduce to its Phase 2 sampler without losing accuracy.
Scaling test. We generate BTER-style synthetic graphs from $10^3$ to $10^6$ nodes and plot peak memory and sampling time against BiGG, EDGE, and AutoGraph. The prediction is linear growth for our model at a fixed block size $B$.
Decisive checks. Four results would settle the core claim. First, at matched overlap, our triangle counts should exceed those of every flat neural baseline. Second, our path-length error should fall below both clique planting and the learned-blocks-plus-Chung–Lu ablation. Third, exact Phase 2 likelihood training should outperform the same model trained with subsampled non-edges in the SparseDiff style; this isolates the value of the exact normalizer. Fourth, refinement with $R>1$ should measurably reduce clustering error relative to $R=1$. If the first or second check fails, the proposal's central claim fails.
References
- On the Role of Edge Dependency in Graph Generative Models
- NodeFormer: A Scalable Graph Structure Learning Transformer for Node Classification
- The BTER Graph Model: Blocked Two-Level Erdos-Renyi.
- Scalable Methods for Characterizing and Generating Large Graphs.
- Recipe for a General, Powerful, Scalable Graph Transformer
- SGFormer: Simplifying and Empowering Transformers for Large-Graph Representations
- Efficient and Degree-Guided Graph Generation via Discrete Diffusion Modeling
- Sparse Training of Discrete Diffusion Models for Graph Generation
- Scalable Deep Generative Modeling for Sparse Graphs
- Flatten Graphs as Sequences: Transformers are Scalable Graph Generators
- LGDC: Latent Graph Diffusion via Spectrum-Preserving Coarsening