Skip to content

error when finetune gemma2-2b when Running Evaluation #853

Closed

Description

@zfflxx

File "torch/_dynamo/variables/constant.py", line 176, in call_method
return ConstantVariable.create(op(self.value, add_target))
torch._dynamo.exc.InternalTorchDynamoError: 'bool' object is not subscriptable

from user code:
File "unsloth/kernels/flex_attention.py", line 73, in slow_attention_softcapping
A += causal_mask[:q_len, :q_len]

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information

Activity

  1. zfflxx commented on Aug 1, 2024

    @zfflxx
    Author

    I check my flash_attn=2.6.3, I got this error when Running Evaluation

  2. changed the title [-]error when finetune gemma2-2b without HAS_FLASH_ATTENTION_SOFTCAPPING[/-] [+]error when finetune gemma2-2b when Running Evaluation[/+] on Aug 1, 2024
  3. danielhanchen commented on Aug 2, 2024

    @danielhanchen
    Member

    Oh try uninstalling Unsloth and reinstalling (hopefully that'll fix it!)

  4. Simplegram commented on Aug 7, 2024

    @Simplegram

    I have this issue as well when using DPOTrainer with unsloth/gemma-2-9b-it-bnb-4bit. I have reinstalled Unsloth along with all dependencies.

  5. danielhanchen commented on Aug 10, 2024

    @danielhanchen
    Member

    Will check again apologies!

  6. added
    fixed - pending confirmation
    and removed
    currently fixing
    on Aug 12, 2024
  7. danielhanchen commented on Aug 12, 2024

    @danielhanchen
    Member

    I think I fixed it!

  8. Simplegram commented on Aug 12, 2024

    @Simplegram

    Hello. After completely reinstalling everything with the latest commit, I can confirm that the error no longer occurs. Interestingly, this also resolved a non-breaking issue I had where the state of each step was missing during training (the dataframe-like state report after each step). Thank you for such an instant fix!

    Now my only problem is that I can't test the model evaluation due to CUDA Out of Memory (OOM) errors. I have tried both unsloth/gemma-2-2b-bnb-4bit and unsloth/gemma-2-9b-it-bnb-4bit. I'm on Windows with WSL, running the code with ipynb in VS Code, and my GPU is an RTX 4090. Do you any suggestions I can try?

    Thanks

  9. Simplegram commented on Aug 12, 2024

    @Simplegram

    Hello. After completely reinstalling everything with the latest commit, I can confirm that the error no longer occurs. Interestingly, this also resolved a non-breaking issue I had where the state of each step was missing during training (the dataframe-like state report after each step). Thank you for such an instant fix!

    Now my only problem is that I can't test the model evaluation due to CUDA Out of Memory (OOM) errors. I have tried both unsloth/gemma-2-2b-bnb-4bit and unsloth/gemma-2-9b-it-bnb-4bit. I'm on Windows with WSL, running the code with ipynb in VS Code, and my GPU is an RTX 4090. Do you any suggestions I can try?

    Thanks

    I just realized there's a per_device_eval_batch_size parameter. After setting it to 1, I no longer encountered OOM errors. Model evaluation ran smoothly until the end of training.

  10. danielhanchen commented on Aug 13, 2024

    @danielhanchen
    Member

    Oh great you solved it :)

  11. gsarti commented on Aug 13, 2024

    @gsarti

    I still receive the same error when installing from source with pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git". I'm on Python 3.10, using torch==2.3, xformers<0.0.27, trl<0.9.0 using the Gemma 2b fine-tuning demo notebook.

    EDIT: Getting the same error after updating to xformers 0.0.27.post2, torch==2.5.0:

    Failed running call_function <built-in function iadd>(*(FakeTensor(..., device='cuda:0', size=(s10, s2*s3, s19, s11),
               dtype=torch.bfloat16, grad_fn=<MulBackward0>), FakeTensor(..., device='cuda:0', size=(s20, 1, s21, s22), dtype=torch.bfloat16)), **{}):
    Attempting to broadcast a dimension of length s22 at -1! Mismatching argument at index 1 had torch.Size([s20, 1, s21, s22]); but expected shape should be broadcastable to [s10, s2*s3, s19, s11]
    
    from user code:
       File "/opt/conda/lib/python3.10/site-packages/unsloth/kernels/flex_attention.py", line 73, in slow_attention_softcapping
        A += causal_mask[:q_len, :q_len]
    
    Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information
    
  12. ivsanro1 commented on Aug 19, 2024

    @ivsanro1

    Having this problem as well.

    Interestingly enough, it happens arbitrarily with some sample once in evaluation

    edit: Seems to happen with gemma 9b as well

  13. kimseungju-00 commented on Aug 21, 2024

    @kimseungju-00

    I am experiencing the same error. I am using the 'unsloth/gemma-2-9b-it-bnb-4bit' model with CUDA 11.8 and Torch 2.2.0. For Unsloth, I used the following installation command:

    pip install "unsloth[cu118-ampere-torch220] @ git+https://github.com/unslothai/unsloth.git"

    The error I am encountering is:

    torch._dynamo.exc.TorchRuntimeError: Failed running call_function ((FakeTensor(..., device='cuda:0', size=(1, s2s3, s10, s10), dtype=torch.bfloat16), FakeTensor(..., device='cuda:0', size=(s9, 1, s10, s10), dtype=torch.bfloat16)), **{}):
    output with shape torch.Size([1, s2s3, s10, s10]) doesn't match the broadcast shape (s9, s2s3, s10, s10)

    from user code:
    File "/home/ksj/.pyenv/versions/3.11.8/lib/python3.11/site-packages/unsloth/kernels/flex_attention.py", line 73, in slow_attention_softcapping
    A += causal_mask[:q_len, :q_len]

    If anyone has encountered and resolved this issue, I would greatly appreciate it if you could share how you resolved it.

  14. 25 remaining items

  15. added 2 commits that reference this issue on Dec 5, 2024
    9bc2609
    3464b35
  16. added 3 commits that reference this issue on Dec 20, 2024
    135c25a
    a240783
    4fbbd7e
  17. added 10 commits that reference this issue on May 14, 2026
    786aea6
    ddf118a
    67fd43f
    e7edb9b
    35ca26c
    a0377c5
    0e0d8fc
    6bf5d8d
    a20b380
    160ff80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed - pending confirmation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions