Skip to content

NPU private routes: optional routes decline to the fast lane - #88

Merged
bong-water-water-bong merged 3 commits into
mainfrom
npu/optional-private-route
Sep 25, 2026
Merged

bong-water-water-bong merged 3 commits into
mainfrom
npu/optional-private-route

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

A private route can be marked optional: an opt-in route for a model_type the fast lane also serves (for example qwen3). When its unavailable() declines a directory (say its --npu-opt was not given), the fast lane serves the directory exactly as it would without the add-on. Before this change, any registered route for a type took every directory of that type, and a decline was an error.

  • npu/private_route.h: PrivateRoute::optional (default false, so existing routes are unchanged) and route_for(dir, opts, &why), which returns the route that serves a directory. It returns nullptr when there is no route or an optional one declines, and nullptr plus a reason when a required one declines.
  • app/unified.cpp: npu_model_problem / npu_model_kind and the route lookup at load use route_for.
  • tests/npu_private_route_test.cpp: covers route_for (serves, declines with a reason, optional declines to the fast lane).
  • docs/npu.md, "Private routes": one bullet on optional routes.

No behaviour change for the 35B route, which is not optional, or for builds without an add-on.

🤖 Generated with Claude Code

A private route can now be optional: an opt-in route for a model_type the
fast lane also serves (qwen3). When its unavailable() declines a directory,
the fast lane serves it exactly as without the add-on, instead of failing.
The choice moves into the registry as route_for(dir, opts, &why), which
1bit unified uses and tests/npu_private_route_test.cpp now covers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@context7

context7 Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Docs7 for 1bit-monster/engine

Result Status Action
Deployment ➖ Not used —
Content review ➖ Did not run. This site has no agent runs available this month. Wait for the monthly reset or check your Docs7 plan. —

Commit da251a6

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit da251a6)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect error handling for optional routes

When an optional route declines a directory, the code attempts to throw an error with a message that says the private route no longer serves it. However, for optional routes, the decline should result in falling back to the fast lane, not throwing an error. The error message is misleading and could confuse users.

std::string why;
const npu::PrivateRoute* rp = npu::route_for(model_dir, opts, &why);
if (!rp) throw std::runtime_error(model_dir + ": the private route no longer serves it" + (why.empty() ? "" : ": " + why));
Potential null pointer dereference

In route_for, if find_private_route returns nullptr, the code attempts to access r->optional without checking if r is null. This could lead to a null pointer dereference, although the current logic prevents this by returning nullptr early.

const PrivateRoute* route_for(const std::string& dir, const PrivateOptions& opts, std::string* why) {
    why->clear();
    const PrivateRoute* r = find_private_route(model_type_of(dir));
    if (!r) return nullptr;
    const std::string no = r->unavailable ? r->unavailable(dir, opts) : "";
    if (no.empty()) return r;
    if (!r->optional) *why = no;
    return nullptr;
}

… after the kind check)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit a3c21fb

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit da251a6

@bong-water-water-bong
bong-water-water-bong enabled auto-merge (squash) September 25, 2026 17:07
@bong-water-water-bong
bong-water-water-bong merged commit 8c59b37 into main Sep 25, 2026
5 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the npu/optional-private-route branch September 25, 2026 17:08
bong-water-water-bong added a commit that referenced this pull request Oct 5, 2026
…-Next) (#311)

* Bump HRX: llama.cpp e57beb9721af (fork #81-#83, #86-#88)

Moves third_party/llama.cpp (1bit-MONSTER/llama.cpp 1bit/hrx-vulkan-patched)
2e5fcf56a24d -> e57beb9721af; hrx-system stays at 51b1739ae5fd.
Registry regenerated at the new pin: 290 -> 292 architectures (qwen4exp).

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* Bump HRX: registry at the committed pin; qwen4exp is mapped now

registry/architectures.json was generated against the previous gitlink
(registry_pins failed). tests/device_route.sh used qwen4exp as its
"not built" example; at this pin Flash-Next runs on HRX, so the test now
checks it takes the plain route and keeps zamba2 as the refused example.
Docs that listed qwen4exp as unbuilt say it is back.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

---------

Co-authored-by: bong-water-water-bong <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant