Inferensys

Glossary

Sample Ratio Mismatch

A diagnostic check that verifies if the observed traffic split between control and treatment groups matches the intended randomization ratio, serving as a primary guardrail for detecting bugs in the experimentation infrastructure.
MLOps engineer reviewing model serving infrastructure on laptop, container orchestration visible, technical workspace.
SRM

What is Sample Ratio Mismatch?

A diagnostic check verifying that the observed traffic split between control and treatment groups matches the intended randomization ratio, serving as a primary guardrail for detecting bugs in experimentation infrastructure.

Sample Ratio Mismatch (SRM) is a critical validity check in online controlled experiments that detects when the observed user allocation between variants deviates statistically from the pre-specified randomization ratio. It is the first diagnostic run on any A/B test, as a failure indicates a fundamental breakdown in the randomization pipeline—such as bot traffic filtration, residual bias in a hash function, or a bug in the experiment configuration service—rendering downstream metric comparisons invalid.

SRM is detected using a Chi-Squared Test comparing observed counts against expected counts. A significant p-value signals that the traffic diversion mechanism is broken, often due to treatment group crashes causing differential dropout or instrumentation errors silently dropping users from one variant. Unlike metric movements, SRM is a non-negotiable invariant; a failed SRM check requires immediate experiment termination and a root-cause investigation into the feature flag delivery system before any causal conclusions can be drawn.

EXPERIMENTATION GUARDRAILS

Frequently Asked Questions

Critical diagnostic checks that validate the integrity of your A/B testing infrastructure before you trust the results.

A Sample Ratio Mismatch (SRM) is a diagnostic check that verifies whether the observed traffic split between control and treatment groups matches the intended randomization ratio, serving as a primary guardrail for detecting bugs in the experimentation infrastructure. It works by comparing the actual number of users assigned to each variant against the expected allocation using a Chi-Squared Goodness of Fit test. For example, if you configure a 50/50 split but observe 5,100 users in control and 4,900 in treatment, the SRM check calculates a p-value to determine if this deviation is statistically significant or just random noise. A significant p-value (typically < 0.001) triggers an alert, indicating a critical failure in the randomization pipeline—such as a hash collision, a misconfigured load balancer, or a bot filtering rule that asymmetrically drops users from one variant. SRM is the first metric any experimentation platform should evaluate before analyzing treatment effects because if the randomization is broken, all downstream causal conclusions are invalid.

GUARDRAIL METRIC

How Sample Ratio Mismatch Detection Works

Sample Ratio Mismatch (SRM) is a diagnostic check that verifies if the observed traffic split between control and treatment groups matches the intended randomization ratio, serving as a primary guardrail for detecting bugs in the experimentation infrastructure.

Sample Ratio Mismatch detection operates by applying a Chi-Squared Test to compare the expected user counts against the observed user counts in each experimental variant. If the p-value falls below a strict threshold, typically 0.001, the test signals an SRM, indicating a critical failure in the randomization pipeline, such as a bot filtering bias or a faulty hash function, rather than a natural statistical fluctuation.

This diagnostic serves as a non-negotiable pre-condition for analyzing any Online Controlled Experiment. An SRM invalidates all downstream metric calculations because the treatment and control populations are no longer statistically equivalent. Common root causes include residual Data Leakage from test rollouts, browser redirect loops, or crashes in a specific variant that prevent users from being properly assigned and tracked.

DIAGNOSTIC GUARDRAIL

Key Characteristics of SRM

Sample Ratio Mismatch (SRM) is the primary canary in the coal mine for your experimentation platform. It verifies that the observed traffic split matches the intended randomization ratio, catching bugs in hashing algorithms, bot filtering, and variant assignment before they silently invalidate your results.

01

The Chi-Squared Sentinel

SRM detection relies on a Pearson's Chi-Squared test comparing observed user counts against expected counts. If you intend a 50/50 split but observe 50,100 in control and 49,900 in treatment, the test quantifies the probability this deviation is due to chance. A p-value below 0.001 typically triggers an automatic alarm, halting the experiment. This is not a metric evaluation; it is a pre-statistical infrastructure check that must pass before any analysis of lift or significance is valid.

02

Common Root Causes

SRM rarely indicates a problem with your model. It almost always signals a pipeline bug upstream of the analysis:

  • Hashing Collisions: A non-uniform randomization seed causing deterministic bias in variant assignment.
  • Residual Bot Traffic: Automated scrapers or click-farm traffic that bypasses your bot detection, artificially inflating one variant.
  • Funnel Filtration: A downstream filter (e.g., 'active users only') that differentially removes users from one variant due to a performance bug.
  • Telemetry Loss: A logging outage in one data center causing systematic data loss for a specific treatment group.
03

SRM vs. AA Test

While related, these are distinct validation layers:

  • SRM Check: A continuous, automated monitor running on every live experiment. It uses a simple count of randomized units to detect assignment failures.
  • AA Test: A deliberate, time-bound experiment where both groups receive the identical control experience. It validates the entire metric computation pipeline, ensuring no false positives arise from variance in metric definitions. An AA test can pass while SRM fails if the assignment is broken but the metric logging is consistent.
04

Severity Thresholds

Not all mismatches are fatal. The severity is a function of sample size and deviation magnitude:

  • Tiny Sample: A 0.1% deviation on 1,000 users is likely noise.
  • Massive Sample: A 0.1% deviation on 100 million users is almost certainly a systemic bug. The Chi-Squared statistic is sensitive to sample size, correctly flagging trivial percentage deviations as critical when the absolute user count is large enough to rule out random chance.
05

The SUTVA Connection

SRM can be an early symptom of a Stable Unit Treatment Value Assumption (SUTVA) violation. In social networks or ride-sharing marketplaces, if a treatment user invites a control user to the app, the control user's experience is contaminated. This 'interference' can manifest as a traffic imbalance because the treatment group is effectively 'generating' new users who are then incorrectly bucketed, skewing the observed ratio.

06

Remediation Protocol

When the SRM alarm fires, the experiment is immediately quarantined. The standard triage workflow:

  1. Freeze Traffic: Stop the experiment to prevent further data corruption.
  2. Segment Diagnosis: Slice the mismatch by platform (iOS vs. Android), browser, or geography to isolate the faulty component.
  3. Hash Audit: Verify the randomization seed and salt used by the experimentation library.
  4. Bot Replay: Run the logged traffic through a secondary, stricter bot-detection model. Results from an SRM-flagged experiment are statistically unusable and must be discarded.
DIAGNOSTIC COMPARISON

SRM vs. Other Experimentation Guardrails

A comparison of Sample Ratio Mismatch against other critical validation checks used to ensure the integrity of online controlled experiments.

GuardrailSample Ratio MismatchA/A TestMinimum Detectable Effect

Primary Function

Validates traffic split integrity

Validates Type I error rate

Validates test sensitivity

Detection Target

Buggy randomization or data pipeline filtering

Systematic bias in metric calculation

Underpowered experiment design

Statistical Test

Chi-Squared Goodness of Fit

Two-Sample T-Test

Power Analysis

Null Hypothesis

Observed ratio equals intended ratio

No difference between identical groups

Effect is smaller than detectable threshold

Timing

Continuous monitoring during experiment

Pre-experiment infrastructure validation

Pre-experiment design phase

Failure Consequence

Invalidates all downstream metric results

Inflated false positive rate

Inability to detect true effects

Automated Alerting

Typical Threshold

p < 0.001

p > 0.05 for metric parity

80% statistical power

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.