Closed plvckn closed 1 year ago
UPDATE
fixed last error by using a different version of a package: optimum-intel-1.7.0.dev0
however, running same code sample now returns a different error:
KeyError Traceback (most recent call last)
<ipython-input-1-47896b3f0ea0> in <module>
1 from optimum.intel.neural_compressor.quantization import INCModelForSeq2SeqLM
----> 2 int8_model = INCModelForSeq2SeqLM.from_pretrained(
3 'Intel/distilbart-cnn-12-6-int8-dynamic',
4 )
~/anaconda3/envs/nlp/lib/python3.9/site-packages/optimum/intel/neural_compressor/quantization.py in from_pretrained(cls, model_name_or_path, q_model_name, **kwargs)
551
552 if "best_configure" in state_dict and state_dict["best_configure"] is not None:
--> 553 model = load(state_dict_path, model)
554
555 return model.eval()
~/anaconda3/envs/nlp/lib/python3.9/site-packages/neural_compressor/utils/pytorch.py in load(checkpoint_dir, model, history_cfg, **kwargs)
370 _set_activation_scale_zeropoint(q_model, history_cfg)
371 else:
--> 372 q_model.load_state_dict(stat_dict)
373 util.get_embedding_contiguous(q_model)
374 return q_model
~/anaconda3/envs/nlp/lib/python3.9/site-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict)
1655 )
1656
-> 1657 load(self, state_dict)
1658 del load
1659
~/anaconda3/envs/nlp/lib/python3.9/site-packages/torch/nn/modules/module.py in load(module, local_state_dict, prefix)
1643 child_prefix = prefix + name + '.'
1644 child_state_dict = {k: v for k, v in local_state_dict.items() if k.startswith(child_prefix)}
-> 1645 load(child, child_state_dict, child_prefix)
1646
1647 # Note that the hook can modify missing_keys and unexpected_keys.
~/anaconda3/envs/nlp/lib/python3.9/site-packages/torch/nn/modules/module.py in load(module, local_state_dict, prefix)
1643 child_prefix = prefix + name + '.'
1644 child_state_dict = {k: v for k, v in local_state_dict.items() if k.startswith(child_prefix)}
-> 1645 load(child, child_state_dict, child_prefix)
1646
1647 # Note that the hook can modify missing_keys and unexpected_keys.
~/anaconda3/envs/nlp/lib/python3.9/site-packages/torch/nn/modules/module.py in load(module, local_state_dict, prefix)
1643 child_prefix = prefix + name + '.'
1644 child_state_dict = {k: v for k, v in local_state_dict.items() if k.startswith(child_prefix)}
-> 1645 load(child, child_state_dict, child_prefix)
1646
1647 # Note that the hook can modify missing_keys and unexpected_keys.
~/anaconda3/envs/nlp/lib/python3.9/site-packages/torch/nn/modules/module.py in load(module, local_state_dict, prefix)
1637 def load(module, local_state_dict, prefix=''):
1638 local_metadata = {} if metadata is None else metadata.get(prefix[:-1], {})
-> 1639 module._load_from_state_dict(
1640 local_state_dict, prefix, local_metadata, True, missing_keys, unexpected_keys, error_msgs)
1641 for name, child in module._modules.items():
~/anaconda3/envs/nlp/lib/python3.9/site-packages/torch/ao/nn/quantized/modules/embedding_ops.py in _load_from_state_dict(self, state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs)
55 def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict,
56 missing_keys, unexpected_keys, error_msgs):
---> 57 self.dtype = state_dict[prefix + 'dtype']
58 state_dict.pop(prefix + 'dtype')
59
KeyError: 'model.shared._packed_params.dtype'
Hi, @plvckn I checked it and the root cause it's that transformers disabled sharing embedding, please try transformers <= v4.23.0. Thanks, I will add a note in the model card later.
Downgrading to transformers v4.23 has solved this issue, thanks @xin3he
Steps to reproduce: run code sample from https://huggingface.co/Intel/distilbart-cnn-12-6-int8-dynamic
Error message:
My environment:
My cpu