Repository navigation
Conversation
wwwjn
marked this pull request as ready for review
April 8, 2026 04:13
wwwjn
requested review from
SherlockNoMad,
aditvenk,
fegin,
tianyu-l,
wconstab,
xmfan and
yiming0416
as code owners
April 8, 2026 04:13
tianyu-l
reviewed
Apr 8, 2026
tianyu-l
left a comment
Contributor
There was a problem hiding this comment.
looks reasonable, had some suggestions
Contributor
There was a problem hiding this comment.
are these changes tested with TP applied on DCP side?
tianyu-l
reviewed
Apr 8, 2026
tianyu-l
approved these changes
Apr 9, 2026
tianyu-l
left a comment
Contributor
There was a problem hiding this comment.
I didn't check state dict adapter code.
wwwjn
force-pushed
the
fused-qkv
branch
2 times, most recently
from
April 14, 2026 18:19
18997fd to
ba6a29d
Compare
saforem2
added a commit
to saforem2/torchtitan
that referenced
this pull request
Apr 18, 2026
Replay upstream changes from PRs pytorch#2878 (fused QKV) and pytorch#2842/pytorch#2960 (attention backend abstraction) onto the ezpz agpt experiment: - Replace inner_attention/mask_type params with attn_backend string and fuse_qkv bool in _build_agpt_layers and _build_agpt_config - Add _ezpz_get_attention_config() that overrides the sdpa case with XPU-aware EzpzScaledDotProductAttention, delegates others to upstream - Remove deepcopy-based _apply_flex_attn/_apply_varlen_attn overlays; configs now specify attn_backend directly - Add FusedQKVLinear detection and branching TP plan in parallelize.py - Pass fuse_qkv through to make_gqa_config() - Preserve all XPU customizations (SDPA workaround, Megatron init, capture_scalar_outputs fix)
2 tasks done
SherlockNoMad
added a commit
that referenced
this pull request
Apr 20, 2026
…3031) ## Summary - Updates hardcoded expected hashes in `test_bitwise_deterministic.py` for `TestLlama3BitwiseDeterministic` and `TestLlama3FlexAttnBitwiseDeterministic` ## Root Cause `git bisect` identified **#2878** (`ad7a8653` — "Fused QKV GQAttention implementation") as the commit that broke these tests. That PR replaced separate `wq`/`wk`/`wv` projections with a single fused `wqkv` linear in `GQAttention`, which changed the parameter layout and therefore the deterministic model/gradient hashes. **Verified:** - Parent commit `aa0214b8` (before #2878): both tests pass - Commit `ad7a8653` (the PR itself): both tests fail **Loss values are unchanged** — only the model and gradient hashes differ, confirming the fused QKV change altered parameter layout but not numerics. ## Test plan - [x] `pytest torchtitan/experiments/graph_trainer/tests/test_bitwise_deterministic.py::TestLlama3BitwiseDeterministic::test_eager_self_deterministic` passes - [x] `pytest torchtitan/experiments/graph_trainer/tests/test_bitwise_deterministic.py::TestLlama3FlexAttnBitwiseDeterministic::test_eager_self_deterministic` passes
wwwjn
added a commit
that referenced
this pull request
Apr 25, 2026
Port the fused QKV (FusedQKVLinear) handling from Qwen3's adapter to Qwen3-VL. When fuse_qkv is enabled, to_hf() splits wqkv into separate q/k/v projections, and from_hf() fuses them back. This is needed for PR #2878 which switches Qwen3-VL to use FusedQKVLinear. ## Test Load Qwen3-VL-2B-Instruct weight into a fusedQKV Qwen3-VL model
This was referenced Sep 1, 2026
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.
Implementation
Replaces separate wq, wk, wv with single wqkv linear of shape [n_kv_heads * R * head_dim, dim], where R = heads_per_kv + 2. Fused q/k/v project to reduce number of matmul kernel launches, and also reduce the number of TP communication kernel launches.
Model-wise:
q_lora_rank), makes it not easy to interact with fusing decision.Test
using llama3 debug model:
Performance test fused v.s. unfused:
Test with DCP + state_dict_adapter: