Skip to content
Closed
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
14 changes: 13 additions & 1 deletion examples/eagle/convert_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ def copy(tensors):
args.n_positions = hf_config.max_position_embeddings
args.dtype = str(
hf_config.torch_dtype)[6:] if args.dtype == 'auto' else args.dtype
args.head_dim = hf_config.head_dim
args.head_size = args.head_dim

if args.eagle_model_dir is None:
hf_config_eagle = hf_config.eagle
Expand All @@ -305,6 +307,12 @@ def copy(tensors):
args.n_kv_head_eagle = hf_config_eagle['num_key_value_heads']
args.rms_norm_eps_eagle = hf_config_eagle['rms_norm_eps']
args.n_positions_eagle = hf_config_eagle['max_position_embeddings']
if 'head_dim' in hf_config_eagle:
args.head_dim_eagle = hf_config_eagle['head_dim']
else:
args.head_dim_eagle = args.n_embd_eagle // args.n_head_eagle

args.head_size_eagle = args.head_dim_eagle
else:
hf_config_eagle = LlamaConfig.from_pretrained(args.eagle_model_dir)
args.n_head_eagle = hf_config_eagle.num_attention_heads
Expand Down Expand Up @@ -370,6 +378,8 @@ def copy(tensors):
},
'use_parallel_embedding': args.use_parallel_embedding,
'embedding_sharding_dim': args.embedding_sharding_dim,
'head_dim': args.head_dim_eagle,
'head_size': args.head_size_eagle
}

config = {
Expand Down Expand Up @@ -402,7 +412,9 @@ def copy(tensors):
'max_draft_len': args.max_draft_len,
'num_eagle_layers': args.num_eagle_layers,
'max_non_leaves_per_layer': args.max_non_leaves_per_layer,
'eagle_net_config': eagle_net_config
'eagle_net_config': eagle_net_config,
'head_dim': args.head_dim,
'head_size': args.head_size
}

assert args.max_draft_len <= 256, "args.max_draft_len > 256 is not supported"
Expand Down
4 changes: 4 additions & 0 deletions tensorrt_llm/models/eagle/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def from_hugging_face(
n_positions = hf_config.max_position_embeddings
hidden_act = hf_config.hidden_act
dtype = str(hf_config.torch_dtype)[6:] if dtype == 'auto' else dtype
head_dim = hf_config.head_dim
head_size = hf_config.head_size

if speculative_config_or_dir is None:
hf_config_eagle = hf_config.eagle
Expand Down Expand Up @@ -143,6 +145,8 @@ def from_hugging_face(
},
'use_parallel_embedding': kwargs['use_parallel_embedding'],
'embedding_sharding_dim': kwargs['embedding_sharding_dim'],
'head_dim': head_dim,
'head_size': head_size
}

config = {
Expand Down