Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Can't run T5 agent on latest transformers #4148

Closed
zhangmozhi opened this issue Nov 7, 2021 · 1 comment
Closed

Can't run T5 agent on latest transformers #4148

zhangmozhi opened this issue Nov 7, 2021 · 1 comment
Assignees

Comments

@zhangmozhi
Copy link
Contributor

Bug description
When training T5 model with Transformer version 4.10+, ParlAI will throw a runtime error Must use transformers package >= 4.3 to use t5.

Reproduction steps
Install the latest Transformer and run any T5 training command. For example:
parlai train_model -m hugging_face/t5 -mf $HOME/project/model/t5_test -t convai2 -bs 24 --fp16 true -eps 1 -lr 1e-5 --optimizer adam --t5-model-arch t5-3b --t5-model-parallel true

Expected behavior
There should be no runtime error.

Logs

Traceback (most recent call last):
  File "/home/mozhi/miniconda3/bin/parlai", line 33, in <module>
    sys.exit(load_entry_point('parlai', 'console_scripts', 'parlai')())
  File "/mnt/mozhi/ParlAI/parlai/__main__.py", line 14, in main
    superscript_main()
  File "/mnt/mozhi/ParlAI/parlai/core/script.py", line 325, in superscript_main
    return SCRIPT_REGISTRY[cmd].klass._run_from_parser_and_opt(opt, parser)
  File "/mnt/mozhi/ParlAI/parlai/core/script.py", line 108, in _run_from_parser_and_opt
    return script.run()
  File "/mnt/mozhi/ParlAI/parlai/scripts/train_model.py", line 997, in run
    self.train_loop = TrainLoop(self.opt)
  File "/mnt/mozhi/ParlAI/parlai/scripts/train_model.py", line 353, in __init__
    self.agent = create_agent(opt)
  File "/mnt/mozhi/ParlAI/parlai/core/agents.py", line 479, in create_agent
    model = model_class(opt)
  File "/mnt/mozhi/ParlAI/parlai/core/torch_generator_agent.py", line 484, in __init__
    self.model = fsdp_utils.fsdp_wrap(self.build_model())
  File "/mnt/mozhi/ParlAI/parlai/agents/hugging_face/t5.py", line 105, in build_model
    model = ParlaiT5Model(self.opt, self.dict)
  File "/mnt/mozhi/ParlAI/parlai/agents/hugging_face/t5.py", line 285, in __init__
    self.t5 = build_t5(opt)
  File "/mnt/mozhi/ParlAI/parlai/agents/hugging_face/t5.py", line 34, in build_t5
    raise RuntimeError('Must use transformers package >= 4.3 to use t5')
RuntimeError: Must use transformers package >= 4.3 to use t5

Additional context
The build_t5 method in parlai/agents/hugging_face/t5.py compares HF versions as floating numbers, which causes this error. This should be an easy fix.

@klshuster
Copy link
Contributor

Thanks for flagging, fix is up in #4164

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants