From a537511652ec07107155ead8cdbcbb586df64eab Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Mon, 20 Apr 2026 20:38:56 -0400 Subject: [PATCH] refactor: consolidate hardware optimizer with quant selector (#92) --- evolution/hardware_optimizer.py | 32 ++++++++++++++++++++++++++++---- tests/test_hardware_optimizer.py | 21 +++++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 tests/test_hardware_optimizer.py diff --git a/evolution/hardware_optimizer.py b/evolution/hardware_optimizer.py index 27866e12..67dd7da6 100644 --- a/evolution/hardware_optimizer.py +++ b/evolution/hardware_optimizer.py @@ -1,5 +1,29 @@ -"""Phase 19: Hardware-Aware Inference Optimization. -Part of the TurboQuant suite for local inference excellence. +"""Backward-compatible shim for hardware-aware quantization selection. + +The original Phase 19 placeholder `hardware_optimizer.py` never shipped real +logic. The canonical implementation now lives in `evolution.quant_selector`. +This shim preserves the legacy import path for any downstream callers while +making `quant_selector.py` the single source of truth. """ -import logging -# ... (rest of the code) + +from evolution.quant_selector import ( # noqa: F401 + HardwareInfo, + QuantLevel, + QuantSelection, + QUANT_LEVELS, + detect_hardware, + estimate_kv_cache_gb, + estimate_model_memory_gb, + select_quant_level, +) + +__all__ = [ + "HardwareInfo", + "QuantLevel", + "QuantSelection", + "QUANT_LEVELS", + "detect_hardware", + "estimate_kv_cache_gb", + "estimate_model_memory_gb", + "select_quant_level", +] diff --git a/tests/test_hardware_optimizer.py b/tests/test_hardware_optimizer.py new file mode 100644 index 00000000..72358a1c --- /dev/null +++ b/tests/test_hardware_optimizer.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +"""Tests for hardware_optimizer compatibility shim.""" + +import os +import sys + +sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) + +from evolution import hardware_optimizer, quant_selector + + +def test_hardware_optimizer_reexports_quant_selector_api(): + assert hardware_optimizer.select_quant_level is quant_selector.select_quant_level + assert hardware_optimizer.detect_hardware is quant_selector.detect_hardware + assert hardware_optimizer.HardwareInfo is quant_selector.HardwareInfo + assert hardware_optimizer.QuantSelection is quant_selector.QuantSelection + + +def test_hardware_optimizer_exports_quant_level_definitions(): + assert hardware_optimizer.QUANT_LEVELS is quant_selector.QUANT_LEVELS + assert hardware_optimizer.QuantLevel is quant_selector.QuantLevel