dmlc / gluon-nlp

NLP made easy
https://nlp.gluon.ai/
Apache License 2.0
2.56k stars 538 forks source link

XLMR Conversion fails on parameter dictionary KeyError #1570

Closed davisliang closed 3 years ago

davisliang commented 3 years ago

Description

When running the script convert_xlmr.sh we encounter an error in the final conversion step referencing a key error.

Error Message

Traceback (most recent call last): File "convert_fairseq_xlmr.py", line 120, in <module> convert_fairseq_model(args) File "convert_fairseq_xlmr.py", line 99, in convert_fairseq_model ctx) File "/home/ubuntu/gluon-nlp/scripts/conversion_toolkits/convert_fairseq_roberta.py", line 230, in convert_params fairseq_params[fs_name].cpu().numpy()) KeyError: 'model.encoder.sentence_encoder.emb_layer_norm.weight'

To Reproduce

Install the following packages and run the conversion script gluonnlp 1.0.0.dev20210513 mxnet-cu110 2.0.0a0 torch 1.8.1 fairseq 1.0.0a0+d151f27

Steps to reproduce

(Paste the commands you ran that produced the error.)

  1. Install packages above.
  2. cd /path/to/gluon-nlp/scripts/conversion_toolkits
  3. bash convert_xlmr.sh

What have you tried to solve it?

  1. Tried various instance types (p3, p4 the latter runs into compute_80 not supported issues)

Environment

We recommend using our script for collecting the diagnositc information. Run the following command and paste the outputs below:

curl --retry 10 -s https://raw.githubusercontent.com/dmlc/gluon-nlp/master/tools/diagnose.py | python

# paste outputs here
sxjscience commented 3 years ago

Thanks for reporting the error, the fix is tracked in https://github.com/dmlc/gluon-nlp/pull/1572

sxjscience commented 3 years ago

@davisliang Would you try the latest master again? It should have been fixed.

davisliang commented 3 years ago

I tried the latest master branch and can verify the fix works and the conversion script runs successfully. Thank you for the help!