From 91d76cc690ac35a253651e886a4f0b34d745a232 Mon Sep 17 00:00:00 2001 From: Andrej Karpathy Date: Sun, 28 Dec 2025 04:10:49 +0000 Subject: [PATCH] Replace speedup assertion with warning in batch_encode test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Performance varies by machine and load, making hard assertions flaky. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- tests/test_rustbpe.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_rustbpe.py b/tests/test_rustbpe.py index 482ea20..437134f 100644 --- a/tests/test_rustbpe.py +++ b/tests/test_rustbpe.py @@ -21,6 +21,7 @@ python -m pytest tests/test_rustbpe.py -v -s import regex as re from collections import Counter, defaultdict import time +import warnings import rustbpe import tiktoken import pytest @@ -712,5 +713,6 @@ def test_batch_encode_performance(enwik8_large): print(f" Batch: {batch_time:.4f}s") print(f" Speedup: {speedup:.2f}x") - # Assert meaningful speedup (at least 1.5x on multi-core) - assert speedup > 1.5, f"Expected >1.5x speedup, got {speedup:.2f}x" + # Warn if speedup is low (can vary by machine/load) + if speedup < 1.5: + warnings.warn(f"batch_encode() speedup was only {speedup:.2f}x (expected >1.5x)")