Skip to content

Commit 8255f87

Browse files
lhb8125Hongbin Liutimmoon10ksivaman
authored
Support FP16 for user buffer (NVIDIA#690)
* add_dtype_for_userbuf Signed-off-by: Hongbin Liu <[email protected]> * Update transformer_engine/pytorch/module/base.py Signed-off-by: Tim Moon <[email protected]> * Fix syntax Signed-off-by: Kirthi Shankar Sivamani <[email protected]> * Fix lint Signed-off-by: Kirthi Shankar Sivamani <[email protected]> --------- Signed-off-by: Hongbin Liu <[email protected]> Signed-off-by: Tim Moon <[email protected]> Signed-off-by: Kirthi Shankar Sivamani <[email protected]> Co-authored-by: Hongbin Liu <[email protected]> Co-authored-by: Tim Moon <[email protected]> Co-authored-by: Kirthi Shankar Sivamani <[email protected]>
1 parent b459ccc commit 8255f87

File tree

1 file changed

+5
-2
lines changed
  • transformer_engine/pytorch/module

1 file changed

+5
-2
lines changed

transformer_engine/pytorch/module/base.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def initialize_ub(
111111
shape: list,
112112
tp_size: int,
113113
use_fp8: bool = False,
114+
dtype: torch.dtype = torch.bfloat16,
114115
ub_cfgs: Optional[dict] = None
115116
) -> None:
116117
"""Initialize communicators for TP comm overlap using userbuffers."""
@@ -151,8 +152,10 @@ def add_ub(
151152
num_splits: int = 4,
152153
aggregate: int = 0,
153154
) -> None:
154-
dtype = torch.uint8 if (use_fp8 and name in fp8_buf) else torch.bfloat16
155-
sample_buffer = torch.empty(shape, dtype=dtype, device='cuda')
155+
sample_buffer = torch.empty(
156+
shape,
157+
dtype=torch.uint8 if (use_fp8 and name in fp8_buf) else dtype,
158+
device='cuda')
156159
if method == 'ring_exchange':
157160
ub_obj = tex.UbufP2PCommOverlap(
158161
sample_buffer, # Sample userbuffer

0 commit comments

Comments
 (0)