Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def forward(
combined_embeddings = split_data_cp_rank(combined_embeddings, cp_size, 0, cp_rank)
if packed_seq_params is not None:
if attention_mask is None:
attention_mask = torch.ones_like(input_ids, dtype=torch.int32, device=input_ids.device)
attention_mask = torch.ones_like(input_ids, dtype=torch.bool, device=input_ids.device)
input_ids_thd, _ = preprocess_packed_seqs(
input_ids, attention_mask, pre_process=True, pg_collection=self.pg_collection
)
Expand Down Expand Up @@ -456,7 +456,7 @@ def forward(
# convert lm_input_ids to THD format so it matches position_ids.
if packed_seq_params is not None:
if attention_mask is None:
attention_mask = torch.ones_like(input_ids, dtype=torch.int32, device=input_ids.device)
attention_mask = torch.ones_like(input_ids, dtype=torch.bool, device=input_ids.device)
lm_input_ids, _ = preprocess_packed_seqs(
input_ids, attention_mask, pre_process=True, pg_collection=self.pg_collection
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,11 @@ def preprocess_packed_seqs(
"""
batch_size = input_ids.shape[0]

# Ensure boolean dtype for correct advanced indexing (bool → mask select,
# int → fancy index which silently corrupts data when values are 0/1).
if attention_mask.dtype != torch.bool:
attention_mask = attention_mask.bool()

seqlens_in_batch = attention_mask.sum(dim=-1, dtype=torch.int32)
if pg_collection is not None:
tp_size = pg_collection.tp.size()
Expand Down
Loading