-
Notifications
You must be signed in to change notification settings - Fork 78
docs(glm52): pegaflow offload → P/D design record; refresh serving-status #597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # GLM5.2 × pegaflow: host-tier KV offload → P/D disaggregation | ||
|
|
||
| > **TL;DR:** Design record (no code yet). The pegaflow in-process bridge already exists and serves qwen3 (`openinfer-kv-offload` embeds `PegaEngine` directly); GLM5.2 integration is an extension, not greenfield. M1 = single-engine host-tier offload wired into the admission prefix-match; M2 = cross-engine P/D (vLLM prefill → openinfer decode) via the #540 hash-compat pattern. Design pins to pegaflow-core **v0.23.2 rev d46fd16** (the vendored dep), not the local v0.22.6 checkout. | ||
| > | ||
| > **Last touched:** 2026-07 | ||
|
|
||
| ## Why pegaflow first | ||
|
|
||
| The standing decision is prefill-by-vLLM (no dedicated GLM5.2 prefill path). P/D disaggregation means the decode engine ingests KV that someone else produced — and the ingestion mechanism (query a shared tier by block hash, lease, load into pool pages, commit as matched prefix) is byte-for-byte the same mechanism as host-tier offload restore. M1 builds and gates that mechanism against ourselves; M2 only changes who wrote the blocks. | ||
|
|
||
| ## What already exists (seam map, 2026-07-06) | ||
|
|
||
| - `openinfer-kv-offload` is an **in-process** bridge: `OffloadEngine::new(config, &KvBuffer, stream)` builds a `PegaEngine` in the same process (`engine.rs:299`); no server, no metaserver unless `P2pConfig` (RDMA) is set. Minimal deployment = host pinned-memory tier only. | ||
| - qwen3 drives the full loop today: save sealed blocks (`executor.rs:1504`), CPU-tier query (`:1665`), lease + load + `commit_loaded_blocks` (`:1724`). GLM5.2 stops at the GPU-only `match_and_add_prefix` (`scheduler/mod.rs` admission); the CPU-tier leg is the missing wiring, and `BlockPool` already exposes the split point (`probe_prefix` → `cpu_query_hashes` → `commit_loaded_blocks`, `openinfer-kv-cache/src/pool.rs:169-253`). | ||
| - Keying: openinfer serializes its xxh3 `PositionalLineageHash` u128 as 16 big-endian bytes (`pool.rs:602`); pegaflow treats `BlockKey { namespace, hash }` as opaque bytes and never re-hashes. | ||
|
|
||
| ## M1 — single-engine host-tier offload (GLM5.2 ↔ GLM5.2) | ||
|
|
||
| 1. **Registration geometry**: GLM5.2 has *two* per-layer arenas sharing pool block ids — MLA fp8_ds_mla (64-token page × 656 B/token) and index-K (64 × (128+4) B, full-indexer layers only). pegaflow's `KVCacheRegistration` models one arena per "layer", so register **two pegaflow layers per model layer** (`glm52.L{n}.mla`, `glm52.L{n}.idxk`), both blocks-first single-segment with their own `block_stride_bytes` via `register_context_layer_batch_strided` (v0.23.2, `lib.rs:301`). Save/load must move both or neither — a page whose MLA restored but whose index-K didn't is silent corruption; make the save entry per (block, both-arenas) atomic at our bridge layer. | ||
| 2. **Per-rank engines**: DP8 = 8 independent pools; `OffloadEngine` is single-rank by construction, so one engine per rank with the pinned pool budget split /8. Non-expert KV is rank-local — no cross-rank coordination needed. | ||
| 3. **Hook**: admission's `match_and_add_prefix` grows the CPU leg exactly like qwen3's executor — GPU match first, then `cpu_query_hashes` against pegaflow, lease + async load into freshly-reserved pool pages, `commit_loaded_blocks`, and only then report `cached_tokens`. Loads must complete before the request's first step (admission is a step boundary; block on the `LoadHandle` like qwen3 does). | ||
| 4. **Save policy**: sealed (content-addressed) blocks flow to the host tier on release, same as qwen3's `save_sealed_blocks`. dspark × prefix-cache exclusivity carries over unchanged — drafter on ⇒ no prefix matching ⇒ offload restore off (#590 owns lifting that). | ||
| 5. **Gates** (jz-38): byte parity — evict-then-restore a 1200-token varied prompt and require the warm output byte-identical to the resident-prefix run; step-bench flat vs the D5/D10 anchors (save is off the step path, restore is admission-side); 17-way mixed load with restores zero-error; `--no-prefix-cache` disables the whole leg. | ||
|
|
||
| ## M2 — cross-engine P/D (vLLM prefill → openinfer decode) | ||
|
|
||
| Blocked on M1. Two hard problems, both with prior art: | ||
|
|
||
| - **Hash compat**: openinfer xxh3-lineage vs vLLM SHA-256 `block_hashes` never collide onto the same keys. PR #540 (qwen3) already built the pattern: compute vLLM-compatible hashes for the prompt at admission and query the vLLM-written namespace. Port that, plus the namespace derivation (vLLM side = SHA-256 over model/dtype/tp/heads/... — `connector/common.py:210`; ours must reproduce it byte-for-byte). | ||
| - **Layout parity**: vLLM's GLM5.2 runs the same FlashMLA-sparse fp8_ds_mla + DeepGEMM indexer contracts, but byte-level identity of both arenas (656 B token layout, index-K packing, scale placement) must be *proven*, not assumed — gate: dump one block from each engine for the same prefix and byte-compare before any e2e. Also reconcile page granularity (our fixed 64-token page vs vLLM scheduler-block × dcp/pcp virtual blocks). | ||
|
|
||
| ## Pitfalls pinned during the survey | ||
|
|
||
| - The local `/data/code/pegaworkspace/pegaflow` checkout is v0.22.6 and **lacks the `*_inproc` and `_strided` APIs** the integration uses; read the vendored `~/.cargo/git/checkouts/pegaflow-*/d46fd16/` instead. | ||
| - The PyO3 package is a gRPC client — reference contract only, not our path. | ||
| - vLLM connector requires `storage_offset()==0` and registers CUDA-IPC handles; our in-process path passes raw device pointers and skips IPC entirely. | ||
|
|
||
| ## Next action | ||
|
|
||
| M1 step 1: extend `openinfer-kv-offload`'s `Registration` to model the two-arena-per-layer geometry (today `Registration::from_buffer` assumes the qwen3 fused single-buffer layout), behind the same `OffloadEngine` API so qwen3 is untouched. | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When M1 is exposed through the existing server flags, this gate specifies the opposite of the documented behavior:
openinfer-server/src/config.rsandQwen3Executor::set_no_prefix_cachedefine--kv-offload --no-prefix-cacheas pure-L2 mode (disable HBM retention but still restore from the host tier via prefix matching), not as disabling the offload leg. If GLM5.2 follows this design, the test would skip the restore path instead of forcing it, leaving the host-tier integration unvalidated and diverging from user-visible CLI semantics.Useful? React with 👍 / 👎.