diff --git a/tests/test_quant_selector.py b/tests/test_quant_selector.py index 5447d143..faa8b219 100644 --- a/tests/test_quant_selector.py +++ b/tests/test_quant_selector.py @@ -20,9 +20,26 @@ from evolution.quant_selector import ( class TestQuantLevels: def test_levels_ordered_by_quality(self): - """Levels should be ordered from best quality to most aggressive.""" - for i in range(len(QUANT_LEVELS) - 1): - assert QUANT_LEVELS[i].bits_per_channel > QUANT_LEVELS[i + 1].bits_per_channel + """Levels should be ordered from best quality to most aggressive. + + TurboQuant levels (turbo4, turbo3, turbo2) are ordered by descending + bits_per_channel (higher = better quality). The standard fallback q4_0 + comes last regardless of its bits value — it's a different quantization + scheme (standard vs TurboQuant) and serves as a last-resort fallback. + """ + # TurboQuant levels must be strictly descending in bits + turbo_levels = [l for l in QUANT_LEVELS if l.kv_type.startswith("turbo")] + for i in range(len(turbo_levels) - 1): + assert turbo_levels[i].bits_per_channel > turbo_levels[i + 1].bits_per_channel + + # Standard fallback(s) must come after all TurboQuant levels + standard_levels = [l for l in QUANT_LEVELS if not l.kv_type.startswith("turbo")] + if standard_levels: + last_turbo = turbo_levels[-1] + for std in standard_levels: + turbo_idx = QUANT_LEVELS.index(last_turbo) + std_idx = QUANT_LEVELS.index(std) + assert std_idx > turbo_idx, f"{std.name} should come after all TurboQuant levels" def test_all_levels_have_required_fields(self): for level in QUANT_LEVELS: