RunanywhereAI / RunanywhereAI/runanywhere-android

QHexRT/NPU generate fails with InvalidArgument when prompt exceeds max_ctx (LFM2.5-230M: 599 > 512)

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

Nobody has claimed this yet.

bug
Dominant language
Kotlin
Stars
11
Forks
27
PR merge metrics
No merged PRs in 30d

Description

Summary

During device E2E testing (physical Snapdragon dev unit, serial 8977b1dd, Canoe_for_arm64, Android 16) after downloading and loading LFM2.5 230M on the QHexRT/NPU backend, a generate call failed natively with InvalidArgument because the assembled prompt (599 tokens) exceeded the model's max_ctx (512). The app did not crash — a subsequent plain-chat generate on the same loaded model succeeded cleanly (223 tok/s, 47ms ttft) — but the failure surfaces as a raw native error rather than a graceful, user-facing message.

Suspected trigger

The failing call appears to be a request that included the tool-calling / "web and tools" prompt template (see the accompanying racToolCallingRunLoopProto error in the same log burst), which pushes prompt length well past what a 512-ctx small model can hold. Worth checking whether the "enable web and tools" toggle should be disabled/warned for models whose catalog-declared context window can't fit the tool-calling template overhead.

Logcat evidence

08-17 15:16:50.146 I/qhexrt  ( 1375): rpcmem ion allocator ready
08-17 15:16:50.158 I/qhexrt  ( 1375): ion buffers bound (24 in, 21 out)
08-17 15:16:50.158 I/qhexrt  ( 1375): ion buffers bound (1 in, 1 out)
08-17 15:16:50.164 I/qhexrt  ( 1375): ion buffers bound (4 in, 21 out)
08-17 15:16:50.164 I/qhexrt  ( 1375): Session: built IoTensors for 3 graph(s), ion-persistent
08-17 15:16:50.548 I/qhexrt  ( 1375): rpcmem ion allocator ready
08-17 15:16:50.557 I/qhexrt  ( 1375): ion buffers bound (24 in, 21 out)
08-17 15:16:50.557 I/qhexrt  ( 1375): ion buffers bound (1 in, 1 out)
08-17 15:16:50.562 I/qhexrt  ( 1375): ion buffers bound (4 in, 21 out)
08-17 15:16:50.562 I/qhexrt  ( 1375): Session: built IoTensors for 3 graph(s), ion-persistent
08-17 15:16:50.566 E/qhexrt  ( 1375): lfm_generate: bad prompt len 599 (max_ctx 512)
08-17 15:16:50.566 E/qhexrt  ( 1375): plan: host-op 'lfm_generate' failed (InvalidArgument)
08-17 15:16:50.566 E/QHexRT  ( 1375): qhx_generate failed: InvalidArgument
08-17 15:16:50.566 I/System.out( 1375): [ERROR] [QHexRT] [Native] qhx_generate failed: InvalidArgument | source_file=qhexrt_llm_ops.cpp:282, source_function=qhexrt_llm_generate, device_model=Canoe for arm64, os_version=16, platform=android
08-17 15:16:50.566 I/System.out( 1375): [ERROR] [JNI.Commons] [Native] racToolCallingRunLoopProto: native proto API failed with code -130 (racToolCallingRunLoopProto) | source_file=runanywhere_commons_jni.cpp:524, source_function=makeProtoBufferByteArray, device_model=Canoe for arm64, os_version=16, platform=android

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

Start by reproducing the 599-token prompt failure on the QHexRT/NPU backend, then inspect qhexrt_llm_ops.cpp at qhexrt_llm_generate and the racToolCallingRunLoopProto path in runanywhere_commons_jni.cpp. The issue is done when prompts exceeding max_ctx no longer surface as a raw native error and the user receives graceful handling, including appropriate behavior for the web-and-tools option.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
machine-learning, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.