Skip to content

Commit

Permalink
Fix attention mask inference (NVIDIA#7213)
Browse files Browse the repository at this point in the history
* Fix attention mask inference

Signed-off-by: Cheng-Ping Hsieh <[email protected]>

* Fix config

Signed-off-by: Cheng-Ping Hsieh <[email protected]>

---------

Signed-off-by: Cheng-Ping Hsieh <[email protected]>
  • Loading branch information
hsiehjackson authored and guyueh1 committed Aug 14, 2023
1 parent 63c45cf commit dede2b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ def main(cfg) -> None:
)

model.freeze()
if not cfg.model.get('use_flash_attention', False):
cfg.inference.compute_attention_mask = True
config = OmegaConf.to_container(cfg.inference, resolve=True)
model.set_inference_config(config)

Expand Down
2 changes: 2 additions & 0 deletions examples/nlp/language_modeling/tuning/megatron_gpt_sft.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def main(cfg) -> None:
model = load_from_checkpoint_dir(MegatronGPTSFTModel, cfg, trainer, modify_confg_fn=_modify_config)

if 'inference' in cfg:
if not cfg.model.use_flash_attention:
cfg.inference.compute_attention_mask = True
config = OmegaConf.to_container(cfg.inference, resolve=True)
model.set_inference_config(config)

Expand Down

0 comments on commit dede2b4

Please sign in to comment.