Gk/tp strong scaling clean - #60
Merged
Merged
Conversation
Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
lucaslie
reviewed
Jun 11, 2025
lucaslie
reviewed
Jun 11, 2025
Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
Author
|
@lucaslie Implemented custom GQA_block in the |
greg-kwasniewski1
marked this pull request as ready for review
June 12, 2025 19:12
lucaslie
approved these changes
Jun 14, 2025
There was a problem hiding this comment.
@greg-kwasniewski1 , this looks great. I kicked off a dashboard run with your changes: https://gitlab-master.nvidia.com/ftp/infra/autodeploy-dashboard/-/pipelines/30068368
I think it's worth checking what happens and if all models pass as before. Let's monitor it and see what happens
Nevermind, Let's get it merged and look at the dashboard tomorrow morning after it ran on the feature branch :)
lucaslie
pushed a commit
that referenced
this pull request
Jun 24, 2025
* Fixed TP strong scaling if TP > num_kv_heads Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com> * Fixed test_graph_sharding. Attention uses simple_shard Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com> * head_dim inferred from the graph directly. Fixed test_graph_sharding.py Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com> * changed GQA block to fit column_row_shard heuristic requirements Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com> * Fixed parameter count Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com> --------- Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
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.
[https://github.com/NVIDIA/issues/4308][bug] TP > num_kv_heads fix
Description
Current TP strategy always distributes weight matrix either row-wise or column-wise using the entire WORLD_SIZE. For weight matrices such as w_k of shape [num_kv_heads * head_dim, embd], if TP > num_kv_heads , this results in distributing the individual heads, which leads to incorrect attention computation.
This PR fixes it by passing optional parameter
min_local_size, derived frommodel.configto thecolumn_row_shardlogic. Then it calculates maximum number of distributed groupsnum_groups = world_size * min_local_shape / t.shape[d].If
world_size > max_split_size, then the sharder groups ranks intonum_groupsgroups, each rank in the groupsharing (replicating) the same slice of the weight tensor.
Test Coverage
Added new class GQABlock to
test_graph_sharding.pyunittest, which explicitly specifies q_proj, k_proj, v_proj, withnum_kv_heads < num_heads.