Skip to content

feat: allow BaseSamplingStrategy to specify a concurrency budget - #240

Closed
jakelorocco wants to merge 1 commit into
mainfrom
jal/rejection-with-concurrency
Closed

jakelorocco wants to merge 1 commit into
mainfrom
jal/rejection-with-concurrency

Conversation

@jakelorocco

@jakelorocco jakelorocco commented Nov 24, 2025 •

Copy link
Copy Markdown
Contributor

Investigated adding a concurrency budget to base sampling strategy (and its subclasses). By increasing concurrency, you increase the number of sampling iterations that happen concurrently (ie generate/validate pairs).

I looked into some other solutions of how to add this concurrency parameter (like creating a total_budget, etc...), but none of them kept the meaning of loop_budget as what it is now while being intelligible. I think specifying a separate concurrency budget makes the most sense since it keeps existing sampling strategies the same while allowing for an easy way to improve the rate of sampling.

For example:

  • loop_budget = 2, concurrency_budget = 2 -> can generate at most 4 samples; at any point in time, only two samples can be in progress

Changes:

  • had to modify the output slightly. Example output of several sampling strategies being run:
output looks something like:
RejectionSamplingStrategy: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 3/3 [00:04<00:00,  1.63s/it]
=== 13:15:53-INFO ======
Invoking select_from_failure after 3 failed attempts.
MultiTurnStrategy: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3/3 [00:02<00:00,  1.20it/s]
=== 13:15:56-INFO ======
Invoking select_from_failure after 3 failed attempts.
RejectionSamplingStrategy:  67%|██████████████████████████████████████████████████████████████████▋                                 | 6/9 [00:02<00:01,  2.99it/s]
=== 13:15:58-INFO ======
Sampling was successful.
RepairTemplateStrategy: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 25/25 [00:05<00:00,  4.98it/s]
=== 13:16:04-INFO ======
Invoking select_from_failure after 25 failed attempts.
MultiTurnStrategy: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████| 6/6 [00:02<00:00,  2.99it/s]
=== 13:16:06-INFO ======
Invoking select_from_failure after 6 failed attempts.
  • had to create a sub-function to hold a sampling iteration; this function yields slices of sampling results that can be combined into a single sampling result

Tests:

  • added a bunch of tests to make sure the new methods worked as expected
  • tests and examples pass

@mergify

mergify Bot commented Nov 24, 2025

Copy link
Copy Markdown

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|release)(?:\(.+\))?:

@jakelorocco
jakelorocco marked this pull request as ready for review November 24, 2025 19:18

@nrfulton nrfulton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable.

@nrfulton
nrfulton self-requested a review January 16, 2026 00:19
@jakelorocco jakelorocco closed this May 7, 2026
@jakelorocco
jakelorocco deleted the jal/rejection-with-concurrency branch May 7, 2026 19:17
@github-actions github-actions Bot added the enhancement New feature or request label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants