Skip to content

feat(speculation): generator contract and bestfirst impl - #446

Open
behinddwalls wants to merge 1 commit into
preetam/speculation-generator-rfcfrom
preetam/speculation-generator
Open

feat(speculation): generator contract and bestfirst impl#446
behinddwalls wants to merge 1 commit into
preetam/speculation-generator-rfcfrom
preetam/speculation-generator

Conversation

@behinddwalls

@behinddwallsbehinddwalls commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Why?

The standard Speculator needs a ranked stream of candidate speculation paths to fund. Nothing enumerates or ranks the path space today.

What?

Adds submitqueue/extension/speculation/generator — the Generator/PathIterator contract — plus the bestfirst implementation and mocks.

The generator is a pure enumerator: Open takes only the queue’s batches and offers every coherent path, including ones whose builds already ran. Suppressing those belongs to the Allocator, which reconciles candidates against stored path sets by ID.

bestfirst ranks each path by how likely all its assumptions are to hold and generates lazily: one heap holds the frontier of every head’s path tree, so pulling k paths does O(k) work however large the space behind them. Scores are summed log probabilities so wide heads cannot underflow into ties, and canonical subset expansion emits each path exactly once in non-increasing score order. The full algorithm, tie-breaks, derivation, and floating-point constraints live in doc/rfc/submitqueue/speculation-generator-best-first.md; the package README now records only operational behavior.

Also sharpens scorer.Scorer’s contract: it returns the probability that a batch’s build succeeds — the quantity bestfirst consumes — rather than “the likelihood of a successful land.”

Test Plan

./tool/bazel test //submitqueue/extension/speculation/generator/...

make fmt

make lint

make check-tidy

make check-gazelle

Stack

  1. docs(rfc): explain best-first speculation generation #513
  2. @ feat(speculation): generator contract and bestfirst impl #446
  3. feat(speculation): allocator contract and sticky impl #450
  4. feat(speculation): standard composed speculator #451
  5. feat(storage): speculation path set store #501
  6. feat(storage): path-build link store for per-path builds #502
  7. feat(orchestrator): dispatch builds per speculation path #503
  8. feat(orchestrator): poll builds and stop the ones nothing wants #504
  9. fix(orchestrator): mint distinct message IDs for cancel re-publishes #505
  10. feat(orchestrator): re-plan the queue from the Speculator each run #506
  11. feat(orchestrator)!: finalize batches from their speculation paths #507
  12. feat(orchestrator): compose per-queue speculators and turn speculation on #508

@behinddwalls
behinddwallsforce-pushed the preetam/speculation-generator branch 3 times, most recently from c8ec6b1 to 3fb7e2bCompareJuly 27, 2026 23:14
@behinddwalls
behinddwalls marked this pull request as ready for review July 27, 2026 23:17
@behinddwalls
behinddwalls requested review from a team and sbalabanov as code ownersJuly 27, 2026 23:17
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-generator branch 2 times, most recently from 5e0bdbd to 3fb7e2bCompareJuly 28, 2026 19:13
Comment threadsubmitqueue/extension/speculation/generator/README.md Outdated
Comment threadsubmitqueue/extension/speculation/generator/generator.go Outdated
Comment threadsubmitqueue/extension/speculation/generator/generator.go Outdated
Comment threadsubmitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment threadsubmitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment threadsubmitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment threadsubmitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment threadsubmitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment threadsubmitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment threadsubmitqueue/extension/speculation/generator/bestfirst/bestfirst_test.go Outdated
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-generator branch from 3fb7e2b to 5e2ad89CompareJuly 29, 2026 18:12
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-generator branch from 5e2ad89 to 4c727b2CompareJuly 29, 2026 18:24
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-generator branch from 4c727b2 to ccb1aa4CompareJuly 29, 2026 22:31
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-generator branch 3 times, most recently from e9e54ca to ee4ab40CompareJuly 29, 2026 23:18
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-generator branch from ee4ab40 to d5dd68bCompareJuly 29, 2026 23:18
Base automatically changed from preetam/speculation-speculator to mainJuly 30, 2026 01:19
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-generator branch from d5dd68b to e3d56b0CompareJuly 30, 2026 01:19
## Summary
### Why?
The standard Speculator needs a ranked stream of candidate speculation paths to fund. Nothing enumerates or ranks the path space today.
### What?
Adds `submitqueue/extension/speculation/generator` — the Generator/PathIterator contract — plus the `bestfirst` implementation and mocks.
The generator is a pure enumerator: `Open` takes only the queue’s batches and offers every coherent path, including ones whose builds already ran. Suppressing those belongs to the Allocator, which reconciles candidates against stored path sets by ID.
`bestfirst` ranks each path by how likely all its assumptions are to hold and generates lazily: one heap holds the frontier of every head’s path tree, so pulling k paths does O(k) work however large the space behind them. Scores are summed log probabilities so wide heads cannot underflow into ties, and canonical subset expansion emits each path exactly once in non-increasing score order. The full algorithm, tie-breaks, derivation, and floating-point constraints live in `doc/rfc/submitqueue/speculation-generator-best-first.md`; the package README now records only operational behavior.
Also sharpens `scorer.Scorer`’s contract: it returns the probability that a batch’s build succeeds — the quantity bestfirst consumes — rather than “the likelihood of a successful land.”
## Test Plan
✅ `./tool/bazel test //submitqueue/extension/speculation/generator/...`
✅ `make fmt`
✅ `make lint`
✅ `make check-tidy`
✅ `make check-gazelle`
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-generator branch from 727009d to 110a679CompareAugust 5, 2026 04:57
@behinddwalls
behinddwalls changed the base branch from main to preetam/speculation-generator-rfcAugust 5, 2026 05:05
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@behinddwalls@sbalabanov