Skip to content

Commit 67fe1ec

Browse files
cuichenxabhinavg4
authored andcommitted
Fix nemo 1 packed sequence TE version error (#11874)
* fix nemo 1 packed sequence TE version error Signed-off-by: Chen Cui <[email protected]> * limit condition to only CP=1 case Signed-off-by: Chen Cui <[email protected]> * add cudnn version guard Signed-off-by: Chen Cui <[email protected]> * Apply isort and black reformatting Signed-off-by: cuichenx <[email protected]> --------- Signed-off-by: Chen Cui <[email protected]> Signed-off-by: cuichenx <[email protected]> Co-authored-by: cuichenx <[email protected]> Signed-off-by: Abhinav Garg <[email protected]>
1 parent 795a84d commit 67fe1ec

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

nemo/collections/nlp/models/language_modeling/megatron_gpt_model.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
drain_embedding_wgrad_compute,
103103
get_model_config,
104104
init_method_normal,
105+
is_te_min_version,
105106
scaled_init_method_normal,
106107
)
107108

@@ -1366,7 +1367,17 @@ def fwd_output_and_loss_func(dataloader_iter, model, checkpoint_activations_all_
13661367
'attention_mask': None if self.get_attention_mask_from_fusion else batch['attention_mask'],
13671368
'labels': batch['labels'] if 'labels' in batch else None,
13681369
}
1369-
1370+
else:
1371+
from packaging.version import Version as PkgVersion
1372+
1373+
if (
1374+
self.transformer_config.num_query_groups != self.transformer_config.num_attention_heads
1375+
and not is_te_min_version("1.13", check_equality=False)
1376+
and PkgVersion(os.getenv("CUDNN_VERSION", "9.5")) < PkgVersion("9.6")
1377+
):
1378+
# cu_seqlens_unpadded != cu_seqlens when CP=1 is not supported in TE 1.13 or earlier
1379+
# and im CUDNN 9.5 or earlier when using GQA.
1380+
cu_seqlens_unpadded = cu_seqlens
13701381
forward_args['packed_seq_params'] = PackedSeqParams(
13711382
cu_seqlens_q=cu_seqlens_unpadded,
13721383
cu_seqlens_kv=cu_seqlens_unpadded,

0 commit comments

Comments
 (0)