Skip to content

[Fix] diffusion: Fix VMoBA chunk selection bugs - #44286

Merged
BBuf merged 7 commits into
sgl-project:mainfrom
OnePunchMonk:fix/vmoba-selection-bugs
Oct 19, 2026
Merged

BBuf merged 7 commits into
sgl-project:mainfrom
OnePunchMonk:fix/vmoba-selection-bugs

Conversation

@OnePunchMonk

@OnePunchMonk OnePunchMonk commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes several selection bugs in vmoba_attn/vmoba/vmoba.py, each reproduced on main first.

  • topk + head_global never applied valid_gate_mask, so topk could pick -inf entries from other sequences in the batch.
  • The "select everything" fallback used full_like(any_cond, C-1), which is bool, so the cutoff became 1 (query_head, block). Now torch.full(..., dtype=torch.long).
  • threshold + overall raised IndexError (argmax on empty tensor) when every sequence fits in one chunk. Now returns the self-chunk mask early.
  • When nothing was selected, the code ran dense attention over the whole sequence. It now attends within the self chunk (cu_chunk).
  • Threshold mode always added one extra chunk even when the self chunk already met the threshold. Cutoff is now -1 in that case (all four modes).
  • Zero-length sequences corrupted the chunk layout. The caller drops them, calc_chunks raises on them.
  • Removed lru_cache on calc_chunks (tensor-identity key, stale on in-place updates). Fixed the topk/threshold error messages.

Not included: the kernel.attn.vmoba_attn import path (needs a packaging decision) and host-sync cleanup.

Tests

New tests/test_vmoba_selection.py, CPU only, fakes only the flash-attn kernel. 13 of 16 fail on main, 16 pass with this change. black clean. Independent review found no blocking issues.

Limitations

No GPU end-to-end run, so flash-attn kernel integration is untested.


CI States

Latest PR Test (Base): ✅ Run #39151568172
Latest PR Test (Extra): ❌ Run #39151568018
Latest PR Test (AMD ROCm 10): ❌ Run #39151568205

@github-actions github-actions Bot added the diffusion SGLang Diffusion label Oct 14, 2026
@OnePunchMonk OnePunchMonk changed the title [multimodal_gen] Fix VMoBA chunk selection bugs [diffusion] Fix VMoBA chunk selection bugs Oct 14, 2026
@OnePunchMonk OnePunchMonk changed the title [diffusion] Fix VMoBA chunk selection bugs [Fix] diffusion: Fix VMoBA chunk selection bugs Oct 14, 2026
@OnePunchMonk

Copy link
Copy Markdown
Contributor Author

hi @mickqian , please provide a first pass review for this pr once you have some time. thank you!

@BBuf BBuf 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; the 16 selector tests pass locally. Please rebase onto main and add a GPU parity check for mixed sparse selection and the self-chunk-only fallback.

@BBuf BBuf added the run-ci CI: run the baseline test suite on this PR label Oct 18, 2026
- head_global topk now applies valid_gate_mask (no cross-batch attention)
- fallback cutoff is C-1 (was bool True) in query_head and block
- overall threshold no longer crashes when only self chunks exist
- empty selection attends to the self chunk, not the whole sequence
- threshold mode selects no extra chunk when the self chunk meets it
- drop empty sequences; calc_chunks rejects them; remove lru_cache
- add CPU regression tests
@OnePunchMonk
OnePunchMonk force-pushed the fix/vmoba-selection-bugs branch from 007b5a4 to 042efda Compare October 18, 2026 12:02
@@ -0,0 +1,264 @@
# SPDX-License-Identifier: Apache-2.0

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.

The test file is too long, can you do a cleanup?

@OnePunchMonk OnePunchMonk Oct 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

have split it into two

@BBuf
BBuf merged commit c04f9a6 into sgl-project:main Oct 19, 2026
191 of 202 checks passed
BBuf added a commit to BBuf/sglang that referenced this pull request Nov 4, 2026
…y say

- VMoBA: the runtime imported kernel.attn.vmoba_attn.vmoba, a module that
  does not exist, so the chunk-selection fix of sgl-project#44286 never ran. Import
  the in-tree copy, require flash-attn 2 at backend resolution, drop its
  stale setup.py/README/speed script, and move its tests into the unit
  suite (the CUDA ones skip without flash-attn 2).
- Add --enable-attention-backend-autotune for the documented field; fix
  ring_sp_performance.mdx to the real --kv-gather-degree flag.
- Drop --mask-strategy-file-path (it set an unread field); the sliding-tile
  error now names --attention-backend-config mask_strategy_file_path.
- HiDream-O1 rejects --flow-shift/--scheduler-class-override like its
  other ignored overrides; HunyuanImage-3 keeps a user --flow-shift.
- /v1/images/edits returns 400 for a mask instead of ignoring it.
- Drop the per-role requests_timed_out counter nothing increments.
- PortArgs keeps only master_port: the three IPC names were never read
  and each construction leaked three temp files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion SGLang Diffusion run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants