[MLU] feat(fused_kernel): add fused linear_cross_entropy kernel for MLU - #12
Open
uqyxx wants to merge 5 commits into
Open
[MLU] feat(fused_kernel): add fused linear_cross_entropy kernel for MLU#12uqyxx wants to merge 5 commits into
uqyxx wants to merge 5 commits into
Conversation
Contributor
Author
|
Hi @physics31415926 , thanks for your comments, all issues resolved, please review. |
| accu_ptrs = accu_ptr + offs_m_cur[:, None] * stride_accu_m + offs_n[None, :] * stride_accu_n | ||
| entropy_b_ptrs = entropy_b_ptr + offs_m_cur[:, None] * stride_entropy_b_m + offs_n[None, :] * stride_entropy_b_n | ||
|
|
||
| _max = tl.load(max_ptrs, mask=mask_n) |
Collaborator
There was a problem hiding this comment.
Please set other on these masked loads (-inf for maxima, 0 for accumulators). For vocab_size=151936, 149 splits occupy a 256-wide block, so undefined masked lanes enter the reductions and can corrupt logprobs/entropy. The TP epilogue needs the same fix.
| pid_n = tile_idx // num_pid_m | ||
|
|
||
| if pid_m == 0 and pid_n == 0: | ||
| tl.store(global_logprobs_scalar_ptr, 0.0) |
Collaborator
There was a problem hiding this comment.
With reduction="none", this pointer aliases logprobs[0]. If another program writes the first token's label logit before this store, it gets overwritten with zero. Please remove this store; sum/mean outputs are already zero-initialized on the host.
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.
Summary
Add MLU fused linear_cross_entropy kernel.
Changes
Add linear_cross_entropy and function_wrapper to replace original linear_cross_entropy when running on MLU.
Testing
pytest tests/ -vpassesChecklist
pre-commitchecks