Conversation
transpose Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
…bias gradient Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
|
/te-ci |
for more information, see https://pre-commit.ci
|
|
/te-ci |
# Conflicts: # transformer_engine/pytorch/module/layernorm_linear.py # transformer_engine/pytorch/module/layernorm_mlp.py
for more information, see https://pre-commit.ci
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
|
/te-ci |
vthumbe1503
left a comment
There was a problem hiding this comment.
LGTM. My comments are nits. Its surprising how using views for semantic convinience introduces so much CPU overheads. GroupedLinear would also benefit with similar optimizations I hope.
| NVTE_CHECK(output.data.shape[0] == row_length, "Output has invalid first dimension (expected ", | ||
| row_length, ", got ", output.data.shape[0], ")."); | ||
| const size_t output_cols = std::accumulate(output.data.shape.begin() + 1, output.data.shape.end(), | ||
| size_t{1}, std::multiplies<size_t>()); | ||
| NVTE_CHECK(output_cols == num_rows, | ||
| "Output has invalid product of dimensions after the first (expected ", num_rows, | ||
| ", got ", output_cols, ")."); |
There was a problem hiding this comment.
Nit: can we use flat_2d_dims for output as well?
| NVTE_CHECK(output.data.shape[0] == row_length, "Output has invalid first dimension (expected ", | |
| row_length, ", got ", output.data.shape[0], ")."); | |
| const size_t output_cols = std::accumulate(output.data.shape.begin() + 1, output.data.shape.end(), | |
| size_t{1}, std::multiplies<size_t>()); | |
| NVTE_CHECK(output_cols == num_rows, | |
| "Output has invalid product of dimensions after the first (expected ", num_rows, | |
| ", got ", output_cols, ")."); | |
| const auto [out_rows, out_cols] = output.flat_2d_dims(); | |
| NVTE_CHECK(out_rows== row_length, "Output has invalid first dimension (expected ", | |
| row_length, ", got ", out_rows, ")."); | |
| NVTE_CHECK(out_cols == num_rows, | |
| "Output has invalid product of dimensions after the first (expected ", num_rows, | |
| ", got ", out_cols, ")."); |
| if return_layernorm_output: | ||
| if return_layernorm_output_gathered: | ||
| shape = list(inp_shape) | ||
| shape[0] *= tp_size if (sequence_parallel and set_parallel_mode) else 1 |
There was a problem hiding this comment.
lint seems to be failing since tp_size is not longer used in this function
Description
This PR removes the unnecessary calls to view() from the TE modules to avoid the CPU overhead.
Results on GB200 (just the CPU time is reported):
Each commit is standalone and can be reviewed on its own.
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: