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

[BUG]: TypeError: 'LazyTensor' object is not callable #4296

Closed
upwindflys opened this issue Jul 20, 2023 · 1 comment · Fixed by #4801
Closed

[BUG]: TypeError: 'LazyTensor' object is not callable #4296

upwindflys opened this issue Jul 20, 2023 · 1 comment · Fixed by #4801
Labels
bug Something isn't working

Comments

@upwindflys
Copy link

🐛 Describe the bug

Hi, I checkout to the branch example/llama,
and modify code from

 model = LlamaForCausalLM(config)

to

model = AutoModelForCausalLM.from_pretrained(
             "/home/llama_7B_hf",
              device_map = None,
              torch_dtype=torch.float16,
        )

run python colossalai run --nproc_per_node 1 --hostfile hostfile --master_addr 172.17.0.2 benchmark.py --plugin "gemini_cpu" -l 512 -g -b 6,
error occured.
Loading checkpoint shards: 0%| | 0/2 [00:09<?, ?it/s]
Traceback (most recent call last):
File "/home/Colosal/examples/language/llama/benchmark.py", line 206, in
main()
File "/home/Colosal/examples/language/llama/benchmark.py", line 146, in main
model = AutoModelForCausalLM.from_pretrained(
File "/opt/conda/lib/python3.9/site-packages/transformers/models/auto/auto_factory.py", line 493, in from_pretrained
return model_class.from_pretrained(
File "/opt/conda/lib/python3.9/site-packages/transformers/modeling_utils.py", line 2910, in from_pretrained
) = cls._load_pretrained_model(
File "/opt/conda/lib/python3.9/site-packages/transformers/modeling_utils.py", line 3267, in _load_pretrained_model
new_error_msgs, offload_index, state_dict_index = _load_state_dict_into_meta_model(
File "/opt/conda/lib/python3.9/site-packages/transformers/modeling_utils.py", line 719, in _load_state_dict_into_meta_model
set_module_tensor_to_device(model, param_name, param_device, **set_module_kwargs)
File "/opt/conda/lib/python3.9/site-packages/accelerate/utils/modeling.py", line 320, in set_module_tensor_to_device
new_value = param_cls(new_value, requires_grad=old_value.requires_grad).to(device)
File "/opt/conda/lib/python3.9/site-packages/colossalai/lazy/lazy_init.py", line 160, in new
elem = func(*args, **{**kwargs, 'device': 'meta'})
TypeError: 'LazyTensor' object is not callable

Environment

build from this repo, branch example/llama dockerfile.

@upwindflys upwindflys added the bug Something isn't working label Jul 20, 2023
@flybird11111
Copy link
Contributor

flybird11111 commented Aug 30, 2023

Please set low_cpu_mem_usage to False, lazyinit is not compatible with it. or delete ‘torch_dtype=torch.float16’

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants