Skip to content

Commit e648c11

Browse files
feat: add a README file for the auto search
1 parent 3b65db8 commit e648c11

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

MaxKernel/auto_search/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# MaxKernel Auto-Search
2+
3+
This directory contains the automated search orchestration framework for `MaxKernel`. It leverages autonomous LLM-based worker agents to systematically search for optimized kernel implementations (like Pallas or Triton) for reference JAX benchmark problems.
4+
5+
## Search Algorithms
6+
The framework currently supports two primary search topologies:
7+
1. **Parallel Search (`--algorithm parallel`)**: Dispatches multiple independent worker agents in parallel to optimize the reference kernel. The best performing candidate across all parallel runs is returned.
8+
2. **Beam Search (`--algorithm beam`)**: A more structured tree-search approach that explores multiple optimization strategies (branches) concurrently, evaluates their latency, and keeps only the top `beam_size` candidates at each depth before expanding further.
9+
10+
---
11+
12+
## Usage
13+
14+
### 1. Run Search on a Single Problem
15+
Use `run_search.py` to optimize a single benchmark directory. The directory must contain a valid `reference.py` file.
16+
17+
**Example (Beam Search):**
18+
```bash
19+
python -m auto_search.run_search \
20+
--problem_dir /path/to/problem_dir \
21+
--algorithm beam \
22+
--beam_size 2 \
23+
--branches_per_node 2 \
24+
--max_depth 3 \
25+
--max_concurrency 4
26+
```
27+
28+
### 2. Run Batch Search on a Dataset
29+
Use `run_batch_search.py` to optimize an entire dataset containing multiple problem directories concurrently.
30+
31+
**Example (Parallel Search):**
32+
```bash
33+
python -m auto_search.run_batch_search \
34+
--data_dir /path/to/dataset_dir \
35+
--algorithm parallel \
36+
--num_parallel_runs 4 \
37+
--num_problem_concurrency 2 \
38+
--max_concurrency 8
39+
```
40+
41+
---
42+
43+
## Key Arguments
44+
45+
### General Orchestration Arguments
46+
* `--algorithm` : The algorithm to use (`parallel`, `beam`). Default is `parallel`.
47+
* `--max_concurrency`: The maximum number of concurrent LLM agent workers to spawn at any given time.
48+
* `--max_worker_retries`: Maximum times a worker is allowed to retry if the generated kernel crashes or fails syntax checks.
49+
* `--strategies`: (Optional) Space-separated list of explicit strategies to explore (e.g., `--strategies "Fuse operations" "Vectorize loops"`).
50+
* `--agent_config`: (Optional) JSON string of internal agent parameters. Available parameters:
51+
* `"max_iterations"` (int): Maximum number of improvement loop iterations (default: 2).
52+
* `"end_agent"` (string): The sub-agent pipeline stage at which to terminate early (e.g., `"validate_agent"`, `"test_run_agent"`).
53+
* `"session_dir"` (string): Explicit path for session artifacts (usually auto-generated by the worker).
54+
* Example: `'{"max_iterations": 5, "end_agent": "validate_agent"}'`.
55+
* `--log_file`: File path to save the orchestration logs (creates separate `agent.log` and main logs).
56+
* `--graph_db_path`: *(Single-problem only)* Explicit path to a `search_graph.json` file to resume a previously interrupted search.
57+
58+
### Parallel Search Specific Arguments
59+
* `--num_parallel_runs`: Number of independent agents to spawn to tackle the problem simultaneously.
60+
61+
### Beam Search Specific Arguments
62+
* `--beam_size`: Number of top-performing candidates to retain at each depth of the search tree.
63+
* `--branches_per_node`: Number of new optimization strategies to explore from each retained node.
64+
* `--max_depth`: Maximum depth of the beam search tree before terminating.
65+
* `--keep_factor`: Factor of parent latency required to keep a candidate. For example, `1.0` means the child must be strictly faster (lower latency) than its parent to survive pruning.
66+
67+
### Batch Search Specific Arguments
68+
* `--num_problem_concurrency`: Number of distinct dataset problems to optimize concurrently.

0 commit comments

Comments
 (0)