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

Interactive generation script #53

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

younesbelkada
Copy link
Contributor

@younesbelkada younesbelkada commented Jul 8, 2022

Add small arguments that are accepted by accelerate for better performance
in the previous script we were offloading to the disk which takes a lot of time

cc @Muennighoff

@Muennighoff
Copy link
Collaborator

I can't find any documentation on max_cpu_memory - Does this kwarg exist?

Traceback (most recent call last):
  File "generate.py", line 64, in <module>
    main()
  File "generate.py", line 41, in main
    model = AutoModelForCausalLM.from_pretrained(
  File "/gpfswork/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages/transformers/models/auto/auto_factory.py", line 446, in from_pretrained
    return model_class.from_pretrained(pretrained_model_name_or_path, *model_args, config=config, **kwargs)
  File "/gpfswork/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2070, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
TypeError: __init__() got an unexpected keyword argument 'max_cpu_memory'
bash-4.4$ pip show accelerate
Name: accelerate
Version: 0.11.0.dev0
Summary: Accelerate
Home-page: https://github.com/huggingface/accelerate
Author: The HuggingFace team
Author-email: [email protected]
License: Apache
Location: /gpfsssd/worksf/projects/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages
Requires: psutil, torch, packaging, pyyaml, numpy
Required-by:
bash-4.4$ pip show transformers
Name: transformers
Version: 4.21.0.dev0
Summary: State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow
Home-page: https://github.com/huggingface/transformers
Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/transformers/graphs/contributors)
Author-email: [email protected]

@Muennighoff
Copy link
Collaborator

Also I'm pretty sure max_memory cannot be a string, but has to be a dictionary

@Muennighoff
Copy link
Collaborator

Just writing one line and CTRL+C (w/o Enter) yields the below for me. I think there is some batching issue.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "generate.py", line 64, in <module>
    main()
  File "generate.py", line 59, in main
    output = generate_from_text(model, text, tokenizer, max_length=args.generate_max_length, greedy=args.greedy, top_k=args.top_k)
  File "generate.py", line 25, in generate_from_text
    greedy_output = model.generate(
  File "/gpfswork/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/gpfswork/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages/transformers/generation_utils.py", line 1288, in generate
    return self.greedy_search(
  File "/gpfswork/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages/transformers/generation_utils.py", line 1683, in greedy_search
    outputs = self(
  File "/gpfswork/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/gpfswork/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages/accelerate/hooks.py", line 148, in new_forward
    output = old_forward(*args, **kwargs)
  File "/gpfswork/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages/transformers/models/bloom/modeling_bloom.py", line 821, in forward
    transformer_outputs = self.transformer(
  File "/gpfswork/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/gpfswork/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages/accelerate/hooks.py", line 148, in new_forward
    output = old_forward(*args, **kwargs)
  File "/gpfswork/rech/six/commun/conda/muennighoffmodelconv/lib/python3.8/site-packages/transformers/models/bloom/modeling_bloom.py", line 639, in forward
    input_ids = input_ids.view(-1, input_shape[-1])
RuntimeError: cannot reshape tensor of 0 elements into shape [-1, 0] because the unspecified dimension size -1 can be any value and is ambiguous

@Muennighoff
Copy link
Collaborator

Opened a PR with some changes: younesbelkada#1

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

Successfully merging this pull request may close these issues.

2 participants