Skip to content

Commit 5055a68

Browse files
committed
fix(mlx_metal_kernel_opt): stabilize run script and config
- Fix bash -u background run bug (stdbuf/nohup handling) - Avoid clobbering OPENAI_API_KEY from GEMINI_API_KEY - Use non-preview Gemini model names - Place cascade_evaluation under evaluator and fix 2:1 GQA prompt
1 parent 556811d commit 5055a68

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

examples/mlx_metal_kernel_opt/config.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ log_level: "INFO"
44

55
# LLM configuration for Metal kernel optimization
66
llm:
7-
primary_model: "gemini-2.5-flash-preview-05-20"
7+
primary_model: "gemini-2.5-flash"
88
primary_model_weight: 0.6
9-
secondary_model: "gemini-2.5-pro-preview-06-05"
9+
secondary_model: "gemini-2.5-pro"
1010
secondary_model_weight: 0.4
1111
api_base: "https://generativelanguage.googleapis.com/v1beta/openai/"
1212
temperature: 0.6
@@ -78,7 +78,7 @@ prompt:
7878
// CURRENT: Basic kv_head_idx = head_idx / HEADS_PER_KV
7979
// OPTIMIZE: Leverage the specific 2:1 ratio pattern
8080
81-
// Example: Process 5 query heads together for each KV head
81+
// Example: Process 2 query heads together for each KV head
8282
// Example: Optimize memory layout for the 16:8 pattern
8383
// Example: Reduce broadcast overhead through clever indexing
8484
```
@@ -181,7 +181,7 @@ prompt:
181181
**Strategy 4: GQA Pattern Exploitation**
182182
```metal
183183
// Optimize for the specific 2:1 query:KV ratio
184-
// Process query heads in groups of 5
184+
// Process query heads in groups of 2
185185
// Reduce KV head indexing overhead
186186
```
187187
@@ -226,6 +226,8 @@ database:
226226
evaluator:
227227
timeout: 900 # 15 minutes for Metal kernel compilation and testing
228228
parallel_evaluations: 1
229+
# This example's evaluator does not implement evaluate_stage1.
230+
cascade_evaluation: false
229231

230232
# Evolution settings
231233
diff_based_evolution: true

examples/mlx_metal_kernel_opt/run_evolve_experiment.sh

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ USAGE
5050
# Force unbuffered Python output for reliable logging
5151
export PYTHONUNBUFFERED=1
5252

53-
export OPENAI_API_KEY=$GEMINI_API_KEY
54-
5553
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5654

5755
RUN_NAME=""
@@ -209,20 +207,20 @@ LOG_FILE="$RUN_DIR/run.log"
209207
# Truncate log file to ensure clean start (especially important for --resume)
210208
: > "$LOG_FILE"
211209

212-
# Check if stdbuf is available for line-buffered output
213-
if command -v stdbuf &>/dev/null; then
214-
# Use stdbuf to force line buffering on both stdout and stderr
215-
STDBUF_PREFIX=(stdbuf -oL -eL)
216-
else
217-
STDBUF_PREFIX=()
218-
fi
219-
220210
if [[ "$FOREGROUND" -eq 1 ]]; then
221211
# Stream to console and persist logs with line buffering.
222-
"${STDBUF_PREFIX[@]}" "${CMD[@]}" 2>&1 | tee "$LOG_FILE"
212+
if command -v stdbuf &>/dev/null; then
213+
stdbuf -oL -eL "${CMD[@]}" 2>&1 | tee "$LOG_FILE"
214+
else
215+
"${CMD[@]}" 2>&1 | tee "$LOG_FILE"
216+
fi
223217
else
224218
# Run in background with line-buffered output for reliable log ordering.
225-
nohup "${STDBUF_PREFIX[@]}" "${CMD[@]}" > "$LOG_FILE" 2>&1 &
219+
if command -v stdbuf &>/dev/null; then
220+
nohup stdbuf -oL -eL "${CMD[@]}" > "$LOG_FILE" 2>&1 &
221+
else
222+
nohup "${CMD[@]}" > "$LOG_FILE" 2>&1 &
223+
fi
226224
echo "[run_evolve_experiment] Started PID: $!"
227225
echo "[run_evolve_experiment] Log: $LOG_FILE"
228226
echo "[run_evolve_experiment] Tail: tail -f \"$LOG_FILE\""

0 commit comments

Comments
 (0)