Skip to content

[FIXED] attention_mask = attention_mask.to(torch.bool) #1704

Closed

Description

@torahoang

Been trying to fine tune Meta-Llama-3.1-8B model, all goes well until it can't generate outputs. Some thing is wrong with the attention_mask and idk why. I also can't generate text in the original notebook for Llama3-8B. Anyone have any idea?

Image

Activity

  1. Marekoro commented on Feb 14, 2025

    @Marekoro

    File "/usr/local/lib/python3.11/dist-packages/unsloth/models/llama.py", line 727, in LlamaModel_fast_forward
    attention_mask = attention_mask.to(torch.bool)
    ^^^^^^^^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'to'

    same problem using qwen2.5 models

  2. SunVictor23 commented on Feb 14, 2025

    @SunVictor23

    I also have the same question!

  3. torahoang commented on Feb 14, 2025

    @torahoang
    Author

    unsloth/llama-3-8b-bnb-4bit also have the same problem with inference

  4. kkailaasa commented on Feb 14, 2025

    @kkailaasa

    Facing same issue, I think it is happening after #1699 was patched. This issue was also raised here #issuecomment-2658058664

  5. danielhanchen commented on Feb 14, 2025

    @danielhanchen
    Member

    Working on a fix as we speak - apologies on the issues!

  6. danielhanchen commented on Feb 14, 2025

    @danielhanchen
    Member

    Ok fixed - apologies - all Colab / Kaggle instances will need a refresh.

    For fresh installs, pip install unsloth will work. Updating for local machines: pip install --upgrade --force-reinstall --no-deps unsloth

  7. added
    fixed - pending confirmation
    and removed
    currently fixing
    URGENT BUG
    on Feb 14, 2025
  8. changed the title [-]attention_mask = attention_mask.to(torch.bool) error[/-] [+][FIXED] `attention_mask = attention_mask.to(torch.bool)`[/+] on Feb 14, 2025
  9. kkailaasa commented on Feb 14, 2025

    @kkailaasa

    @danielhanchen Thank you so much, testing it out now

  10. unpinned this issue on Mar 4, 2025
  11. danielhanchen commented on Jun 18, 2026

    @danielhanchen
    Member

    This should be fixed now - sorry on the delay - please update with uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir - if it's not fixed yet, it'll be in the next pip / PyPI release - if it's still not working after that, please open another issue - appreciate it again!

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