Repository navigation
[Refactor] spec: Move platform dispatch and Triton kernels into kernels/ops - #45504
Conversation
fill_front_out_cache_loc_func for post-verify move targetskernels/ops wrappers
kernels/ops wrapperskernels/ops
…upled-spec rid codec and inbox
|
/rerun-test test_next_verify_prep.py test_graph_pool_borrow.py test_move_accept_tokens_targets.py test_build_eagle_tree.py test_spec_ngram.py registered/spec/uno/test_uno.py test_spec_eagle.py test_spec_eagle_topk.py test_eagle_reject_sampling.py registered/spec/dflash/test_dflash.py test_dspark_kernel_parity.py test_dflash_overlap_hostsync.py test_renorm.py test_dflash_logits.py test_verify_mask.py test_kernels_namespace.py test_spec_utils_reexport_surface.py test_uno_tree_sparse_sampling.py test_eagle_worker_v2_topk1_fastpath.py test_dspark_accept_tail.py |
|
/tag-and-rerun-ci |
|
🚀 🚀 🚀 🚀 |
… importable - hooks.py: torch 2.14's `_CUDAGraph` binding reads `keep_graph` in `__init__`, so overriding only `__new__` let a bare `torch.cuda.CUDAGraph()` drop its raw graph at capture end, and decode graph capture failed in cuGraphInstantiate with CUDA_ERROR_INVALID_VALUE. - lifted.py: defer annotations. `Tuple`, `Optional` and `torch` are bound only in the SGLang module each function is rebound into, so the first verify raised `NameError: Tuple`. - lifted.py: `eagle_sample` drops its inline sampler imports, which referenced `_is_npu` (removed from eagle_utils by sgl-project/sglang#45504), and uses eagle_utils' module names. - lifted.py: `_draft_extend_for_decode` passes `sampling_seed=` and `positions=` again, as current SGLang does. Tested on 8x B300, GLM-5.3-NVFP4, TP8, EAGLE 3/1/4, SGLang f4a2df3dac, all spec_step switches on.
…traverse — entries 102,103,119-supersede,120,194,195,261-264 3 markers consumed (eagle_utils RE-PLANTED; spec_utils re-plant; eagle_info VERIFIED-ABSORBED). B4 tree count now 12. PER-FILE: - eagle_utils.py (entry 103): RE-PLANTED the tensors-after-early-return graft (num_needed_tokens == 0 returns before any torch.tensor -- the 17F were the fail-fast + alloc-path rebuilding CPU tensors every round; topk>1 max_alloc_len back to the list-builtin max) MERGED with upstream's in-range mirrorless block: it rides AFTER the tensors now (it reads cur_kv_lens_cpu) with a getattr-guarded seq_lens_cpu read -- identical semantics for the real ScheduleBatch (attr always present), stale-stub-proof. - spec_utils.py (entries 102,120,195; 261 deduped): * entry 261 sgl-project#45491: DEDUPED with evidence -- git log 12dc623..2a6c204 proves 573b571 IN RANGE; its verify-window semantics SURVIVE upstream's later refactors (sgl-project#45504 kernel move + sgl-project#46990 typed views collapsed the triton assign_extend_cache_locs pair) as fill_front_out_cache_loc_func(num_correct_drafts+1, batch.out_cache_loc, ...) carrying sgl-project#45491's OWN comment text; the fork-hunks window-form is thus superseded-in-place (origin/main has neither old name -- the replacement landed within the same range). * entry 195 sgl-project#44317: RE-PLANTED the traverse_tree host walk (tolist + numpy bitmask view; int words) + the needs_vocab_mask() skip (the backend-side methods ALREADY landed upstream in constrained/ -- consumer half was the dropped one) + the leftover-grammar_mask clear on the grammars-present-but-unconstrained path (the merged tree had the clear on the SUCCESS path only -- the stale-mask class this entry exists for). traverse_tree 3F -> green. * entry 102 (PLE on the ReplaySSM branches) + entry 120 (circular-ring fold before a plain extend): RE-PLANTED, RETARGETED to sgl-project#45504/sgl-project#46980 reality: kernel import path attention.fla.* -> attention.linear.* (upstream's kernels regroup), and the fold reads mamba_pool.get_speculative_mamba2_params_all_layers() (upstream sgl-project#46980 deleted the req-pool delegate; same route the verify-commit uses now). test_replayssm_extend_fold collection 1err -> 2P (the documented 'pair': its sibling test_replayssm_ring_fold.py was PRUNED by upstream's own sgl-project#44690 (file gone; a stale .pyc remains) and the 'gdn cutedsl probe' err belongs to kernels/ops/attention (6 CUDA-import collection errs there -- B1/B5 zone, not this dir): the spec-dir population is now 0err. test_replayssm_verify_ple_commit 1F -> green (stub re-anchored: router part_view seam + PLE pools off-pin restored -- the entry-102 pin the upstream file rewrite dropped, present in the 309-tip test verbatim). - eagle_info.py (entry 194): VERIFIED-ABSORBED -- the call sites pass num_token_blocks=None + kv_lens_sum, and runner_ids.pack_read_stream auto-sizes with the fork's OWN helper (spec_kv_index_token_blocks, now hosted in kernels/ops/attention/kv_indices) -- the 'AUTO-SIZED upgrade' B3-4 recorded; identical tiling math. - Entry-119 supersession chain CLOSED as briefed: sgl-project#45435's upstream form (tails padded -1 + mamba_lazy_undo_prealloc_at_boundary + untracked_decode_batch_idx gate) is the tree's reality (B4-2 audit); entry 119's production half stays dead. - test_ngram_mamba_verify_update.py (B2-marked file, B2 marker INTACT): restored only the two PLE off-pins + the entry-102 comment that the 309-tip fork version carried and upstream's rewrite dropped -- my re-plant re-creates the condition they exist for. ACTUALS (damage -> after, CVD=9, prod venv, per-file): test_eagle_decode_allocation 17F -> ** 18P ** (16-matrix + capacity + 1) test_spec_utils_traverse_tree 3F -> green (file pin incl.) test_replayssm_extend_fold 1err -> ** 2P ** test_replayssm_verify_ple_commit 1F -> green DIR unit/spec 363P/20F/21S/238sub/2err -> ** 388P/0F/21S/238sub/0err ** (two consecutive full-dir re-runs EXACT; DoD(b): zero non-env F). Lint: ruff format + F821/E9/F401 clean on the six files. No GPU; no push. Co-Authored-By: OpenCode <noreply@opencode.ai>
fill_front_out_cache_loc_funcandassign_draft_cache_locs_contiguous_funcinkernels/ops/speculative/cache_locs.py, each dispatching to the Triton kernel or thesgl_kernelCPU op;move_accept_tokens_to_target_kvcacheand the draft cache-loc assignment call them, andspec_utilsdrops its CPU-op imports,next_power_of_2, and the unusedassign_extend_cache_locsforwardsrt:compute_dflash_correct_drafts_and_bonustokernels/ops/speculative/dflash.py(sodspark_acceptno longer imports it fromsrt),table_qk_norm_rope_tokernels/ops/attention/table_qk_norm_rope.py, anduno_tree.pytokernels/ops/speculative/uno_tree.pyunchangedreconstruct_indices_from_tree_mask_funcinreconstruct_tree.py(Triton on XPU, the compiled op elsewhere);ngram_workerdrops its per-platform importsTreeMaskMode, the tree-build and greedy-verify Triton launchers, andverify_tree_greedy_funcintokernels/ops/speculative/spec_tree.py, and split the platform dispatch out ofbuild_tree_kernel_efficientintobuild_tree_kernel_efficient_func;eagle_utilskeeps the mask allocationkernels/ops/sampling/renorm.py(top_k_renorm_prob,top_p_renorm_prob) andkernels/ops/speculative/verify_sampling.py(tree_speculative_sampling_target_only,chain_speculative_sampling_triton),Nonewhere a platform has no kernel; DFlash and EAGLE import from there instead of each keeping its own tablealign_evict_mask_to_page_size,get_src_tgt_cache_loc,get_target_cache_loc, andfilter_finished_cache_loc_kernelwith theirspec_utilsforwards (and the unusedassign_req_to_token_poolforward),create_num_accept_tokens_filter,compute_ragged_extend_lengths,read_draft_checkpoint_gamma, and the decoupled-spec request-id codec,DraftControlInbox, andReadyDraftControls, which only their tests usedtest_next_verify_prep.pycalls the draft wrapper over a smaller matrix;test_graph_pool_borrow.pypatches the sampling op whereeagle_utilsbinds it; droptest_decoupled_spec_io.py, whose schema has no production callerNo behavior change on CUDA. Elsewhere: on NPU, DFlash's target-probability renormalization uses the
sgl_kernel_npuops EAGLE already uses, with thetorch_npupath as fallback; on CPU the draft assignment passeswindow_cols, which equalsnum_stepsthere.CI States
Latest PR Test (Base): 🚫 Run #39556705672
Latest PR Test (Extra): ❌ Run #39556705491
Latest PR Test (AMD ROCm 10): ⏳ Run #39556705596