Skip to content

Commit 9191687

Browse files
committed
Update evaluator.py
1 parent 83284e8 commit 9191687

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

examples/mlx_metal_kernel_opt/evaluator.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
from typing import Dict, List, Tuple, Any, Optional
2626
import numpy as np
2727

28-
# Add paths for imports
29-
sys.path.insert(0, "/Users/asankhaya/Documents/GitHub/mlx-lm")
28+
# Add current directory to path for imports
3029
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
3130

3231
import mlx.core as mx
@@ -41,7 +40,6 @@ class CustomGQAEvaluator:
4140

4241
def __init__(self):
4342
self.model_path = "mlx-community/Qwen3-0.6B-bf16"
44-
self.mlx_lm_dir = "/Users/asankhaya/Documents/GitHub/mlx-lm"
4543

4644
# Baseline performance from comprehensive benchmark
4745
self.baseline_metrics = {
@@ -99,12 +97,13 @@ def _create_long_prompt(self) -> str:
9997
Question: Analyze the computational and memory efficiency benefits of GQA compared to standard multi-head attention."""
10098

10199
def evaluate(self, program_text: str) -> Dict[str, Any]:
102-
"""
103-
Evaluate an evolved custom GQA implementation by:
100+
"""Evaluate an evolved custom GQA implementation by:
104101
1. Executing the program to extract CustomGQAAttention
105102
2. Testing correctness vs standard implementation
106103
3. Hooking into mlx-lm for real inference testing
107104
4. Measuring performance improvements
105+
106+
Note: Requires mlx-lm to be installed (pip install mlx-lm)
108107
"""
109108

110109
print("\n" + "=" * 80)
@@ -190,7 +189,6 @@ def _execute_evolved_program(self, program_text: str) -> Optional[Any]:
190189

191190
# Add mlx_lm imports for RoPE
192191
try:
193-
sys.path.insert(0, self.mlx_lm_dir)
194192
exec_globals["mlx_lm"] = __import__("mlx_lm")
195193
except ImportError:
196194
print("⚠️ Could not import mlx_lm, RoPE may not work")
@@ -335,9 +333,6 @@ def _run_single_benchmark_with_custom_attention(
335333
MEASUREMENT_RUNS = 7 # Statistical significance (odd number for median)
336334

337335
try:
338-
original_dir = os.getcwd()
339-
os.chdir(self.mlx_lm_dir)
340-
341336
# Build mlx-lm command
342337
cmd = [
343338
"python",
@@ -486,8 +481,6 @@ def _run_single_benchmark_with_custom_attention(
486481
except Exception as e:
487482
print(f" ❌ Benchmark error: {e}")
488483
return None
489-
finally:
490-
os.chdir(original_dir)
491484

492485
def _parse_mlx_lm_output(
493486
self, stdout: str, config: BenchmarkConfig, total_time: float

0 commit comments

Comments
 (0)