[GH-ISSUE #190] [Bug]TMA Multicast code issue #107

Closed
opened 2026-10-26 21:12:45 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @afei6 on GitHub (Sep 11, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepGEMM/issues/190

in file /sgl-workspace/DeepGEMM/csrc/jit_kernels/heuristics/common.hpp:213-226
This piece of code logic seems not correct:

    // Decide the number of TMA multicasts and whether broadcast on A
    MulticastConfig best_multicast_config = {1, true};
    const auto& [is_legal_on_a, is_legal_on_b] = ArchSpec::get_multicast_legality(gemm_type, m, n, best_block_m, best_block_n, num_sms);
    const bool is_legal[2] = {is_legal_on_a, is_legal_on_b};
    bool order[2] = {false, true};
    if (best_block_m > best_block_n)
        std::swap(order[0], order[1]);
    for (const bool& is_multicast_on_a: order) {
        if (m >= 512 and is_legal[static_cast<int>(is_multicast_on_a)]) {
            best_multicast_config = {2, is_multicast_on_a};
            break;
        }
    }

When the best_block_m bigger than best_block_n the order vector is swapped. The is_multicast_on_a is ture now. In the if condition is_legal[static_cast<int>(is_multicast_on_a)] will access the is_legal[1] which is actually checking the is_legal_on_b instead.

Originally created by @afei6 on GitHub (Sep 11, 2025). Original GitHub issue: https://github.com/deepseek-ai/DeepGEMM/issues/190 in file `/sgl-workspace/DeepGEMM/csrc/jit_kernels/heuristics/common.hpp:213-226` This piece of code logic seems not correct: ``` // Decide the number of TMA multicasts and whether broadcast on A MulticastConfig best_multicast_config = {1, true}; const auto& [is_legal_on_a, is_legal_on_b] = ArchSpec::get_multicast_legality(gemm_type, m, n, best_block_m, best_block_n, num_sms); const bool is_legal[2] = {is_legal_on_a, is_legal_on_b}; bool order[2] = {false, true}; if (best_block_m > best_block_n) std::swap(order[0], order[1]); for (const bool& is_multicast_on_a: order) { if (m >= 512 and is_legal[static_cast<int>(is_multicast_on_a)]) { best_multicast_config = {2, is_multicast_on_a}; break; } } ``` When the `best_block_m` bigger than `best_block_n` the `order` vector is swapped. The `is_multicast_on_a` is ture now. In the `if` condition `is_legal[static_cast<int>(is_multicast_on_a)]` will access the `is_legal[1]` which is actually checking the `is_legal_on_b` instead.
Author
Owner

@yukuai26 commented on GitHub (Sep 12, 2025):

Hi, @afei6 . Thank you for pointing this out. In fact, we also happened to discover this issue yesterday. This is the fix for this.
#193

<!-- gh-comment-id:3284707512 --> @yukuai26 commented on GitHub (Sep 12, 2025): Hi, @afei6 . Thank you for pointing this out. In fact, we also happened to discover this issue yesterday. This is the fix for this. #193
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepGEMM#107
No description provided.