A robot passes 18 of 20 trials. Its true success rate could be anything from 70% to 97%. Testing a learned robot is mostly the craft of knowing how many trials it takes to be sure.
Pick how many trials to run, then press Run. Watch where the pink 85% gate falls inside the range. Then we build, piece by piece, the oracles, intervals, gates, simulator checks and hardware tests that turn a merge into a robot you can ship.
You need a little Python and what a probability is. We build the rest from zero.
The running example is Rhoda AI’s Direct Video-Action model, as described on Rhoda’s research page. The testing methods are general. All test numbers on this page are illustrative unless a line says otherwise.
Illustrative: the simulated robot succeeds 90% of the time, and one trial takes 4 minutes. The first run of each size shows a 90% pass count; later runs draw new random trials. The range is the 95% Wilson interval from Chapter 2.
Chapter 0
See the chain of tests between a code change and a robot at work, and what each link costs
An engineer merges a new model at 4 pm. By morning it drives a robot arm that lifts boxes beside people. Between those two moments, someone must turn "the code compiles" into "the robot is safe and works". That chain of evidence is the job of quality engineering (QE): the tests, the rigs and the rules that decide a release.
Our running example is Rhoda AI’s Direct Video-Action model (DVA), as Rhoda describes it on its research page. A causal video model predicts the next frames of camera video. A small inverse dynamics model turns those predicted frames into robot actions; Rhoda reports it needs about 10 hours of data.
Each video prediction is long enough to cover the latency of the next prediction. Rhoda reports one box-breakdown run of 160 minutes without a human stepping in. Rhoda rates its robot for a 25 kg payload.
Every layer here is stochastic or physical. The video model gives a different future each run. Joints wear and warm up. So no single test can decide a release. You build a ladder of tests: cheap and fast at the bottom, slow and real at the top.
Each rung is one test level. The yellow bar is minutes per run, on a log scale. Pick a rung to see what it catches and what it misses.
Illustrative times for a typical robot learning team, not Rhoda’s numbers. HIL means hardware in the loop: tests on the real robot.
Look at the cost column. A unit suite runs 50 times a day for 5 minutes each. A hardware run takes 3 hours and runs once a night. So a bug caught at the bottom costs minutes, and the same bug caught on the robot costs a night. The rule of the ladder: catch each bug at the lowest rung that can see it.
The failure to watch for: the symptom is a hardware queue full of runs that fail on simple bugs. Measure it by labelling each hardware failure with the lowest rung that could have caught it. The fix is to add that check lower down.
Chapter 1
Replace exact-match asserts with property checks that every good answer must pass
Feed the video model the same camera frame twice. You get two different predicted futures, and both look fine. So assert out == expected fails on every run. There is no single right answer to compare against.
A test oracle is the rule that decides pass or fail. For a stochastic model, the oracle checks properties: facts that every acceptable answer shares. A joint stays inside its range. An object does not jump across the table between frames. A joint never moves faster than its motor allows. Each property is deterministic, so the test is deterministic even when the model is not.
Take the speed property. The robot sends a joint angle every control step. Call the angle at step t θt, the time between steps Δt, and the fastest safe joint speed vmax.
v equals the absolute value of theta-t-plus-one minus theta-t, over delta-t, and it must be at most v-max.
Subtract theta-t from theta-t-plus-one and drop the sign. Divide by delta-t to get the speed v. If v is ever above v-max, the sample fails.
With made-up numbers: angles 0.40, 0.46, 0.61, 0.65 rad and delta-t 0.1 s. The speeds are 0.6, 1.5 and 0.4 rad/s. The middle step breaks the 1.0 limit, so the sample fails, even though the start and the end look fine.
Eight samples of one joint from the same input. No two match. Drag the limit, or inject a glitch, and see which samples the oracle fails.
Illustrative samples. A real suite checks every joint, every frame pair and several properties at once.
Properties catch the failures that matter, but not all of them. A sample can obey every limit and still reach for the wrong box. So the oracle ladder has three parts. Property checks are fast and exact. Perceptual scores on predicted video sit in the middle. Task success in simulation or on hardware is slow and final, and Chapters 2 to 5 handle it.
The failure: a property check with a loose limit. The symptom is a passing suite while the robot jerks on hardware. Measure the real top speed in logs from good runs. Set the limit from that data and from the motor's rating, not from a guess.
Chapter 2
Turn k successes in n trials into an interval, and see how slowly it shrinks
The robot breaks down boxes. You run 60 trials and it succeeds in 51. The report says 85%. Run another 60 tomorrow and you might see 47 or 55. The 85% is one draw from a range of results the same robot could give.
Each trial is a pass or a fail. Call the true success rate p, the number of trials n, and the measured rate p̂ ("p-hat"), which is successes divided by n. The standard error is the typical distance between p-hat and p. A 95% confidence interval is a range built so that, over many repeats, 95 of 100 such ranges contain p.
p-hat, plus or minus 1.96 times the square root of p-hat times one minus p-hat, over n.
Multiply p-hat by one minus p-hat. Divide by n and take the square root: that is the standard error. Go 1.96 standard errors below and above p-hat.
With made-up numbers: 51 successes in n = 60, so p-hat = 0.85. The standard error is √(0.85 × 0.15 / 60) = 0.046. The range is 0.85 ± 0.090, from 76% to 94%. The same robot could be below an 85% target or well above it.
Each teal bar is one experiment of n trials and its 95% range. The dashed line is the true rate. Red bars miss it. Drag n and watch the bars shrink.
Simulated trials with a random number generator. The bars use the formula above.
The width falls with the square root of n. To halve the range you need four times the trials. At 60 trials the half-width is 9 points; at 240 it is 4.5. On a robot where a trial takes minutes, that square root sets your whole test budget.
The failure: the formula breaks near 0% and 100%. With 20 of 20 passes it gives a width of zero, which is false. Use the Wilson interval there; it stays honest at the edges. The hero and the field guide code use Wilson.
Chapter 3
Size an A/B test before you book the robot, and price it in robot-hours
A new model is ready. You want to know if it is worse than the one in production. You will run both on the same task, trial after trial, alternating. How many trials do you book? Too few and a real drop hides in the noise. Too many and you burn a week of robot time.
Two numbers set the answer. The significance level is how often you accept a false alarm; 5% is usual. The power is how often you catch a real drop of a chosen size; 80% is usual. Call the baseline success rate p1 and the rate you must detect p2.
n equals z-alpha plus z-beta, squared, times the sum of p-one times one minus p-one and p-two times one minus p-two, over p-one minus p-two, squared.
Add z-alpha and z-beta and square the sum. Multiply by the noise of each model, p times one minus p, added. Divide by the squared drop. That is n per model.
With made-up numbers: p-one = 0.85, p-two = 0.75. (1.96 + 0.84)2 = 7.85. The noise sum is 0.1275 + 0.1875 = 0.315. The squared drop is 0.01. So n = 7.85 × 0.315 / 0.01 = 247.2, which rounds up to 248 trials per model.
The curve is trials per model against the drop you must catch, on a log scale. Drag the drop and the baseline. The yellow read-out is the bill.
5% false alarms, 80% power, two models. Illustrative 4 minutes per trial. The faint marker shows what 60 trials per model can detect.
Two models at 248 trials each is 496 trials. At 4 minutes a trial that is 33 robot-hours. A drop of 5 points from 85% needs 903 trials per model. So you choose the smallest drop that matters to the customer, and you size for that.
The failure: an underpowered test. The symptom is "no significant difference" from 60 trials per model. Measure what 60 can detect: from 85%, only a drop of about 22 points. Fix it by booking the sized number, or by testing paired episodes (Chapter 5), which removes some noise.
Chapter 4
Measure what a streak of passes proves, and when a test may leave quarantine
A simulation test fails twice in 20 runs, then passes again. Nobody changed the code. That is a flaky test: one that fails some of the time for the same input. Flaky tests are dangerous in two ways. Engineers learn to ignore red, and a real bug can hide behind "it is just flaky".
The usual policy is a quarantine: a flaky test still runs, but it cannot block a merge, and someone owns the fix. The hard question is when to let it out. "It passed 50 times in a row" sounds strong. How strong is it?
Call the chance that one run fails f, and the number of runs n. If runs are independent, the chance that a flaky test passes every run is:
P-hide equals one minus f, to the power n.
Take the pass chance of one run, one minus f. Multiply it by itself n times. That is P-hide, the chance that n clean runs come from a test that is still flaky.
With made-up numbers: f = 0.02 and n = 50. P-hide = 0.9850 = 0.36. A test that fails 1 run in 50 still shows 50 clean runs about one time in three.
Turn the question around. After n clean runs, which failure rates are still plausible? Set P-hide to 5% and solve for f. For large n this gives the rule of three:
Fifty clean runs say only "f is probably below 6%". To claim below 1%, you need about 300 clean runs.
The red curve is P-hide against the number of runs. The pink line marks 5%. Drag the failure rate and the streak length.
Assumes independent runs. Flakes that cluster (a busy GPU host, a warm room) hide longer than this.
The failure: a rule like "below 98% pass rate over 30 runs is flaky". Thirty runs cannot measure 98%: one failure already gives 96.7%. Measure the exit rule with this formula before you adopt it. Then pick n from the failure rate you can live with.
Chapter 5
Block a release on a canonical episode, or on an interval that allows too big a drop
A regression is something that worked before and now fails. A regression gate is the automatic rule that blocks a release when the evidence shows one. A robot model gate has two parts, and both must pass.
Part one is the canonical episodes: recorded scenes of past failures that the team fixed. A crushed box corner, a glare on the tote, a box half off the table. Each new model replays all of them. One failure blocks the release, even if the average went up. A gain on average does not pay for a known bug coming back.
Part two judges the aggregate success rate as a non-inferiority test. The new model may be a little worse, but not more than a chosen margin. Call the baseline rate p̂1 over n1 trials and the candidate rate p̂2 over n2. The measured difference is Δ̂ = p̂2 − p̂1.
Delta-hat, plus or minus 1.96 times the square root of p-one-hat times one minus p-one-hat over n-one, plus p-two-hat times one minus p-two-hat over n-two.
Add the two noises and take the square root. Go 1.96 of those below and above delta-hat. If the low end is below minus the margin, block.
With made-up numbers: baseline 170 of 200 (0.85), candidate 174 of 200 (0.87). Delta-hat = +0.02. The root of 0.1275/200 + 0.1131/200 is 0.035. The range is −0.048 to +0.088. The margin is 5 points, and −4.8 is above −5, so the aggregate part passes, by a hair.
Tap a canonical episode to make it fail. Drag the candidate's success count and the trials. The bar is the 95% range of the difference; the pink line is the margin.
Illustrative: baseline 85% on the same number of trials, margin 5 points. The episode names are made-up examples of scenes a team records.
Drag the trials down to 50. The candidate still looks better on average, but the range now reaches far below the margin, and the gate blocks. A small test cannot prove "not worse". That is the gate doing its job.
The failure: a gate on the point estimate alone ("block if the new rate is lower"). Noise then blocks good models half the time and lets bad ones through. Measure your gate by replaying old releases through it. Fix it with the interval and a margin the product owner signs.
Chapter 6
Use simulation as a cheap proxy, and learn what its number predicts on the robot
A simulator runs thousands of trials a day for the price of GPUs. A robot runs a few dozen. So most testing happens in sim. But sim is a model of the world, and the model is wrong: no motion blur, perfect friction, no tape on the boxes. The difference is the sim-to-real gap.
To use sim safely, track every model version in both places. Plot sim success against real success. Two different numbers come out of that plot:
Each dot is one model version. Purple axis is sim, teal axis is real. The dashed line is where sim would equal real. Add gap noise and watch r fall.
Illustrative versions. Gap noise adds a fixed random offset to each real score, like a sim that misses a different effect for each model.
With made-up numbers: five versions score 62, 70, 78, 84 and 90% in sim, and 41, 47, 52, 60 and 63% on the robot. The correlation is r = 0.99. A line through the points is real = 0.81 × sim − 0.10. So a new model at 88% in sim predicts about 62% real. "Sim says 88%, ship it" would have been a 26-point mistake.
Close the gap where you can. Domain randomization varies light, camera noise, mass and friction in sim, so a policy that passes has seen variety. When a real failure happens, replay it in sim. If sim does not fail too, add the missing effect.
The failure: r drifts down over months. The robot's grippers wear, a new camera mount arrives, sim stays the same. Measure r every few hardware sessions on matched episodes. If it drops, stop trusting sim gates until you refit.
Chapter 7
Run each robot session in a fixed order, and turn stop latency into stopping distance
Hardware in the loop (HIL) means automated tests on the real robot, cameras and sensors. A HIL session runs at night without a person watching. So the order of checks matters. Each step must pass before the next one runs.
Why does stop latency matter so much? Call the arm speed v, the time from stop signal to the start of braking t, and the braking deceleration a. The arm keeps moving at full speed during t, then slows to zero.
d equals v times t, plus v squared over two a.
Multiply speed v by latency t: that is the distance before braking. Add v squared over two a: that is the braking distance. The sum is d.
With made-up numbers: v = 1.0 m/s, t = 0.1 s, a = 5 m/s². d = 0.10 + 1.0 / 10 = 0.20 m. If latency grows to 0.3 s, d = 0.40 m. Each extra 100 ms adds 10 cm at this speed.
The arm moves right. Pink is the edge of the safe zone. Yellow is distance lost to latency; teal is braking. Drag speed and latency.
Illustrative: braking at 5 m/s² and a 0.30 m margin. Real values come from the robot maker's stop data and the site risk assessment.
Industrial robot safety follows standards: ISO 10218 for industrial robots and ISO/TS 15066 where people share the space. Stop types come from IEC 60204-1. A category 0 stop cuts power at once. A category 1 stop brakes under control, then cuts power. Your test measures time from signal to zero speed from encoder logs, every session.
The failure: stop latency that grows under load. The symptom is a stop time that is fine at idle and late during heavy inference. Measure it while the GPU is busy. Fix it with a stop path that does not depend on the model's computer.
Chapter 8
Test that each prediction arrives before the last one runs out, and count the stalls per hour
Rhoda describes DVA’s timing in one rule: each video prediction is long enough to cover the latency of the next prediction. So the robot always has motion to execute while the model thinks. Call the time a prediction covers the horizon. If one prediction takes longer than the horizon, the robot runs out of plan and pauses. That pause is a stall.
Average latency does not decide this. The tail does: the slowest runs. The P50 is the latency half the runs beat; the P99 is the latency 99 of 100 runs beat. A model with a fine average and a long tail stalls all day.
The hill is how often each latency happens. Pink is the horizon. Red area is stalls. Drag the median and the spread.
Illustrative: a log-normal latency, a 150 ms horizon and 10 predictions a second. Rhoda does not publish its latency numbers; these are not them.
With made-up numbers: 10 predictions a second is 36,000 an hour. If 1% run past the horizon, that is 360 stalls an hour, one every 10 seconds. At 0.1% it is 36 stalls an hour. That is why the test reports P99 and the stall count, not the mean.
Pin the benchmark so runs compare: the same GPU model, the same context length, the same input size, the same batch. Change one, and it is a new benchmark, not a comparison. DVA keeps hundreds of frames of context, so also log GPU memory across a full run. It should level off, not climb.
The failure: latency measured on an idle machine. The symptom is smooth motion in the lab and stutter at the site. Measure under the real load, for the full task length. Fix it by testing the tail under stress: slow the model by 20%, 40%, 60% and count stalls.
Chapter 9
Bound the intervention rate from a clean run, then trace a failure to its layer
Rhoda reports a box-breakdown run of 160 minutes with no human stepping in. What does one clean run like that prove? It is the rule of three again, now for time. An intervention is any moment a person must step in. Call the run length T and the true interventions per hour λ ("lambda").
Lambda-max is about three over T.
Add up the hours with no intervention, T. Divide 3 by T. Rates above lambda-max would almost never give a run that clean.
With the reported 160 minutes, T = 2.67 hours. Lambda-max = 3 / 2.67 = 1.1 interventions per hour. To claim below 0.5 per hour from clean time alone, you need 3 / 0.5 = 6 clean hours.
Long runs also catch drift. Joints warm up, the GPU throttles, memory grows. Log joint temperature, latency and memory across the run, and compare the last hour with the first.
When a task fails, you have the recording: camera frames, predicted video, actions, commanded and measured joints. DVA has four layers, and the predicted video lets you inspect the first one directly. Ask three questions in order.
Answer each question from the recording. Green marks a cleared layer; red marks where to look.
A teaching sketch of the attribution order. The second question replays the actions in a simulator and compares the motion with the predicted video.
The failure: blaming the model by default. The symptom is a retrain that does not fix the bug. Measure each layer from the logs first. A worn gearbox shows up as joints that do not track commands, and no retrain fixes that.
Chapter 10
Keep the numbers, the checklist and the code for the next release
You test a learned robot with evidence, not with a single pass. Property oracles handle stochastic outputs. Intervals and sample sizes turn trials into decisions. Gates combine canonical episodes with a margin. Sim is a calibrated proxy. Hardware sessions run in a safe order, and long runs bound the intervention rate.
| Term | What it is | Key number |
|---|---|---|
| Property oracle | a check every good sample passes | speed 1.5 rad/s fails a 1.0 limit |
| 95% interval | p-hat ± 1.96 standard errors | 51/60: 76% to 94% |
| A/B sample size | trials per model for 80% power | 85% vs 75%: 248 each |
| P-hide | (1 − f)n | 0.9850 = 0.36 |
| Rule of three | 0 failures in n: f below 3/n | 50 runs: 6% |
| Non-inferiority gate | low end of the difference above −margin | −4.8 vs −5: pass |
| Sim calibration | fitted line from sim to real | sim 88% predicts real 62% |
| Stopping distance | v·t + v2/(2a) | 1 m/s, 0.1 s: 0.20 m |
| Stalls per hour | share past horizon × predictions per hour | 1% of 36,000 = 360 |
| Intervention bound | 3 / clean hours | 160 min: 1.1 per hour |
pythonfrom math import sqrt, ceil def wilson(k, n, z=1.96): # k successes in n trials p = k / n; d = 1 + z*z/n c = (p + z*z/(2*n)) / d h = z * sqrt(p*(1-p)/n + z*z/(4*n*n)) / d return c - h, c + h # wilson(18, 20) -> (0.699, 0.972) def n_per_arm(p1, p2, za=1.96, zb=0.8416): return ceil((za+zb)**2 * (p1*(1-p1) + p2*(1-p2)) / (p1-p2)**2) # (0.85, 0.75) -> 248 def p_hide(f, n): return (1 - f) ** n # (0.02, 50) -> 0.364 def gate(k1, n1, k2, n2, margin=0.05, canon_ok=True): p1, p2 = k1/n1, k2/n2 se = sqrt(p1*(1-p1)/n1 + p2*(1-p2)/n2) low = (p2 - p1) - 1.96*se return canon_ok and low > -margin # (170,200,174,200) -> True, low = -0.048
Sources for the Rhoda facts. The 160-minute run, about 10 hours of inverse dynamics data, the prediction-covers-latency rule and hundreds of frames of context come from Causal Video Models Are Data-Efficient Robot Policy Learners. The 25 kg rated payload comes from rhoda.ai.
Now press Present or Teach and explain from memory. Why is 18 of 20 not enough? How do you size an A/B test? What do 50 clean runs prove? Why can r = 0.99 mislead? Then go back to the hero and find the smallest trial count that proves 85%.