Remove the incompatible attribute `conv_pointwise_type` from the `model_config.yaml` file

#1
by bofenghuang - opened

Hi!

I've tried to load the model using the following code snippet

import nemo.collections.asr as nemo_asr
asr_model = nemo_asr.models.EncDecHybridRNNTCTCBPEModel.from_pretrained(model_name="nvidia/stt_fr_fastconformer_hybrid_large_pc")

However, I got the following error

File ~/asr/NeMo/nemo/collections/asr/models/rnnt_models.py:56, in EncDecRNNTModel.__init__(self, cfg, trainer)
     54 # Initialize components
     55 self.preprocessor = EncDecRNNTModel.from_config_dict(self.cfg.preprocessor)
---> 56 self.encoder = EncDecRNNTModel.from_config_dict(self.cfg.encoder)
     58 # Update config values required by components dynamically
     59 with open_dict(self.cfg.decoder):

File ~/asr/NeMo/nemo/core/classes/common.py:468, in Serialization.from_config_dict(cls, config, trainer)
    465 # Hydra 1.x API
    466 elif '_target_' in config and _HAS_HYDRA:
    467     # regular hydra-based instantiation
--> 468     instance = hydra.utils.instantiate(config=config)
    469 else:
    470     instance = None

File ~/anaconda3/envs/nemo/lib/python3.9/site-packages/hydra/_internal/instantiate/_instantiate2.py:226, in instantiate(config, *args, **kwargs)
    223     _convert_ = config.pop(_Keys.CONVERT, ConvertMode.NONE)
    224     _partial_ = config.pop(_Keys.PARTIAL, False)
--> 226     return instantiate_node(
    227         config, *args, recursive=_recursive_, convert=_convert_, partial=_partial_
    228     )
    229 elif OmegaConf.is_list(config):
    230     # Finalize config (convert targets to strings, merge with kwargs)
    231     config_copy = copy.deepcopy(config)

File ~/anaconda3/envs/nemo/lib/python3.9/site-packages/hydra/_internal/instantiate/_instantiate2.py:347, in instantiate_node(node, convert, recursive, partial, *args)
    342                 value = instantiate_node(
    343                     value, convert=convert, recursive=recursive
    344                 )
    345             kwargs[key] = _convert_node(value, convert)
--> 347     return _call_target(_target_, partial, args, kwargs, full_key)
    348 else:
    349     # If ALL or PARTIAL non structured or OBJECT non structured,
    350     # instantiate in dict and resolve interpolations eagerly.
    351     if convert == ConvertMode.ALL or (
    352         convert in (ConvertMode.PARTIAL, ConvertMode.OBJECT)
    353         and node._metadata.object_type in (None, dict)
    354     ):

File ~/anaconda3/envs/nemo/lib/python3.9/site-packages/hydra/_internal/instantiate/_instantiate2.py:97, in _call_target(_target_, _partial_, args, kwargs, full_key)
     95 if full_key:
     96     msg += f"\nfull_key: {full_key}"
---> 97 raise InstantiationException(msg) from e

InstantiationException: Error in call to target 'nemo.collections.asr.modules.conformer_encoder.ConformerEncoder':
TypeError("__init__() got an unexpected keyword argument 'conv_pointwise_type'")

It seems like the conv_pointwise_type attribute is not compatible with the current version which I've installed from the main branch.

I've removed the relevant attribute in model_config.yaml and then repacked to the .nemo file using

asr_model.save_to("stt_fr_fastconformer_hybrid_large_pc.nemo")

Then I can successfully load the model using

asr_model = nemo_asr.models.EncDecHybridRNNTCTCBPEModel.restore_from("stt_fr_fastconformer_hybrid_large_pc.nemo")

Finally, I would like to submit this PR to modify the online version, so that users can seamlessly load it from the Hugging Face Hub using from_pretrained function.

Thanks in advance!

Kindly ping @smajumdar94 for review :)

This is fantastic ! Thanks you for taking the effort to patch the model !

smajumdar94 changed pull request status to merged

Sign up or log in to comment