Skip to content

[LLM:Bugfix] Refresh PLE for successive Omni text requests - #4894

Merged
wangzhaode merged 2 commits into
alibaba:masterfrom
ZedingZhang:feature/omni-ple-refresh
Sep 20, 2026
Merged

wangzhaode merged 2 commits into
alibaba:masterfrom
ZedingZhang:feature/omni-ple-refresh

Conversation

@ZedingZhang

@ZedingZhang ZedingZhang commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #4890.

Gemma 4 Omni instances can retain the one-token PLE input produced by the final decode step. A later multi-token text prefill then sees a non-null mPleInput, so Llm::embedding() keeps the stale tensor instead of rebuilding PLE for the new request.

This change:

  • clears mPleInput before a multi-token prefill only when Omni is on the text-only path and PLE is enabled; and
  • leaves the multimodal path unchanged so its full-input precomputed PLE is preserved.

Module

LLM / Omni (Gemma 4 PLE)

Type

  • Feature
  • Bugfix
  • Perf
  • Refact
  • Style
  • Doc
  • Test
  • Chore

Testing

  • Validated with a temporary test_omni_ple_lifecycle executable built using MNN_LLM_BUILD_TEST=ON; the test source and CMake target were removed per maintainer review.
  • Negative control: after reverting only the fix, the temporary test fails with Text prefill reused the stale one-token PLE input.
  • Fixed implementation: the same test passes and observes the PLE sequence length changing from 1 to 3.
  • A/B CI run: https://github.com/ZedingZhang/MNN/actions/runs/35440540720
  • Fork platform CI passed on Android, iOS, Linux, macOS, and Windows.

Checklist

  • Commit message follows [Module:Type] Description format
  • Code compiles without errors
  • Tested on relevant platform(s)
  • No unrelated format or style changes included

@wangzhaode wangzhaode self-assigned this Sep 20, 2026
@wangzhaode wangzhaode added module:llm LLM 推理相关 type:bug 功能缺陷 labels Sep 20, 2026
@wangzhaode

Copy link
Copy Markdown
Collaborator

Thanks for the focused PLE lifecycle fix and the A/B validation!

As with #4888, please remove transformers/llm/engine/test/test_omni_ple_lifecycle.cpp and its corresponding executable, include-directory, and link entries in transformers/llm/engine/CMakeLists.txt. This test covers a very narrow scenario, and we would prefer not to retain a separate test executable for it. The validation already documented in the PR is sufficient for this change; there is no need to move or expand the test.

Please keep the core PLE refresh fix in Omni::embedding() unchanged. Thanks again!

@wangzhaode wangzhaode added the awaiting contributor Waiting for contributor to address review comments or rebase label Sep 20, 2026
@ZedingZhang

Copy link
Copy Markdown
Contributor Author

I’ve removed test_omni_ple_lifecycle.cpp and its corresponding executable, include-directory, and link entries from transformers/llm/engine/CMakeLists.txt. No replacement test was added.

The core PLE refresh fix in Omni::embedding() remains unchanged. I updated the PR description to clarify that the temporary test was used only for A/B validation and is no longer part of the change. The PR now contains only the core omni.cpp fix. Thanks!

@wangzhaode
wangzhaode merged commit 5796d59 into alibaba:master Sep 20, 2026
1 check passed
@ZedingZhang
ZedingZhang deleted the feature/omni-ple-refresh branch September 20, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting contributor Waiting for contributor to address review comments or rebase module:llm LLM 推理相关 type:bug 功能缺陷

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Omni reuses stale PLE input across successive text requests

2 participants