-
Notifications
You must be signed in to change notification settings - Fork 499
feat: Support Linear Cross Entropy fuse kernel #1322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TaoZex
wants to merge
35
commits into
areal-project:main
Choose a base branch
from
TaoZex:lm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
c2852f3
feat(engine): LinearCrossEntropy
fc5211b
fix(kernel): continus
e494738
test(linear_cross_entropy): add test for tp > 1
9495141
test(linear_cross_entropy): log test
77ea280
refactor(test): remove useless test code
47fd3e2
perf: NVTX
203a7e4
feat(config): add use_fused_linear_ce config
e2e5d70
fix(utils): network
fecfcbd
feat(profiling):nsys flush
0b5eefe
fix(engine): fix
e69674e
feat(profiler): torch profile
d444cbe
fix(sequence_parallel): fix sp
07f03d8
fix(engine): dtype
003296b
fix(engine): dtype again
0020faa
test(linear_cross_entropy): fix test
fa82bb9
perf(benchmark): benchmark
4e9f8c7
refactor(fsdp): remove useless
64b91a4
refactor: remove test profile
92c4298
refactor(kernel): fix
c640e03
fix(kernel): fix code
8b1a243
refactor(kernel): fix
a6952f3
refactor(kernel): remove useless
6346396
refactor(kernel): comment
0b044e5
docs(kernels): fix
5e35bbe
feat(test): fix
09eff54
fix(engine): fix
825d44c
fix(megatron): fix vocab
8aaff93
feat(engine): fix conflict
292dab1
Merge branch 'main' into lm
TaoZex 8addb48
Merge branch 'main' into lm
TaoZex c5525d6
feat: precommit fix
9a6b467
feat: fix by comment
TaoZex 7fcc99b
feat: fix
TaoZex fa91e9d
Merge branch 'main' into lm
TaoZex a2b6d31
Merge branch 'main' into lm
TaoZex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we usually require fp32 logits, will this downcast operation cause a precision issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fused LCE kernel internally accumulates the matrix multiplication in
fp32. Therefore, even withbf16input hidden states, the precision of the logits and log-softmax computations within the kernel remains fully preserved infp32.In practice, the non-fused computation path follows:
bf16 hidden→bf16 matmul→bf16 logits→fp32 logits(upcast byFloat16Module) →fp32 log-softmax.In contrast, the fused path maintains
fp32accumulation throughout the entire computation, ensuring its numerical precision is at least on par with, if not better than, the non-fused baseline.