Skip to content

fix: Android LlamaDemo app - remove unnecessary stop code check per model#200

Merged
kirklandsign merged 2 commits intometa-pytorch:mainfrom
saiskandadotin:fix-android-llamademo-stop-token-handling
Feb 4, 2026
Merged

fix: Android LlamaDemo app - remove unnecessary stop code check per model#200
kirklandsign merged 2 commits intometa-pytorch:mainfrom
saiskandadotin:fix-android-llamademo-stop-token-handling

Conversation

@saiskandadotin
Copy link
Contributor

Issue faced - When LlamaDemo app is used with Qwen3, inference would not stop until unless stopped manually

Fix - Removed an unnecessary check that would stop inference only for particular models

Note - Not sure if I am missing something here but as long as stop code is configured in PromptFormat, any model level check should not be required.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 4, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR unifies stop-token handling in the Android LlamaDemo app so that generation stops correctly for all models, including Qwen3. It removes a model-specific condition and always stops the module when the configured stop token is encountered.

Changes:

  • In ChatViewModel.onResult, remove the special-case check for GEMMA_3 and LLAVA_1_5 and always call module?.stop() when the streamed token equals the model’s configured stop token.
  • Ensure early return from onResult after stopping to avoid further token processing once the stop token is seen.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…llamademo/ui/viewmodel/ChatViewModel.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@kirklandsign kirklandsign merged commit 22f462a into meta-pytorch:main Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants