simonw / simonw/til

Janus flash-attention issues solution

Open
#99 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
1.5k
Forks
120
PR merge metrics
No merged PRs in 30d

Description

As I was trying to run deepseek-ai's Janus on a Colab notebook, I encountered some flash-attention errors, including the one you mentioned in installing-flash-attention.md:

NameError: name '_flash_supports_window_size' is not defined

I couldn't resolve this specific error but managed to get it working by disabling flash-attention entirely for this model.

Fortunately, some guys at Xenova had already addressed this and uploaded a PR to Janus's Hugging Face Hub repository. You can use it by specifying the revision refs/pr/7 when downloading the pretrained model. For example:

import torch
from transformers import AutoModelForCausalLM
from janus.models import MultiModalityCausalLM, VLChatProcessor
from janus.utils.io import load_pil_images

# specify the path to the model
revision_id = "refs/pr/7"
model_path = "deepseek-ai/Janus-1.3B"
vl_chat_processor: VLChatProcessor = VLChatProcessor.from_pretrained(model_path)
tokenizer = vl_chat_processor.tokenizer

vl_gpt: MultiModalityCausalLM = AutoModelForCausalLM.from_pretrained(
    model_path, trust_remote_code=True, revision=revision_id
)
vl_gpt = vl_gpt.to(torch.bfloat16).cuda().eval()

I just tried it with the official Janus Colab demo, and it worked like a charm! I thought you might appreciate this.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review installing-flash-attention.md and the official Janus_colab_demo.ipynb, then compare the reported flash-attention error with the refs/pr/7 model revision described here. Done would be a clear TIL entry or update documenting the verified workaround and the affected Janus setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
huggingface, python, pytorch
Domain
documentation, machine-learning
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.