Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(export): GPT models w/ bias=False convert properly #11255

Merged
merged 2 commits into from
Nov 12, 2024
Merged
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
8 changes: 8 additions & 0 deletions nemo/export/trt_llm/tensorrt_llm_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ def build_and_save_engine(
build_config.lora_config = lora_config

model = model_cls.from_config(model_config)
if not model_config.bias and model_config.architecture == 'GPTForCausalLM':
# NOTE: GPT models in megatron-core that set bias=False sets the bias false globally
# whereas bias=False in TRTLLM GPT models sets it false everywhere except
# LayerNorm. This change makes TRTLLM's implementation match megatron-core.
for name, module in model.named_modules():
if isinstance(module, tensorrt_llm.layers.normalization.LayerNorm):
module.bias = None
module.register_parameter('bias', None)
model = optimize_model(
model,
use_parallel_embedding=model_config.use_parallel_embedding,
Expand Down
Loading