-
Notifications
You must be signed in to change notification settings - Fork 74
Add device type meta support for CutlassNvfp4GroupedMmaOp::evaluate
#5695
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1a99a15
Add device type meta support for CutlassNvfp4GroupedMmaOp::evaluate
zasdfgbnm 6b57c2d
save
zasdfgbnm 12680c9
Merge branch 'main' of github.com:NVIDIA/Fuser into CutlassNvfp4Group…
zasdfgbnm 5da5e22
save
zasdfgbnm e7b6b9c
save
zasdfgbnm 69e9b62
public
zasdfgbnm fda4d73
save
zasdfgbnm 877d21e
save
zasdfgbnm 4aa14ca
save
zasdfgbnm d3d371a
save
zasdfgbnm ba40d2f
save
zasdfgbnm 4897d9e
save
zasdfgbnm 2f407c3
save
zasdfgbnm 8c4cabb
save
zasdfgbnm f383c75
save
zasdfgbnm 2f6a74f
save
zasdfgbnm 3449af7
save
zasdfgbnm 65dec62
save
zasdfgbnm 7b38316
save
zasdfgbnm 588ec95
save
zasdfgbnm 6c326f5
save
zasdfgbnm 8489553
fix (#5800)
zasdfgbnm 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1713,7 +1713,6 @@ std::string CutlassNvfp4GroupedMmaOp::toInlineString(int indent_size) const { | |
| std::vector<PolymorphicValue> CutlassNvfp4GroupedMmaOp::evaluate( | ||
| const ExpressionEvaluator& ee, | ||
| const std::vector<PolymorphicValue>& inputs) const { | ||
| #if NVFUSER_CUTLASS_KERNEL_ENABLED | ||
| const auto& mat1 = inputs[0].as<at::Tensor>(); | ||
| const auto& mat2 = inputs[1].as<at::Tensor>(); | ||
| const auto& scale1 = inputs[2].as<at::Tensor>(); | ||
|
|
@@ -1722,6 +1721,29 @@ std::vector<PolymorphicValue> CutlassNvfp4GroupedMmaOp::evaluate( | |
| const auto& problem_sizes = inputs[5].as<at::Tensor>(); | ||
| const auto& expert_offsets = inputs[6].as<at::Tensor>(); | ||
| const auto& sf_offsets = inputs[7].as<at::Tensor>(); | ||
|
|
||
| // Meta-device fast path outside of torch version guard | ||
| if (mat1.is_meta() || mat2.is_meta() || scale1.is_meta() || | ||
| scale2.is_meta() || alpha.is_meta() || problem_sizes.is_meta() || | ||
| expert_offsets.is_meta() || sf_offsets.is_meta()) { | ||
| // For nvfp4_scaled_grouped_mm, the output shape is [M, N] | ||
| // where M = mat1.size(0) and N = mat2.size(1) | ||
| std::vector<int64_t> result_sizes = {mat1.size(0), mat2.size(1)}; | ||
|
||
|
|
||
| at::ScalarType out_dtype = data_type_to_aten(out()->dtype()); | ||
| auto options = | ||
| mat1.options().device(c10::Device(c10::kMeta)).dtype(out_dtype); | ||
| at::Tensor result = at::empty(result_sizes, options); | ||
|
|
||
| if (const auto rfactor_did_idx = getRFactorDeviceDimensionIndex(out()); | ||
| rfactor_did_idx != -1) { | ||
| result = result.unsqueeze(rfactor_did_idx); | ||
| } | ||
|
|
||
| return {result}; | ||
| } | ||
|
|
||
| #if NVFUSER_CUTLASS_KERNEL_ENABLED | ||
| NVF_CHECK( | ||
| mat1.scalar_type() == at::ScalarType::Float4_e2m1fn_x2 && | ||
| mat2.scalar_type() == at::ScalarType::Float4_e2m1fn_x2); | ||
|
|
||
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.
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.
I thought the output size
nis mat2.size(2).e.g. if you look at line 1767 below.