feat(prefill-probe): add learned prefill complexity router#97
Open
mich-xu wants to merge 9 commits into
Open
Conversation
Signed-off-by: michxu <michxu@nvidia.com>
Signed-off-by: michxu <michxu@nvidia.com>
Signed-off-by: michxu <michxu@nvidia.com>
Signed-off-by: michxu <michxu@nvidia.com>
Signed-off-by: michxu <michxu@nvidia.com>
Signed-off-by: michxu <michxu@nvidia.com>
Signed-off-by: michxu <michxu@nvidia.com>
Signed-off-by: michxu <michxu@nvidia.com>
Signed-off-by: michxu <michxu@nvidia.com>
sabhatinas
reviewed
Jul 20, 2026
| routing_policy: | ||
| type: cost-aware | ||
| lambda: 0.5 | ||
| weak_cost: 0 |
Contributor
There was a problem hiding this comment.
Curious what this field translates to in the algorithm.
sabhatinas
reviewed
Jul 20, 2026
| weak: weak | ||
| weak_checkpoint_head: nemotron-3-super | ||
| hidden_states_dir: /tmp/switchyard-hidden-states | ||
| inference_artifact_dir: ${PREFILL_ROUTER_ARTIFACT_DIR} |
Contributor
There was a problem hiding this comment.
are hidden_states_dir and inference_artifact_dir the same thing?
sabhatinas
reviewed
Jul 20, 2026
| Run Harbor from the repository root and select the adapter by import path: | ||
|
|
||
| ```bash | ||
| uv run --no-sync harbor run \ |
Contributor
There was a problem hiding this comment.
we have baseline benchmarking scripts in the repo to run closed book setup. can you update docs to use that instead ?
sabhatinas
requested changes
Jul 20, 2026
sabhatinas
left a comment
Contributor
There was a problem hiding this comment.
LGTM overall, we just need e2e testing done using the benchmarks.
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
Adds a learned
prefill-probeprofile that routes requests between configured weak and strong completion targets using prompt hidden states from a separate vLLM probe model.The profile:
lambda.This also adds a Terminal-Bench Terminus 2 adapter that supplies the exact raw task instruction through the private
_switchyard_prefill_probe_inputfield. The profile uses that value for scoring and caching, then removes it before calling the selected completion backend.A sample local profile and vLLM deployment documentation are included.
Why
The trained complexity router expects prompt-only hidden-state features, while Terminal-Bench's standard Terminus 2 agent wraps the raw task instruction with its command protocol and terminal state.
Passing the raw task instruction explicitly reproduces the checkpoint's expected representation without changing the conversation received by the selected completion model.
The probe model is intentionally independent of the completion targets. It only needs to match the encoder metadata stored in the inference artifact.
Closes #
How tested
uv run ruff check .cleanuv run mypy switchyardclean: 162 source files checkeduv run pytest tests/ -v -m "not integration"green: 1,978 passed, 12 skipped, 43 deselectedcargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspacemkdocs build --strictlambda = 0.7: 46 weak, 43 strong, 0 probe failureslambda = 0.8: 6 weak, 83 strong, 0 probe failuresThe full live runs encountered upstream provider rate limits, but all 89 routing decisions completed in each run and no probe failures were observed.
Checklist
snake_caseof the primary class.switchyard/__init__.py.__all__if intended for downstream use.--helpupdated if customer-facing surface changed.Signed-off-by: Your Name <email>) per the DCO.Notes for reviewers
This is a stacked PR based on and targeting #13. It can be retargeted to
mainafter #13 merges.The router artifact is deployment data and is not packaged or downloaded by Switchyard. At startup, the profile validates the artifact metadata and tensor shapes, including encoder identity, layer count, hidden width, PCA dimension, output heads, and ensemble architecture.
The learned profile uses a fixed public threshold of
0.5: score1.0selects weak and score0.0selects strong. Routing should be tuned throughlambda, not through an additional confidence threshold.The private Terminal-Bench probe-input field is rejected when malformed and is always removed before target execution.