diff --git a/examples/speculative_decoding/scripts/ar_validate.py b/examples/speculative_decoding/scripts/ar_validate.py index 5699c480b7b..d8c28af48d7 100644 --- a/examples/speculative_decoding/scripts/ar_validate.py +++ b/examples/speculative_decoding/scripts/ar_validate.py @@ -123,7 +123,24 @@ def main(): accelerator.device, ) - if results and accelerator.is_main_process: + # validate_ar() clamps to len(ds), so report what was actually attempted rather than the + # requested --num_samples, which can be larger than the dataset. A non-positive count means + # nothing ran at all -- distinct from "everything ran and failed", so say so separately. + attempted = min(args.num_samples, len(ds)) + if attempted <= 0: + raise ValueError( + f"No samples to validate: --num_samples={args.num_samples} with a dataset of " + f"{len(ds)} prompts. Pass a positive --num_samples." + ) + + if not results: + raise RuntimeError( + f"AR validation produced no results: all {attempted} samples failed. " + "See the per-sample WARNING lines above for the underlying error. " + "Exiting non-zero so this is not mistaken for a successful validation." + ) + + if accelerator.is_main_process: all_ars = [ar for _, ar in results] avg_ar = sum(all_ars) / len(all_ars) print(f"\n==== AR Validation Results (osl={args.osl}, steps={args.steps}) ====")