Skip to content

feat(qwen3.8): add optional DeepSelect QSA selector - #3923

Open
HuiyingLi wants to merge 6 commits into
mainfrom
huiyingl/perf/qwen38-deepselect
Open

HuiyingLi wants to merge 6 commits into
mainfrom
huiyingl/perf/qwen38-deepselect

Conversation

@HuiyingLi

@HuiyingLi HuiyingLi commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

What does this PR do ?

Add an optional DeepSelect backend for Qwen3.8 FlashNext's QSA compressed-block selection. Set model.backend.qsa_topk: deepselect on the model-owned backend config to select 512 causal blocks from FP32 CUDA scores; the default remains torch.

Changelog

  • Add Qwen3_8_FlashNextBackendConfig and recipe/backend resolution without adding a QSA setting to the shared BackendConfig.
  • Integrate the optional deep_select extension with row alignment and per-query causal bounds. Preserve dense prefixes, incomplete-block tails, packed document handling, and CP offsets.
  • Install pinned, unmodified DeepSelect source directly in the Dockerfile: clone with submodules, build a wheel with uv, then install it into system site-packages inherited by the image's uv environment. NVCC_APPEND_FLAGS adds SM90a to upstream's SM100a/SM103a targets. Building the wheel first avoids disagreement between upstream's timestamped metadata and wheel versions.
  • DeepSelect and Torch may select different valid top-k sets when scores tie; parity tests distinguish tied and non-tied inputs.
  • Add CPU configuration/default-path tests and H100 route, packed-input, attention-output, gradient, and activation-checkpoint parity tests.

Before your PR is "Ready for review"

Pre checks:

  • Read and followed contributor guidelines.
  • Added necessary tests.
  • Included usage and dependency requirements in this PR description.

Validation on DFW:

  • Model CPU suite: 89 passed, 2 skipped, with CUDA hidden and TORCH_COMPILE_DISABLE=1 for CPU math tests.
  • Clean-container installation from unmodified upstream revision 0f03b68748b304863fdf0181a11458d04ae533a9 using uv build --wheel followed by wheel installation, with CUDA_VISIBLE_DEVICES empty during compilation. Tracked upstream source has no diff.
  • DeepSelect H100 functional suite: 4 passed with the directly built wheel, compilation enabled; BF16 attention D256, up to 4K keys. The package loads from system site-packages; no previous DeepSelect experiment directory is on PYTHONPATH.
  • cuobjdump confirmed SM90a/SM100a/SM103a in the built extension. Blackwell runtime execution was not run.
  • Docker RUN shell syntax, Ruff format/lint and git diff --check passed. Full Docker image build was not run.
  • Runtime: PyTorch 2.13.0a0+8145d630e8.nv26.06 on H100.

Additional Information

The extension is source-built outside uv's project resolution; standalone uv sync does not install it. Use the image built by this PR, which installs the extension by default.

This PR is independently based on main. It keeps the existing FlexAttention implementation and indexer scheduling; FA4 integration and the separate indexer scheduling optimizations are outside its scope.

Validation artifacts: /lustre/fsw/portfolios/coreai/users/huiyingl/qwen38next/deepselect_pr_20260916/ on DFW.

End-to-end training throughput

Qwen3.8 FlashNext full-model training (48 layers), 8 nodes × 8 H100, EP64, sequence length 8192, LBS 1 / GBS 64, BF16, mock data with fake_balanced_gate=true. Ablation based on main 9d875a6d3; variants ran in the same allocation, with 30 measured steps after 20 warmup steps.

Variant TPS/GPU Throughput gain
FA4 + Torch top-k 2,083.81
FA4 + DeepSelect top-k 2,105.03 +1.02%

Both variants use FA4 and the same indexer scheduling (query_chunk_size=128); this measures the selector change alone.

TPS/GPU counts training label tokens over the complete training-loop time, divided by 64 GPUs.

Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
@HuiyingLi
HuiyingLi requested a review from a team as a code owner September 17, 2026 04:39
@copy-pr-bot

copy-pr-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
@HuiyingLi
HuiyingLi requested a review from a team as a code owner September 17, 2026 05:04
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
@HuiyingLi

Copy link
Copy Markdown
Contributor Author

End-to-end training throughput

Qwen3.8 FlashNext full-model training (48 layers), 8 nodes × 8 H100, EP64, sequence length 8192, LBS 1 / GBS 64, BF16, mock data with fake_balanced_gate=true. Ablation based on main 9d875a6d3; variants ran in the same allocation, with 30 measured steps after 20 warmup steps.

Variant TPS/GPU Throughput gain
FA4 + Torch top-k 2,083.81
FA4 + DeepSelect top-k 2,105.03 +1.02%

Both variants use FA4 and the same indexer scheduling (query_chunk_size=128); this measures the selector change alone.

TPS/GPU counts training label tokens over the complete training-loop time, divided by 64 GPUs.

Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
@HuiyingLi

Copy link
Copy Markdown
Contributor Author

/ok to test d16988b

Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
@HuiyingLi

Copy link
Copy Markdown
Contributor Author

/ok to test 7ca8baf

Comment thread docker/Dockerfile

# Install DeepSelect from unmodified upstream source; add H100 via NVCC flags.
# Build the wheel once so upstream's timestamped version stays consistent.
ARG INSTALL_DEEPSELECT=true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@HuiyingLi two asks:

  • can we include it in the pyproject.toml?
  • we have a test that ensures commits are in-sync btwn pyproject.toml and dockerfile, can you include deepselect?

This branch was successfully deployed

3 active deployments
public 7ca8bafe Deployed Sep 18, 2026 by copy-pr-bot[bot] via release / finalize / notify #4677
test 7ca8bafe Deployed Sep 18, 2026 by copy-pr-bot[bot] via cicd-wait-in-queue #10845
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.

2 participants