Scale beam search: multi-LLM, samples-per-prompt, multi-GPU, PTX dedup, NCU caching#139
Open
jiannanWang wants to merge 1 commit into
Open
Scale beam search: multi-LLM, samples-per-prompt, multi-GPU, PTX dedup, NCU caching#139jiannanWang wants to merge 1 commit into
jiannanWang wants to merge 1 commit into
Conversation
- BeamSearchStrategy: add models / samples_per_prompt / num_expanding_parents knobs; expansion now P × M × K × C with per-candidate openai_model and sample_idx threaded through the worker dispatch. - PTX fingerprint dedup: new ptx_fingerprint.py captures compiled PTX from a per-call TRITON_CACHE_DIR during benchmarking, normalizes (strip comments/debug/headers, canonicalize register/label names), SHA-256 hashes. update_with_results dedups the combined pool by hash before sort+truncate; ProgramEntry / json_db carry ptx_hash. - Multi-GPU: per-GPU mp.Lock pool (single lock covers both benchmark and NCU on a given GPU), round-robin worker -> GPU assignment, CUDA_VISIBLE_DEVICES=<gpu_id> set in the worker process before any torch import. Manager auto-detects via nvidia-smi (NOT torch.cuda) to avoid poisoning forked children with an inherited CUDA context. - Per-parent baseline NCU cache: manager profiles each unique parent once per round and attaches baseline_metrics to each candidate dict; workers skip their own NCU when the cache is populated. - Bottleneck plumbing fix: num_bottlenecks is now wired from strategy_config -> worker_kwargs[num_bottlenecks_to_request] -> BottleneckAnalyzer. Pre-fix the analyzer always asked for 1 ranked bottleneck so workers with bottleneck_id >= 2 silently fell back to rank 1. - mp.Queue feeder-thread deadlock fix: NvidiaWorkerRunner.run_workers now drains the queue interleaved with join(timeout=0.5) polling instead of joining all workers serially before draining. - best_runtime_ptx_hash propagation: orchestrator captures the hash after _update_kernels (was previously checked before, when the comparison was tautologically false), and parent-hash byte-identity fallback in update_with_results lets unchanged-parent results inherit the parent's hash so they collapse correctly in dedup. - ncu_profiler.py: NaN-safe units-row detection (str.lower() propagated pd.NA back to float NaN, breaking the substring check). - Configs: examples/configs/beam_search_diverse.yaml (spread, P=5/C=2), beam_search_diverse_concentrated.yaml (P=2/C=5), beam_search_diverse_smoke.yaml (smoke variant).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Beam search on
mainruns with a single LLM, a single GPU, and no candidate deduplication. That's enough for easy problems but plateaus quickly: a single model produces near-duplicate kernels each round, and on harder problems a single model often can't produce any working kernel at all (e.g.,claude-opus-4.5alone yields 0/32 successful kernels on the Gemma3 fused gate-up workload).This PR scales beam search to run multiple LLMs in parallel, expand multiple samples per
(parent, bottleneck, model)triple, distribute workers across multiple GPUs, and deduplicate beam entries by compiled-PTX fingerprint so the beam doesn't fill with byte-equivalent copies of the leader.All new features are opt-in via
strategy_config. Existing flows that don't setmodelsorsamples_per_promptare unchanged.Example commands
Three new presets ship with the PR:
Each preset configures models: [claude-opus-4.6, gpt-5-4, gemini-2-5-pro] out of the box, routed via the existing RelayProvider fallback.
Experiment results
Two problems, 8 rounds each:
The matvec improvement comes from richer fanout exposing more refinement directions per round. The gemma3_swiglu improvement comes from multi-LLM breaking through the single-model correctness floor — gpt-5-4 and gemini-2-5-pro find working kernels for this problem where claude-opus-4.5 does not.
What is changed
models: list[str]strategy knob — per-candidate LLM override; each worker round-robins through the configured list.samples_per_prompt: intstrategy knob — N independent LLM draws per (parent, bottleneck, model) triple. Default = 1.