fix(sglang): port the DataFlow capture backend to sglang 0.5.14 (up-16)#652
Conversation
Ports the sglang 0.5.14 upgrade onto up-16's new-layout target-capture backend. On `main` the 0.5.14 bump landed via sgl-project#605 (eagle3 / custom backends) plus the follow-up `patch/fix_sgl0.5.14_dflash` (dflash), but both target the OLD `specforge/modeling/target/dflash_target_model.py` layout. up-16 consolidated eagle3 + dflash extend into a single `SGLangCaptureBackend` (`inference/target_engine/sglang_backend/capture.py`), so the same API adaptations are applied there once, covering both paths: - import `prepare_mlp_sync_batch_raw` from `managers.scheduler_components.dp_attn` (moved from `managers.scheduler_dp_attn_mixin` in 0.5.14). - `build()`: replicate the post-load setup 0.5.14 split out of `ModelRunner.initialize()` — `alloc_memory_pool()` / `init_attention_backends()` / `init_cuda_graphs()` — since we drive the ModelRunner directly; and set `chunked_prefill_size=-1` (we prefill the whole batch in one `_forward_extend`, no scheduler chunking). - `_forward_extend()`: drop the removed `get_model_worker_batch()` step — `ForwardBatch.init_new` now consumes the `ScheduleBatch` directly and reads `capture_hidden_mode` off it; and materialize `prefill_input_ids_cpu` -> device (the scheduler normally does this in `resolve_forward_inputs`). - Req construction (dflash + eagle3 + eagle3-vlm): `fill_ids` was removed in favor of `full_untruncated_fill_ids` (array) + integer `fill_len`. - capture `input_lens` BEFORE the forward — `origin_input_ids` is released during prepare_for_extend/forward on 0.5.13+. - bump pyproject pin to `sglang==0.5.14`. Benefits eagle3 + dflash (+ dspark, which builds on the dflash path). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two more 0.5.14 API drifts in the vendored parallel_state setup (surfaced building the target on 0.5.14, mirrors main's post-sgl-project#605 patch.py): - init_model_parallel_group() dropped the pynccl_use_current_stream kwarg (removed in 0.5.13) — remove it from the tp and pdmux_prefill_tp calls. - compute_dp_attention_world_info() now returns a 4-tuple (attn_tp_rank, attn_tp_size, attn_dp_rank, attn_dp_size); the attn-tp rank/size are no longer module globals, so keep only _ATTN_DP_RANK. Validated: sglang DFlash capture (Qwen2.5-0.5B) runs on sglang 0.5.14 and returns correctly-shaped concatenated hidden states. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
✅ Validated on real sglang 0.5.14 (venv on sci-h200, 8×H200, torch 2.11): the DFlash sglang capture path builds the target and runs a real forward — Note: needed two extra |
There was a problem hiding this comment.
Code Review
This pull request updates the sglang dependency from version 0.5.9 to 0.5.14 and adapts the sglang_backend/capture.py module to accommodate several breaking changes introduced in sglang versions 0.5.13 and 0.5.14. These adaptations include updating import paths, disabling chunked prefill, replicating post-load setup steps for the ModelRunner, handling host-to-device input ID copies, adjusting ForwardBatch initialization, capturing input lengths prior to forwarding, and replacing deprecated request attributes like fill_ids with full_untruncated_fill_ids and fill_len. There are no review comments, so I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
The 0.5.14 port added multi-line rationale comments at each sglang-API adaptation; several were 5-6 lines and the Req.fill_ids explanation was duplicated verbatim across the three req-construction sites. Collapse each to a concise "<version>: what changed / what we do" line, keeping the version markers (the useful part in a version-coupling boundary file) and dropping the prose. Comments only; no code changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…iter replaced_logits_processor_forward_for_eagle3 read self.multi_item_delimiter, which sglang removed from the LogitsProcessor in 0.5.13 (now carried per-request on the ForwardBatch as multi_item_delimiter_indices). On 0.5.14 that attribute access raises AttributeError on the eagle3 capture path (wrap_eagle3_logits=True); dflash sets it False, so the dflash smoke test did not exercise this. Extract the indices off the ForwardBatch before the LogitsMetadata conversion, mirroring sglang's own logits_processor. Matches the fix in sgl-project#605. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
🔁 Re-validated on sglang 0.5.14 after the eagle3 fix (
Both eagle3 and dflash capture paths now work on 0.5.14. |
Summary
Makes up-16's DataFlow target-capture backend work on sglang 0.5.14, and bumps the pin from
0.5.9→0.5.14(matchingmain).On
main, the 0.5.14 move landed as #605 (eagle3 / custom backends / shared infra) plus the follow-up branchpatch/fix_sgl0.5.14_dflash(the DFlash-specific_extendfixes #605 didn't include). Both were written against the old layout (specforge/modeling/target/dflash_target_model.py). up-16 consolidated eagle3 + dflash extend into a singleSGLangCaptureBackend(specforge/inference/target_engine/sglang_backend/capture.py), so the same sglang-API adaptations are applied there once and cover both draft algorithms (and DSpark, which builds on the DFlash path).Changes (
sglang_backend/capture.py)prepare_mlp_sync_batch_rawnow comes fromsglang.srt.managers.scheduler_components.dp_attn(moved from…scheduler_dp_attn_mixinin 0.5.14). This is the import that was hard-crashing the whole backend on 0.5.14.build(): 0.5.14 split the post-load setup out ofModelRunner.initialize()(which now only loads weights). Since we drive theModelRunnerdirectly (no scheduler/TpModelWorker), replicate it:alloc_memory_pool()/init_attention_backends()/init_cuda_graphs(). Also setchunked_prefill_size=-1— we prefill the whole batch in one_forward_extend, and 0.5.14's eager runner otherwise pre-allocates buffers sized to the defaultchunked_prefill_size(8192) and errors when our token count exceeds it._forward_extend():get_model_worker_batch()was removed —ForwardBatch.init_newnow consumes theScheduleBatchdirectly and readscapture_hidden_modeoff it. Also materializeprefill_input_ids_cpu→ device (the scheduler normally does this H2D copy inresolve_forward_inputs; we bypass the scheduler).Req.fill_idswas removed in favor offull_untruncated_fill_ids(anarray) + integerfill_len.input_lenscaptured before the forward —origin_input_idsis released duringprepare_for_extend/forward on 0.5.13+.pyproject.toml:sglang==0.5.9→sglang==0.5.14.sglang_backend/{utils,patch,model_runner}.pyneeded no changes.Testing
patch/fix_sgl0.5.14_dflash(DFlash) and upgraded sglang to v0.5.14 #605 (shared/eagle3), re-expressed for the consolidated backend.Notes
dataflow-up-16-zerocopyso DSpark (feat: DSpark trainer (DFlash + Markov/confidence heads + L1 distillation) #613) can rebase on top and exercise the DFlash sglanglast_hidden_statespath on 0.5.14.🤖 Generated with Claude Code