ComBEE parallel scan aggregation for scalable prompt learning#307
ComBEE parallel scan aggregation for scalable prompt learning#307nuglifeleoji wants to merge 17 commits into
Conversation
Changed Files
|
Made-with: Cursor
|
Are there any other problems, I will be happy to fix that! @LakshyAAAgrawal Thanks for your response! |
Shangyint
left a comment
There was a problem hiding this comment.
This is a nice addition, with the following caveats:
- Can you add docs too, so this feature is not buried in the code?
- In the feature flag comment (i'd suggest change
aggregation_methodtouse_combee, can you also either points to the docs or the paper? Naively, gepa's minibatch size is 3, sok=sqrt(3)does not make too much sense here. Ideally, people who want to use combee should know this and set minibatch to something larger.
- rename aggregation_method -> use_combee: bool (clearer than string enum) - add minibatch size guidance in comments and docs - rename prompts local var to lm_prompts in _propose_new_texts_combee - add docs/docs/guides/combee.md with usage and background - add ComBEE guide to mkdocs.yml nav Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
|
Can you resolve the conflicts? |
…terion and callbacks Keep both upstream changes (acceptance_criterion in api.py, callbacks in optimize_anything.py) alongside our ComBEE additions (use_combee, rng). Made-with: Cursor
|
I think all conflicts are resolved now! @LakshyAAAgrawal |
| # Requires reflection_minibatch_size to be set significantly larger than the | ||
| # default of 3; k = floor(sqrt(n)) groups are formed, so n >= 4 is needed | ||
| # for ComBEE to activate (n=3 gives k=1 and falls back to naive). | ||
| use_combee: bool = False, |
There was a problem hiding this comment.
I think all of these should go into both api.py and optimize_anything. You can add another level of config in GEPAConfig in optimize_anything called ComBEEConfig inside reflective mutation config?
Add nested ComBEEConfig to optimize_anything, expose the remaining ComBEE knobs in gepa.optimize, and clarify paper references in the reflection proposer/docs. Made-with: Cursor
Bring in the latest upstream changes, keep the new parallel proposal flow, and preserve the ComBEE reflective mutation path on top of it. Made-with: Cursor
|
Just fixed all the conflicts! @LakshyAAAgrawal |
|
Thanks for this design @LakshyAAAgrawal, do I wait until Phase 1 and Phase 2 are completed? |
…307) ComBEE (arXiv:2604.04247) re-expressed as a ReflectionLM on top of the vectorized pipeline, replacing #307's `use_combee` branch + bespoke `_propose_new_texts_combee` method. - ComBEEReflectionLM(StatelessReflectionLM): per (job, component) with n records, augmented-shuffle (duplicate p times) + split into k=floor(sqrt(n)) groups, reflect per group (Level-1/Map), aggregate the k intermediates into one (Level-2/Reduce). k<=1 degrades to a single stateless reflection — i.e. it IS StatelessReflectionLM at small n. - Both rounds are vectorized across the whole proposal batch via the shared _batch_complete primitive: all ~N*k Map calls go out as one litellm.batch_completion, all ~N Reduce calls as a second. So a batched ComBEE iteration is two batch_completion round-trips regardless of N — vs #307's N*k sequential calls. - Stateless in memory (next_lm = self); the aggregation axis is orthogonal to the session/memory axis. - Add InstructionProposalSignature.default_aggregation_prompt_template (the Level-2 reduce prompt, ported from #307). - Wire through: ReflectiveMutationProposer(use_combee=..., duplication_factor, aggregation_prompt) swaps the ReflectionLM impl in __init__; exposed on optimize_anything ReflectionConfig (use_combee / combee_duplication_factor / combee_aggregation_prompt). No new engine branch. Tests: two-round Map/Reduce batching, k<=1 naive fallback (== stateless), balanced split, determinism under seed, and an end-to-end optimize_anything run with use_combee=True. Full suite: 497 passed, 4 skipped. Refs #329, #307. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-Authored-By: nuglifeleoji <204564520+nuglifeleoji@users.noreply.github.com>
|
Hello! Our team at JetBrains Research is currently running experiments with GEPA, and ComBEE-style parallelization would significantly speed them up. Could you please share when the relevant PRs are expected to be merged and ready for use? Thanks in advance! |
Hi, this is a pr that implements this paper's algorithm on gepa, here are the overall summary and usage, feel free to ask questions and comment!
Summary
Adds
aggregation_methodparameter to support ComBEE (Combee: Scaling Prompt Learning for Self-Improving Language Model Agents), a Map-Shuffle-Reduce framework that prevents context overload when using large reflection batch sizes.When
aggregation_method="naive"(default), the existing code path is completely unchanged. When set to"combee", the reflection step applies:p=2times and the full set is shuffled, ensuring every reflection has multiple chances to be incorporatedk = ⌊√n⌋groups; Level-1 calls one reflection LM per group to producekintermediate instructions; Level-2 aggregates thosekinstructions into a single final context updateThis resolves the context overload problem where naive large-batch reflection degrades quality because the aggregator LLM defaults to retaining only generic patterns while discarding specific, high-value insights.
Usage
aggregation_method="naive"is the default — no behaviour change for existing users.Implementation
src/gepa/strategies/instruction_proposal.py— addeddefault_aggregation_prompt_templatetoInstructionProposalSignature, the Level-2 reduce prompt that synthesizeskintermediate instructions into onesrc/gepa/proposer/reflective_mutation/reflective_mutation.py— added_propose_new_texts_combee()implementing the full Map-Shuffle-Reduce logic;propose()routes to it whenaggregation_method="combee"andreflection_lmis set (falls back to naive otherwise)src/gepa/api.py—aggregation_methodexposed ongepa.optimize()src/gepa/optimize_anything.py—aggregation_methodadded toReflectionConfigwith docstringComBEE is only active when
reflection_lmis provided and no custom adapter proposer overrides the default LM-based reflection.