FE-1341: Give experiment compute backends one interface - #9178
Draft
kube wants to merge 3 commits into
Draft
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
4 tasks
kube
force-pushed
the
cf/fe-1341-swappable-experiment-backends
branch
from
August 13, 2026 08:20
976a2dd to
afff6ce
Compare
kube
force-pushed
the
cf/fe-1341-swappable-experiment-backends
branch
from
August 14, 2026 23:53
afff6ce to
8ad93e6
Compare
Choosing a backend was hardcoded in ExperimentsProvider. The runtime half of swappability already worked — a backend produces a MonteCarloExperiment and consumers drive one with no branching — so this adds only the missing part: asking a backend whether it can run a net, and choosing between backends when one declines. A request is plain serializable data; anything describing how to compute belongs to the backend's construction or to per-call options. Refusal is a value carrying structured blockers with a code, an item id and an origin, so a UI can attribute a problem to the item that caused it. Assessment settles the net without acquiring a device or worker pool and hands back an instantiate() closure. Pure refactor: no user-visible behaviour changes. Registrations carry a deferred load so a heavy backend need not enter the bundle.
Replaces em dashes and drops 'deliberately' in backend-selection.mdx. No content change.
kube
force-pushed
the
cf/fe-1341-swappable-experiment-backends
branch
from
August 15, 2026 00:51
8ad93e6 to
1456a69
Compare
3 tasks
Rewrites the module docstrings in src/experiments to state what each file is before why it is that way, and replaces em dashes. No code change.
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.
🌟 What is the purpose of this PR?
Adds
@hashintel/petrinaut-core/experiments: one interface both compute backends satisfy, and a registry that picks between them.ExperimentsProvidercurrently hardcodes the choice. #9179 registers a backend against this interface instead of rewiring the provider.Refactor only. No behaviour change, no changeset.
🔗 Related links
🚫 Blocked by
🔍 What does this change?
Both paths already produce a
MonteCarloExperiment, and consumers drive one with no branching. That half is untouched. This adds four types:ExperimentRequestExperimentAssessmentcode, optionalitemId, and anoriginExperimentBackendassesssettles the net without acquiring a device or worker pool, then returns aninstantiate()closure carrying that work forwardselectExperimentBackendBlocker origins drive what a UI does:
modelconfigurationenvironmentcapacityflowchart TD R[registrations] --> L[load] --> A{assess} A -->|blockers| N[record refusal] --> R A -->|eligible| I{instantiate} I -->|environment / capacity| N I -->|handle| D[run]loadis deferred, so a heavy backend stays out of a bundle that never uses it.Adds
content/experiments/backend-selection.mdxand thecore.experimentslayer.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
One backend is registered here, so
assessnever refuses and the blocker types are unexercised until #9179.Worker pools and
GPUDeviceare still per experiment. Reuse depends on the worker resetting frame and metric state; if it does not, results stay plausible rather than visibly wrong.🐾 Next steps
Supply backends through a React context, so an embedder can register its own.
🛡 What tests cover this?
select-experiment-backend.test.ts: 9 cases covering preference order, deferred loading, refusal recording, instantiation failure, blocker ordering, unavailable backends, module load failure, and per-requirement request building.❓ How to test this?
Run an experiment. Behaviour is unchanged.