[Perf] Reduce DFlash2 attention cost and screen exact QK reuse - #589
Merged
yangzhuxinyzx merged 6 commits intoSep 10, 2026
Merged
Conversation
Assisted-by: Codex Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Retain exact compensated arithmetic while reducing 256K attention work. Record native, sanitizer, paired-service and rejected-layout evidence. Assisted-by: Codex Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Record actual q8 kernel attribution, resource and route evidence, and the offline recovery of the original Nsight capture. Assisted-by: Codex Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Assisted-by: Codex Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Assisted-by: Codex Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
This was referenced Sep 9, 2026
Assisted-by: Codex Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
yangzhuxinyzx
changed the base branch from
codex/v100-dflash2-long-verify-20260909-152813
to
main
September 10, 2026 09:01
yangzhuxinyzx
marked this pull request as ready for review
September 10, 2026 09:01
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
Reduce DFlash2 target q8 attention at 256K while preserving full context, K16 compensated FP32 sums, N32 online updates, 80 logical splits and the complete FP32 workspace. The user now requires all sixteen target attention layers <=7 ms; complete verification rounds must also reach <=22 ms. Neither target is met.
The selected private E4M3 lookup plus compact P/residual layout improves sixteen-layer attention 14.893 → 12.983 ms. Actual service graph-node attribution confirms 13.077 ms per rank/round. One same-startup A/B improves complete rounds 36.134 → 33.263 ms, with all 12 request pairs identical in tokens, finish reasons and draft acceptance.
New private QK producers reuse each K fragment across three independent M16 products. The best QK-only result improves 6.521 → 5.545 ms, excluding softmax, PV, merge and service execution. It is not a 7-ms attention result. Full attention integration of this producer is incomplete.
Prerequisites #586 and #587 are merged into main. This PR now targets main
213bd9c31ed1ebf2d06ac865a76c5f302ae82b9b; review head isbe8f8ca4b931e940fffcd054ee183951273b5c0d. Latest main changes have been merged into the owned branch without conflicts. The measured private native sources remain frozen; the numerical/performance results below refer to those exact libraries. All candidates are hashed private extensions; no serving default changes. Assisted by Codex.Test Plan
Test Result
The service-checked P-layout candidate passes 65 native checks, 60 tail checks and 25 cases each under memcheck/racecheck/synccheck, with zero errors or hazards. All 12 service request pairs match. Its trace has sixteen full-q8 and sixteen combine kernels in each of eight interior rounds on four ranks. Unprofiled pure decode improves 128.310 → 139.384 tokens/s; the startup's generation trajectory differs from earlier trials, so comparisons remain within the paired startup.
New seven-millisecond screens:
Ten later QK sources and the compact-CTA source regenerate byte for byte. The first historical direct-QK source predates explicit carveout requests and formatting; its measured frozen source/manifest are retained separately. All applicable pre-commit hooks pass. Compiler resource limits are not achieved occupancy; Nsight Compute counters remain unavailable under the driver policy.
Source/DSO hashes, configurations, raw report names, rejected variants and reproduction commands are in
docs/design/sm70_dflash2_attention_resources_20260910.md. Absolute artifact paths and GPU ownership are retained in the local handoff.The user explicitly requested merging the current optimization work on 2026-09-10. The selected service result remains13.077 ms attention and33.263 ms per complete round. The7-ms/22-ms targets, repeated-startup and expanded natural-output admission are still open. No numerical-contract change is admitted.
Main integration validation
This PR is the final eight-file benchmark/builder/documentation delta after #586 and #587. It does not duplicate their runtime loader or graph-selection changes. The combined main tree
0046aea49749fcaa83f0fa2a2af73f5dfed6b3afpassesCUDA_VISIBLE_DEVICES='' .venv/bin/python -m pytest -q tests/v1/worker/test_sm70_long_attention_graphs.py tests/kernels/core/test_sm70_dflash2_state_audit.py(26 passed, 1 skipped) and all applicable pre-commit hooks across the full35-file DFlash2 stack. Both prerequisite merge trees exactly match the locally reviewed three-way merges. The final branch retains the same tested source tree after incorporating their GitHub merge commits.The current main merge is explicitly user-authorized. Keep experimental options opt-in and retain outstanding admission/7-ms/22-ms limits. No additional service deployment or default activation is included.