-
Notifications
You must be signed in to change notification settings - Fork 800
[PyTorch] [torch.compile] torch.compile support for Linear #3053
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
pggPL
wants to merge
19
commits into
NVIDIA:main
Choose a base branch
from
pggPL:linear_torch_compile_final_attempt
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
19 commits
Select commit
Hold shift + click to select a range
c6544d0
[PyTorch] [torch.compile] torch.compile support for Linear
pggPL dfa79c2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 116d477
[PyTorch] Keep the broad-except pylint disable on the anchored line
pggPL dc4ff77
[PyTorch] [torch.compile] Style pass on the Linear custom-op path
pggPL 250bd71
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 39d10f8
Address review: fix recompile assert, empty-batch sentinel collision,…
pggPL 2c37350
Address review: simplify check_gemm_dims, trim test comments, restore…
pggPL eb3f50f
Shorten check_gemm_dims docstring
pggPL 9695013
Drop tensor_can_be_materialized: inline an exact-class check in the t…
pggPL c64a0b0
Trim paraphrase comments in the Linear fake impls
pggPL b9bf693
Rename SP leading-dim helpers for direction clarity, trim two comments
pggPL aeb3481
Tighten custom_op module docstring intro
pggPL 53b811b
Merge and simplify custom_op docstring paragraphs 2-3
pggPL 948f94e
Keep the impl-vs-op contrast as two paragraphs
pggPL 872387f
Drop reference to a PyTorch PR that will not land
pggPL dcc3c9a
Shorten _ensure_distributed_opaque_types docstring
pggPL d87eda6
Fall back to eager cleanly when ProcessGroup opaque registration is u…
pggPL 1950585
Fix leftover 'priority order' wording at _FIELD_ADAPTERS
pggPL 9c4fadf
Restructure register_custom_op docstring: caller contract first, drop…
pggPL 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
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 |
|---|---|---|
|
|
@@ -111,6 +111,8 @@ def _run_layer_with_overlap( | |
| quantization, | ||
| num_layers=1, | ||
| use_cublasmp=False, | ||
| use_compile=False, | ||
| compile_mode="default", | ||
| ): | ||
| test_path = TEST_ROOT / "run_layer_with_overlap.py" | ||
| test_cmd = LAUNCH_CMD + [ | ||
|
|
@@ -129,6 +131,10 @@ def _run_layer_with_overlap( | |
| if overlap_rs_dgrad: | ||
| test_cmd.append("--overlap-rs-dgrad") | ||
|
|
||
| if use_compile: | ||
| test_cmd.append("--compile") | ||
| test_cmd.append(f"--compile-mode={compile_mode}") | ||
|
|
||
| if fp8: | ||
| if quantization in ("fp8_delayed_scaling", "fp8_current_scaling") and not fp8_available: | ||
| pytest.skip(reason_for_no_fp8) | ||
|
|
@@ -281,6 +287,34 @@ def test_layers_with_overlap_bf16( | |
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("compile_mode", ["default", "reduce-overhead"]) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kind of a general comment, but do we expect to ever see a case that would work under reduce |
||
| @pytest.mark.parametrize( | ||
| "linear_parallel_mode,overlap_rs_dgrad", | ||
| [ | ||
| ("row", False), | ||
| ("column", False), | ||
| ("column", True), | ||
| ], | ||
| ids=[ | ||
| "ROW-PARALLEL", | ||
| "COL-PARALLEL - BULK DGRAD/WGRAD", | ||
| "COL-PARALLEL - DGRAD+RS", | ||
| ], | ||
| ) | ||
| def test_linear_with_overlap_compile(linear_parallel_mode, overlap_rs_dgrad, compile_mode): | ||
| """te.Linear comm+GEMM overlap (Userbuffers) under torch.compile (BF16), | ||
| checked numerically against the eager, non-overlap reference.""" | ||
| _run_layer_with_overlap( | ||
| te.Linear.__name__, | ||
| linear_parallel_mode, | ||
| overlap_rs_dgrad, | ||
| False, | ||
| None, | ||
| use_compile=True, | ||
| compile_mode=compile_mode, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("use_cublasmp", (False, True)) | ||
| @pytest.mark.parametrize( | ||
| "quantization", | ||
|
|
||
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.
So how do we test the lower overhead mode? Shouldn't we just do that mode of the compilation if this
option is set?