Skip to content

Commit 768a27b

Browse files
authored
[bugfix] fix embedding seq_cls (#147)
1 parent 38316cf commit 768a27b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/mcore_bridge/bridge/gpt_bridge.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,9 @@ def _set_state_dict(self,
507507
if to_mcore:
508508
assert mg_param is not None, f'mg_module: {mg_module}, mg_key: {mg_key}'
509509
hf_weight = hf_state_dict[hf_key].load()
510-
if module_key in {
511-
'embedding.word_embeddings', 'output_layer'
512-
} and hf_weight.shape[0] < self.config.padded_vocab_size and self.config.task_type != 'seq_cls':
510+
if hf_weight.shape[0] < self.config.padded_vocab_size and (module_key == 'embedding.word_embeddings'
511+
or module_key == 'output_layer'
512+
and self.config.task_type != 'seq_cls'):
513513
hf_weight = F.pad(hf_weight, (0, 0, 0, self.config.padded_vocab_size - hf_weight.shape[0]))
514514
hf_scale_inv = None
515515
if f'{hf_key}_scale_inv' in hf_state_dict:

0 commit comments

Comments
 (0)