Skip to content

refactor(server): share target layer-split runtime helpers#306

Open
weicj wants to merge 3 commits into
Luce-Org:mainfrom
weicj:refactor-server-layer-split-runtime
Open

refactor(server): share target layer-split runtime helpers#306
weicj wants to merge 3 commits into
Luce-Org:mainfrom
weicj:refactor-server-layer-split-runtime

Conversation

@weicj
Copy link
Copy Markdown
Collaborator

@weicj weicj commented May 29, 2026

Summary

This PR refactors the target layer-split server path so new model adapters do not need to keep copying the same runtime shell. The existing Qwen35, Gemma4, and Laguna adapters all repeat shard/range/snapshot-backend setup and the autoregressive decode/sampling loop; this moves those shared pieces into server/src/common/layer_split_runtime.* while keeping model-specific loading, graph execution, cache layout, snapshot payloads, and EOS rules inside each adapter.

Changes

  • Add server/src/common/layer_split_runtime.h/.cpp.
    • init_layer_split_runtime() centralizes target path validation, GGUF layer-count inspection, layer range calculation, shard metadata initialization, peer-access setup, and snapshot backend initialization.
    • run_layer_split_ar_decode() centralizes the AR decode loop, CPU sampling handoff, token emission, cancellation handling, and EOS termination.
  • Update the Qwen35, Gemma4, and Laguna layer-split adapters to call the shared runtime helpers.
    • Qwen35 still owns DFlash draft loading, feature-ring handling, DFlash speculative decode, and its Qwen-specific forward path.
    • Gemma4 and Laguna still own their partial loaders, per-layer graph builders, cache/snapshot formats, and model-specific decode-position offset.
  • Register the new runtime source in server/CMakeLists.txt.

Notes

@weicj weicj marked this pull request as ready for review May 29, 2026 10:40
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

Review completed

Re-trigger cubic

Sign up for free to 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.

1 participant