advanced24 min studyLesson 822 in Engineering

Budget sampled neighborhoods without losing estimator semantics

Track occurrence growth, unique nodes and probability weights separately.

On this page

What you’ll understand

  • Compute a multilayer occurrence budget from declared fanouts.
  • Distinguish replacement, duplicate collapse and unique feature fetches.
  • Identify when sampled aggregation estimates a full-neighborhood quantity.

Sampling keeps a large graph from expanding every seed into its entire reachable neighborhood, but the fanout list is only the beginning of a resource contract. It bounds sampled occurrences under a declared expansion rule, not necessarily unique nodes, induced edges or useful independent observations. Replacement policy and sampling weights also determine whether a sampled aggregate estimates the quantity the model designer intended.

Count expansions before assuming compaction

Define f₁ as the number of neighbors drawn for each seed and f₂ as the number drawn for each first-hop occurrence. With B seeds and two layers, an occurrence-tree upper budget is B+ Bf₁+ Bf₁f₂ when all requested draws are available. Low degree without replacement can reduce counts. Shared nodes and repeated draws can reduce unique feature rows after compaction. Conversely, returning the induced subgraph can add edges beyond those sampled along the expansion tree, so node and edge budgets need separate limits.

GraphSAGE made bounded neighborhood sampling central to scalable aggregation, while PinSAGE uses random-walk-derived importance to construct neighborhoods for its recommendation setting. Those samplers do not define the same distribution. Record fanout ordering, edge types, incoming or outgoing direction, replacement and time constraints. A heterogeneous graph can have a separate fanout for each relation and therefore a larger combined expansion than a single scalar list suggests. Confirm the loader’s actual sampled-node and sampled-edge counters rather than treating configuration as measurement.

Nocc≤B(1+f1+f1f2)N_{\rm occ}\le B\left(1+f_1+f_1f_2\right)
B and f values are dimensionless counts for the specified two-hop occurrence expansion. This bound excludes extra induced edges, per-relation fanout multiplication, model activations and allocator overhead; unique nodes can be fewer.↔ Scroll wide equations horizontally.

Repeated draws and unique nodes are different objects

For k independent uniform draws with replacement from d distinct neighbors, each neighbor is omitted with probability (1−1/d)^k. Summing inclusion indicators gives the expected unique count. For d=4 and k=4 it is only 4(1−0.75⁴)=2.734375. Drawing four times therefore does not normally mean fetching four distinct feature rows. Without-replacement sampling has a different unique-count rule, and a sampler that switches policy for low-degree nodes must make that behavior visible.

Duplicate collapse for feature retrieval can preserve computation if the original draw multiplicities or weights remain attached to messages. Dropping multiplicities changes a sum. For neighbors with values 2 and 10, two uniform replacement draws have an unbiased full-sum estimator equal to the draw sum, whose expectation is 12. If duplicates are collapsed and their weights discarded, the possible sums 2,12,12,10 average to 9. This example concerns sums; an unweighted unique-set mean under uniform symmetry is not automatically biased in the same way.

E[U]=d[1−(1−1d)k],d≥1,k∈N\mathbb E[U]=d\left[1-\left(1-\frac1d\right)^k\right],\qquad d\ge1,\quad k\in\mathbb N
U counts distinct neighbors among k iid uniform replacement draws from d neighbors. The formula assumes a fixed eligible neighborhood and does not cover biased sampling or deduplication of nodes reached through different seeds.↔ Scroll wide equations horizontally.

A local unbiased estimate is not an unbiased whole network

A uniform sample mean can estimate the full neighbor mean before nonlinearities. To estimate a full sum from k uniform replacement draws, scale their sum by d/k. With unequal draw probabilities, importance weights must match the target and sampling design; unique-set estimators instead need inclusion probabilities. Nonlinear activation, sampled normalization and multiple stochastic layers can introduce bias even when one local linear estimate is unbiased. State whether the model intentionally trains on sampled neighborhoods or aims to approximate a particular full-graph operator.

In the probability lab, Reset and set both p=0.25 and n=4. Predict one occurrence on average for a particular neighbor across four independent draws, and zero occurrences with probability 0.75⁴≈0.3164. Play highlights exact binomial outcomes, not neighbor samples. This models one fixed neighbor’s draw count only; the counts of different neighbors are dependent and the lab does not compact a minibatch or estimate nonlinear GNN error. Use the calculation to explain why four draws can cover substantially fewer than four distinct neighbors.

Turn fanout into an explicit feature-occurrence budget

A two-hop sampler starts from two seeds, draws three neighbors per seed and two neighbors per first-hop occurrence. Assume every draw is available and count repeated node occurrences separately. Each occurrence uses sixteen four-byte feature values. Exclude edge storage, intermediate layers and compaction.

  1. The first hop has Bf₁=2×3=6 occurrences, in addition to the two seeds. The count includes the same global neighbor repeatedly if it is drawn from several seeds.

  2. The second hop has Bf₁f₂=2×3×2=12 occurrences. Adding seeds and both hops gives 2+6+12=20 feature occurrences under this explicit tree expansion.

  3. Each row has 16×4=64 bytes, so unshared input-feature storage is 20×64=1,280 bytes. Unique-node compaction can reduce that input-row count, but it does not automatically remove required messages or the model’s intermediate activation storage.

The result

The occurrence budget is twenty rows and 1,280 feature bytes under the stated boundary. Measure unique nodes, sampled edges and full peak memory separately.

Explore the model

Interactive lab

Interactive lab · probability

One neighbor can be missed in repeated draws

Reset → set p=0.25 and n=4 → predict mean 1 and P(K=0)=0.31640625. Play highlights exact binomial counts rather than drawing a neighborhood.

One neighbor can be missed in repeated drawsThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forThis marginal iid count model does not represent the joint multinomial counts, subgraph compaction or the bias of a nonlinear GNN.

Check your understanding

A feature-fetch cache merges repeated node IDs from replacement sampling. What preserves the original sampled sum?

Try it yourself

Repeat the occurrence accounting with B=3, f₁=4 and f₂=2 and the same 64-byte feature rows. Separately, for values 2 and 10 sampled once with probabilities 0.8 and 0.2, give an unbiased estimator of their full sum.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Count seeds and both hops. For one unequal-probability draw of node i, the full-sum importance estimator is its value divided by its draw probability.

Compare with the solution

The occurrence total is 3+12+24=39, requiring 2,496 bytes before sharing. The one-draw estimator is 2/0.8=2.5 when the first node is drawn and 10/0.2=50 otherwise. Its expectation is 0.8×2.5+0.2×50=12. Simply doubling the sampled value would instead have expectation 7.2 and would not estimate the full sum.

Take it with you

  • Fanout budgets count an explicitly defined expansion, not every possible subgraph allocation.
  • Feature deduplication must preserve message multiplicities and weights.
  • Local linear unbiasedness does not guarantee an unbiased multilayer nonlinear result.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.