Skip to content

Add option to construct Llama model with Transformer Engine op fuser - #13776

Merged
chtruong814 merged 3 commits into
NVIDIA-NeMo:mainfrom
timmoon10:mcore-with-te-ops
Jun 3, 2025
Merged

Add option to construct Llama model with Transformer Engine op fuser#13776
chtruong814 merged 3 commits into
NVIDIA-NeMo:mainfrom
timmoon10:mcore-with-te-ops

Conversation

@timmoon10

Copy link
Copy Markdown
Collaborator

What does this PR do ?

This PR exposes Megatron-core integration with Transformer Engine's operation fuser. This is an experimental feature.

Collection: NLP

Changelog

  • Expose Megatron-core integration with Transformer Engine's operation fuser.

Usage

from nemo.collections import llm
from nemo.collections.llm.gpt.model import LlamaModel

config = llm.Llama2Config70B(..., use_transformer_engine_op_fuser=True)
model = LlamaModel(config, ...)

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • This option requires a change that has not yet merged into Megatron-LM. However, old version of Megatron-LM will work as long as the option is not explicitly set.

Signed-off-by: Tim Moon <tmoon@nvidia.com>
"qk_layernorm": config.qk_layernorm,
"fp8": bool(config.num_moe_experts and (config.fp8 is not None)),
}
if getattr(config, "use_transformer_engine_op_fuser", None) is not None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hemildesai Is backward compatibility necessary here ? Can we just do config.use_transformer_engine_op_fuser

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative implementation that maintains backward compatibility and avoids the None option: https://github.com/timmoon10/NeMo/blob/5094732a45deeb5872ffd72c69ac9ccdb710460e/nemo/collections/llm/gpt/model/base.py#L162-L164

persist_layer_norm: bool = True
bias_dropout_fusion: bool = True
apply_rope_fusion: bool = True
use_transformer_engine_op_fuser: Optional[bool] = None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False seems more simpler ?

@ko3n1g ko3n1g added Run CICD and removed Run CICD labels Jun 2, 2025
@timmoon10
timmoon10 marked this pull request as ready for review June 2, 2025 17:32

@chtruong814 chtruong814 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failing test should be resolved after we increased the timeout on main. Going ahead to merge it.

@chtruong814
chtruong814 merged commit 85a5f6d into NVIDIA-NeMo:main Jun 3, 2025
@timmoon10
timmoon10 deleted the mcore-with-te-ops branch August 5, 2025 23:44
nasretdinovr pushed a commit to nasretdinovr/NeMo that referenced this pull request Aug 8, 2025
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Co-authored-by: Charlie Truong <chtruong@nvidia.com>
Co-authored-by: gautham-kollu <gkollu@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants