Skip to content

Conversation

@SangChengC
Copy link
Contributor

No description provided.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @SangChengC, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've focused on integrating FlashAttention v3 (FA3) support into the Qwen2-VL model within the LightLLM framework. The primary goal is to enable more efficient attention computations by allowing the model to leverage FA3 when it's activated via environment variables. This change aims to improve performance, especially for longer sequences, by optimizing how attention is handled.

Highlights

  • FlashAttention v3 Integration: I've implemented a mechanism to enable FlashAttention v3 for the Qwen2-VL model. This is achieved by dynamically setting the inference state class to "Qwen2VLFlashAttentionStateInfo" based on an environment variable, allowing for optimized attention computations.
  • Sequence Length Management: I've added explicit assignments for "max_seq_len" and "q_max_seq_len" during the prefill phase in the inference state. This change likely supports the specific requirements of FlashAttention for managing sequence lengths efficiently.
  • Code Clean-up: I've performed a minor formatting fix in the Triton kernel for mROPE by removing an unnecessary blank line.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for FlashAttention 3 to the qwen2_vl model. The changes are straightforward, primarily involving the conditional selection of an infer_state_class based on an environment variable and adding necessary attributes for FA3 to the inference state structure. The implementation appears correct and follows the existing patterns in the codebase. I have one suggestion to improve code quality by removing an unused import.

import torch
from PIL import Image
from .vision_process import smart_resize
from lightllm.utils.envs_utils import enable_env_vars, get_env_start_args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The function enable_env_vars is imported but not used within this file. To maintain code cleanliness and avoid potential confusion, it's best to remove unused imports.

Suggested change
from lightllm.utils.envs_utils import enable_env_vars, get_env_start_args
from lightllm.utils.envs_utils import get_env_start_args

@hiworldwzj hiworldwzj merged commit 250318a into main Jul 31, 2025
1 check passed
@hiworldwzj hiworldwzj deleted the fix_qwen2vl_fa3 branch July 31, 2025 13:00
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

Successfully merging this pull request may close these issues.

4 participants