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

do_sample is True, nan appears in "eager" mode #14

Open
sunyanguomt opened this issue Nov 21, 2024 · 2 comments
Open

do_sample is True, nan appears in "eager" mode #14

sunyanguomt opened this issue Nov 21, 2024 · 2 comments

Comments

@sunyanguomt
Copy link

HI
When i run demp.py, in attn_implementation="eager", the following problem occurs。

Traceback (most recent call last):
File "demo.py", line 44, in
output_ids = model.generate(input_ids, images=[video_tensor], modalities=["video"],beacon_skip_first=beacon_skip_first,beacon_skip_last=beacon_skip_last, **gen_kwargs)
File "/opt/conda/envs/py38/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/opt/conda/envs/py38/lib/python3.8/site-packages/videoxl/model/language_model/llava_qwen.py", line 1830, in generate
return super().generate(position_ids=position_ids, attention_mask=attention_mask,inputs=inputs,beacon_skip_first=beacon_skip_first, beacon_skip_last= beacon_skip_last, **kwargs)
File "/opt/conda/envs/py38/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/opt/conda/envs/py38/lib/python3.8/site-packages/transformers/generation/utils.py", line 2024, in generate
result = self._sample(
File "/opt/conda/envs/py38/lib/python3.8/site-packages/transformers/generation/utils.py", line 3020, in _sample
next_tokens = torch.multinomial(probs.to("cpu"), num_samples=1).squeeze(1).to("musa")
RuntimeError: probability tensor contains either inf, nan or element < 0

image

Then I found him in this position,this softmax apperas nan

image

This problem does not occur when using “sdpa” mode

@shuyansy
Copy link
Collaborator

In my implementation, the model is running with "flash-attention" mode. It may not work in other modes

@ApolloRay
Copy link

HI When i run demp.py, in attn_implementation="eager", the following problem occurs。

Traceback (most recent call last): File "demo.py", line 44, in output_ids = model.generate(input_ids, images=[video_tensor], modalities=["video"],beacon_skip_first=beacon_skip_first,beacon_skip_last=beacon_skip_last, **gen_kwargs) File "/opt/conda/envs/py38/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/opt/conda/envs/py38/lib/python3.8/site-packages/videoxl/model/language_model/llava_qwen.py", line 1830, in generate return super().generate(position_ids=position_ids, attention_mask=attention_mask,inputs=inputs,beacon_skip_first=beacon_skip_first, beacon_skip_last= beacon_skip_last, **kwargs) File "/opt/conda/envs/py38/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/opt/conda/envs/py38/lib/python3.8/site-packages/transformers/generation/utils.py", line 2024, in generate result = self._sample( File "/opt/conda/envs/py38/lib/python3.8/site-packages/transformers/generation/utils.py", line 3020, in _sample next_tokens = torch.multinomial(probs.to("cpu"), num_samples=1).squeeze(1).to("musa") RuntimeError: probability tensor contains either inf, nan or element < 0

image

Then I found him in this position,this softmax apperas nan

image

This problem does not occur when using “sdpa” mode

where can i change the flash-implementation?
same problem

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

No branches or pull requests

3 participants