skip to content

Why does each experiment layer hash users with its own independent seed?

level: middleimportance: should knowfreq 54%

answer

  1. the seed is what separates the layers
  2. same seed, same hash, same bucket
  3. avalanche: one bit reshuffles everything
  4. shared seed makes effects collinear
  5. check the joint table, not the marginals

basics

~10 s

Independent seeds make assignment in one layer statistically independent of every other layer. Reusing one seed sends the same users to the same arm position in both layers, perfectly confounding the two experiments.

solid answer

~50 s

Each layer assigns a user by hashing the user id combined with that layer's own seed, then mapping the hash to an arm. The seed is what makes the layers independent: with a good hash, changing the seed reshuffles users into completely unrelated buckets, so the layer-2 assignment carries no information about the layer-1 assignment. If two layers share a seed, they compute the identical hash for every user and therefore the identical bucket, so the set of users in treatment for experiment A is exactly the set in treatment for experiment B. The two effects are then perfectly collinear — no amount of data separates them, and neither result is interpretable. The check is a cross-tabulation: count users in each combination of layer-1 arm and layer-2 arm and confirm the cells sit near the product of the marginals rather than piling on the diagonal.

go deeper

for a junior

Know that assignment comes from hashing the user id with something layer-specific, and that if two layers use the same seed every user lands in the same arm position in both.

for a middle

Explain the mechanism end to end: hash plus seed maps to arm ranges, avalanche makes different seeds produce unrelated buckets, and identical seeds make the two treatment indicators one and the same column.

for a senior

Demonstrate the diagnosis. Cross-tabulate the joint arm distribution, recognise partial correlation from a weak hash as the sneakier failure, and be clear that no post-hoc adjustment recovers collinear effects.

for a principal

Argue for seed management as platform policy — seeds owned and rotated centrally, joint-independence checks running continuously rather than only when someone suspects a problem.

## How a layered assignment is computed A layered platform assigns arms deterministically from an identifier. For a given layer it forms a string from the randomization unit's id together with a value that is specific to that layer — commonly called the layer's seed, salt, or key — hashes it, and maps the resulting number onto the arm ranges. A 50/50 split, for instance, takes the low half of the hash range as control and the high half as treatment. Determinism is what makes the assignment reproducible: the platform never has to store a per-user decision, and any service can recompute the same answer. But determinism also means the seed is the *only* thing that distinguishes one layer's shuffle from another's. ## What the seed actually buys A cryptographic-quality hash has the avalanche property: changing any input bit changes roughly half the output bits, in a way that is unpredictable from the original output. Consequently, hashing `user123:layerA` and `user123:layerB` produces two numbers with no usable relationship. Across the population, the pair of arm assignments behaves like two independent draws. That independence is the entire mechanism behind overlapping experiments. It gives you, for every experiment, a treatment group and a control group that look alike with respect to **every other running experiment** — same proportion in each of the other layers' arms, in expectation. Any effect from those other experiments therefore lands equally on both of my sides and cancels from my difference of means. ## The failure mode: a shared seed Suppose two layers are configured with the same seed by copy-paste. Now `hash(user:seed)` is the same number in both layers, so a user in the low half of the range is in control for *both* experiments and a user in the high half is in treatment for *both*. The cross-tabulation of the two layers' arms has two full cells and two empty ones. Everyone who saw experiment A's treatment also saw experiment B's treatment. The consequence is not a small bias — it is total non-identifiability. The measured lift for experiment A is the combined lift of A and B together, and so is the measured lift for B. You cannot attribute the movement to either change, and if the two changes push in opposite directions you may see both experiments read flat while both are individually doing something. No statistical adjustment recovers the separate effects, because the data contain no users who received one treatment without the other. A subtler version of the same defect: layers seeded by a short counter concatenated in a weak way, or a non-avalanching hash (a simple modulus of a numeric id, a checksum), can leave partial correlation between layers. The assignments are then neither identical nor independent, and the other experiment is *unevenly* distributed across your arms — a genuine confound that quietly biases your estimate. ## Diagnosing it The direct test is a joint frequency check. Take a period's exposure logs, cross-tabulate the arm held in layer 1 against the arm held in layer 2, and compare each observed cell count with the product of the two marginal proportions times the total. Under independence, a 50/50 layer crossed with a 50/50 layer should put about a quarter of users in each of the four cells. A diagonal concentration means a shared or correlated seed. A milder skew — say 30/20/20/30 — signals partial correlation and is just as much a bug. It is worth stressing that checking each layer *alone* proves nothing here. Both layers can be perfectly balanced on their own marginals while being completely dependent on each other; the marginals of a diagonal table are exactly 50/50. Independence is a property of the joint distribution, so it must be checked jointly. ## Related seed hygiene The seed should also be stable for the life of the experiment, because changing it mid-flight reshuffles the population and mixes two different randomizations into one analysis. And a seed that has been used before deserves care: rotating it when a layer is reused prevents the previous experiment's arm boundaries from lining up with the new one's. ## What an interviewer is listening for That the candidate can say *why* a shared seed is fatal rather than merely undesirable — the two treatments become perfectly collinear and neither is identifiable — and that they know the check lives in the joint table, not in each layer's own balance.

  • What does the cross-tabulation of two layers' arms look like when the seeds are shared?
    It collapses onto the diagonal: with two 50/50 layers, roughly half the users sit in the control-control cell and half in the treatment-treatment cell, and the two off-diagonal cells are empty. Under independence each of the four cells should hold about a quarter of users. Notably, each layer's own marginals still read 50/50, so only the joint table exposes the fault.
  • Can you statistically adjust for a shared seed after the fact instead of rerunning?
    No. Adjustment needs users who received one treatment without the other, and a shared seed produces none — the two treatment indicators are identical columns, so their separate effects are not identifiable at any sample size. The only fix is to reseed one layer and rerun. What you can salvage is a reading of the combined change versus doing neither.
  • Why isn't a simple modulus of a numeric user id good enough as a bucketing function?
    Numeric ids often carry structure — signup order, region blocks, id ranges reserved for internal or bulk-created accounts — and a modulus preserves that structure rather than destroying it. Two layers using different moduli on the same id can also end up correlated. A hash with good avalanche behaviour severs the relationship between the id's structure and the bucket.

Two dealers shuffling the same deck with the same shuffle produce identical hands every time; only a different shuffle makes the second deal tell you something new.

saying these in an interview costs you the question

  • Thinks different experiment names alone make layers independent
  • Believes a shared seed only causes a small bias
  • Checks each layer's own balance and calls it independence
  • Claims a regression adjustment can untangle a shared seed
  • Uses a plain modulus of a sequential id as the bucketer

context