LLaVA-OneVision-2 icon indicating copy to clipboard operation
LLaVA-OneVision-2 copied to clipboard

[Bug] ImportError: flash_attn_varlen_func

Open Saekitost opened this issue 1 year ago • 1 comments

Environment

  • transformers: 4.57.0.dev0
  • flash-attn: 2.8.3
  • torch: 2.7.1+cu128
  • cuda: 12.8
  • model: lmms-lab/LLaVA-OneVision-1.5-8B-Instruct

Error

When I try to run inference with LLaVA-OneVision-1.5 (with or without explicitly enabling flash attention), the model fails during import: ImportError: cannot import name ‘flash_attn_varlen_func’ from ‘transformers.modeling_flash_attention_utils’

I manually commented out the usage of flash_attn_varlen_func in modeling_llavaonevision1_5.py and avoided using flash-attn. In this case the model can run inference normally. I tried flash-attn on Qwen2.5-VL and it works well, how to fix this?

Saekitost avatar Sep 30 '25 07:09 Saekitost

Two weeks in, and we’re still consistently seeing this gap across production traces. I’ve been exploring it with a ContextualPrecision metric, which is surfacing a recurring pattern: tool selection tends to perform well, while context interpretation is where things break down.

From a recent sample (50+ multi-step agent traces):

87% tool selection accuracy

64% correct interpretation of tool outputs

These silent failures seem to accumulate in ways that meaningfully impact outcomes.

The two-stage evaluation pattern you outlined feels like a strong fit for addressing this. I’d be glad to share anything helpful, including:

Raw traces that highlight the divergence

ContextualPrecision scoring breakdowns

Aggregated metrics comparing selection vs. interpretation errors

If this is something you’re considering for the roadmap, I’d be happy to collaborate and contribute data to help move it forward within HUD.

Ruthwik-Data avatar Apr 20 '26 17:04 Ruthwik-Data

Since there's been no reply, sharing a concrete implementation sketch to make this easier to scope as a PR. The idea is a ToolInterpretationEvaluator that wraps any existing HUD task evaluation with a second-stage score:

from dataclasses import dataclass
from typing import Any

@dataclass
class ToolEvalResult:
    task_id: str
    tool_selection_score: float   # Stage 1: correct tool called?
    tool_interpretation_score: float  # Stage 2: correct reasoning from output?
    combined_score: float
    failure_class: str  # 'selection_error' | 'interpretation_error' | 'none'


def classify_tool_failure(
    expected_tool: str,
    actual_tool: str,
    tool_output: dict[str, Any],
    agent_final_answer: str,
    ground_truth: str,
    llm_judge,  # callable: (prompt) -> float
) -> ToolEvalResult:
    selection_score = 1.0 if actual_tool == expected_tool else 0.0

    if selection_score == 0.0:
        return ToolEvalResult(
            task_id="",
            tool_selection_score=0.0,
            tool_interpretation_score=0.0,
            combined_score=0.0,
            failure_class="selection_error",
        )

    # Stage 2: did the agent correctly reason from the tool output?
    prompt = (
        f"Tool output: {tool_output}\n"
        f"Agent answer: {agent_final_answer}\n"
        f"Ground truth: {ground_truth}\n"
        f"Score 0-1: how well did the agent use the tool output to reach the correct answer?"
    )
    interpretation_score = llm_judge(prompt)

    failure_class = "none" if interpretation_score >= 0.7 else "interpretation_error"
    combined = (selection_score * 0.4) + (interpretation_score * 0.6)

    return ToolEvalResult(
        task_id="",
        tool_selection_score=selection_score,
        tool_interpretation_score=interpretation_score,
        combined_score=combined,
        failure_class=failure_class,
    )

This gives you the two-stage classification: selection_error vs interpretation_error, which maps cleanly to the aggregate metrics (87% selection accuracy vs 64% interpretation accuracy from my earlier data).

If the HUD team would find this useful as a built-in evaluator type, I'm happy to:

  1. Open a PR adding ToolInterpretationEvaluator as an eval class.
  2. Include a worked example (web scraping agent task with tool output interpretation).
  3. Add docs showing how to read the two-stage breakdown in traces.

What's the best path forward? Should I open a draft PR, or would you prefer a design doc first?

Ruthwik-Data avatar Jun 01 '26 12:06 Ruthwik-Data

Thanks for taking a look, @lorenss-m. Understood on the not-planned call — makes sense if this isn't the direction for HUD's eval surface right now.

For context: I ended up building the ToolInterpretationEvaluator as a standalone layer on top of HUD traces and it's been useful in my own agent testing workflow. Happy to share the implementation externally if it's ever useful as a reference or community contribution down the line.

Thanks again for the engagement on the earlier thread.

Ruthwik-Data avatar Jun 20 '26 16:06 Ruthwik-Data