Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dictionary update length error #126

Closed
SzaboGergo01 opened this issue Mar 23, 2023 · 2 comments · Fixed by #129
Closed

Dictionary update length error #126

SzaboGergo01 opened this issue Mar 23, 2023 · 2 comments · Fixed by #129
Labels
feat/model Feature: models

Comments

@SzaboGergo01
Copy link

I tried the quantization in our own project and got this error:

We have 3 separated config, one tagger, one parser and one ner. After that we use an assemble step to merge these together. And I tried to quantize this assembled model and got that error.
config files: https://gist.github.com/SzaboGergo01/5ca9abeaaf199a686d8b41335e9fe261

Running command: /home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/bin/python -m spacy quantize-transformer --max-mse-loss 0.000003 models/hu_core_news_trf_xl-3.5.0 models/hu_core_news_trf_xl-3.5.0-quantized
Traceback (most recent call last):
  File "/home/a100/anaconda3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/a100/anaconda3/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/spacy/__main__.py", line 4, in <module>
    setup_cli()
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/spacy/cli/_util.py", line 74, in setup_cli
    command(prog_name=COMMAND)
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/typer/main.py", line 497, in wrapper
    return callback(**use_params)  # type: ignore
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/curated_transformers/cli/quantize.py", line 43, in quantize_cli
    nlp_quantize_dynamic(
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/curated_transformers/cli/quantize.py", line 75, in nlp_quantize_dynamic
    quantize_dynamic(
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/curated_transformers/cli/quantize.py", line 108, in quantize_dynamic
    quantized_model = torch.quantization.quantize_dynamic(
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/torch/ao/quantization/quantize.py", line 447, in quantize_dynamic
    model = copy.deepcopy(model)
  File "/home/a100/anaconda3/lib/python3.8/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/a100/anaconda3/lib/python3.8/copy.py", line 272, in _reconstruct
    y.__setstate__(state)
  File "/home/a100/gszabo/roberta/hu_core_news_trf_xl/.venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1237, in __setstate__
    self.__dict__.update(state)
ValueError: dictionary update sequence element #0 has length 12; 2 is required

My spacy environment:

## Info about spaCy

- **spaCy version:** 3.5.1
- **Platform:** Linux-5.4.0-136-generic-x86_64-with-glibc2.10
- **Python version:** 3.8.5

In principle the torch.quantization.quantize_dynamic() function is the source of the error. Have you ever encountered something similar or do you know a solution to this?

@danieldk
Copy link
Collaborator

Thanks for reporting! I haven't encountered this error yet. We'll look into it.

@danieldk
Copy link
Collaborator

I can reproduce an issue and have made a PR with fixes (and tests, so that we don't have such a regression again):

#129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat/model Feature: models
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants