Skip to content

[Rust TreeCore] Harden runtime and CI parity - #37303

Merged
hzh0425 merged 6 commits into
sgl-project:mainfrom
Jialin:codex/rust-tree-core-p0
Sep 9, 2026
Merged

hzh0425 merged 6 commits into
sgl-project:mainfrom
Jialin:codex/rust-tree-core-p0

Conversation

@Jialin

@Jialin Jialin commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Motivation

The Rust TreeCore still has a few correctness and build-integration gaps after its initial merge:

  • stale node handles can panic while the core mutex is held, poisoning the backend for all subsequent requests;
  • Rust accepts shortened SWA prefetch windows below non-root anchors, while the Python TreeCore rejects and releases them;
  • Rust extension caches can reuse artifacts built against a different PyTorch installation or stale protobuf sources;
  • the Rust TreeCore E2E is registered on AMD even though that platform does not package this extension.

This PR is rebased onto the merged #37290 crate rename and current main.

Modifications

Rust TreeCore boundary handling

  • Make NodeArena::resolve the single node-handle lookup API and return a dedicated NodeAccessError for stale handles.
  • Remove the parallel optional resolver, TreeCore-specific resolver wrapper, binding-side prevalidation wrappers, and panicking host-insert wrapper.
  • Make production and inspection operations propagate node-access failures from the core; PyO3 maps them to KeyError without poisoning the mutex.
  • Validate all handles for multi-node mutations before changing tree state, including handles nested in transfer and insert results.
  • Preserve explicit absence semantics only where stale work is intentionally dropped (buffer_only snapshots and the three inspector membership predicates).
  • Pass already-resolved internal node indices through match finalization instead of resolving public handles again.

Rust SWA parity

  • Reject and release shortened SWA prefetch windows below non-root anchors.
  • Keep the existing root-anchor behavior unchanged.
  • Add the same backend-routed regression for the Python and Rust TreeCore implementations.

Rust extension build and CI

  • Include the resolved PyTorch installation in torch-sys rebuild inputs.
  • Include proto/** in Rust extension cache keys, sparse checkout inputs, and cache seeding triggers.
  • Add metadata-declared external source inputs to the local Rust extension fingerprint.
  • Keep the Python and Rust Full E2E subclasses together; the shared file remains registered on CUDA and AMD, while the Rust subclass is skipped only in AMD CI because that platform does not package the extension.

Accuracy Tests

No model kernels or numerical computation are changed.

Validation performed on the consolidated branch:

  • Rust native suite: 831 passed, 1 ignored.
  • Rust TreeCore adapter/inspection integration: 104 passed.
  • Shared shortened-SWA-prefetch regression:
    • Python TreeCore: 1 passed.
    • Rust TreeCore: 1 passed.
  • Rust extension discovery and cache tests: 15 passed.
  • Clippy with Python and inspection features passed with warnings denied.
  • Changed-file formatting, lint, syntax, CI-registration, and cache-key checks passed.

Speed Tests and Profiling

Not applicable. These changes affect error handling, SWA transfer validation, extension cache invalidation, and CI registration; they do not modify model execution or kernel hot paths.

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci.
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #34097120801
Latest PR Test (Extra): ✅ Run #34097120429
Latest PR Test (AMD ROCm 7.2): ❌ Run #34097120691

@github-actions github-actions Bot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file labels Aug 31, 2026
@Jialin
Jialin force-pushed the codex/rust-tree-core-p0 branch 4 times, most recently from e394052 to 019f203 Compare September 1, 2026 20:00
@Jialin

Jialin commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

09/01 2:51PM PT: rerun due to tests got cancelled
09/01 4:15PM PT: rerun due to tests got cancelled
09/01 9:47PM PT: rerun due to tests got cancelled
09/02 9:59AM PT: rerun due to tests got cancelled

@bingxche

bingxche commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix for AMD CI. May I know the plan of supporting Rust TreeCore on AMD? This PR has conflicts now, can I cherry pick first to skip the failed test TestRustUnifiedFullRadixCache?

@bingxche

bingxche commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Extracted the AMD-only CI skip from commit 5c9bf17 into focused draft #38287 on current main, since this branch is currently conflicting. If that split is preferred, this commit can be dropped here during rebase; otherwise I can close the draft.

@Jialin

Jialin commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the fix for AMD CI. May I know the plan of supporting Rust TreeCore on AMD? This PR has conflicts now, can I cherry pick first to skip the failed test TestRustUnifiedFullRadixCache?

Let me do a quick rebase now. And I could followup to do the supporting in AMD, ideally, it should be pretty lightweight.

@Jialin
Jialin force-pushed the codex/rust-tree-core-p0 branch from 019f203 to f058a65 Compare September 7, 2026 06:35
@Jialin

Jialin commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Extracted the AMD-only CI skip from commit 5c9bf17 into focused draft #38287 on current main, since this branch is currently conflicting. If that split is preferred, this commit can be dropped here during rebase; otherwise I can close the draft.

Please feel free to go ahead landing #38287 for unblocking AMD first. I could do the rebase correspondingly later on.

@Jialin

Jialin commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

  • 09/08 10:10AM: Retry base-c tests which seems stuck in the queue

@hzh0425 hzh0425 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, sry for the late

@Jialin

Jialin commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

LGTM, sry for the late

Thanks! No worry :)

@hzh0425
hzh0425 merged commit 7a464a7 into sgl-project:main Sep 9, 2026
363 of 403 checks passed
ishandhanani added a commit that referenced this pull request Sep 9, 2026
Resolves the overlap between the RadixValue generics on this branch and the
NodeAccessError Result returns plus the two new finalize_match_result_in_tree_core
parameters from #37303: every conflicting signature keeps main's shape with V in
place of Tensor, try_resolve_node_handle_ callers use arena.resolve, and the
torch-free integration tests unwrap the now fallible APIs.
@Jialin
Jialin deleted the codex/rust-tree-core-p0 branch September 9, 2026 06:54
mqhc2020 pushed a commit to mqhc2020/sglang that referenced this pull request Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation run-ci run-ci-extra unified-radix-cache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants