#1473·GenieX

[FEATURE] Allow prompt_utf8 input in geniex_llm_forward_logits

Author: nos1609Created Sep 20, 2026Updated Sep 22, 2026

Is your feature request related to a problem? Please describe.

geniex_llm_generate() accepts a UTF-8 prompt, while geniex_llm_forward_logits() currently requires pre-tokenized input_ids.

For native applications that only need next-token logits, this forces every caller to bring and maintain a separate tokenizer implementation even though the selected GenieX backend already has the tokenizer required for normal generation.

This adds an unnecessary external dependency and creates a risk that external tokenization differs from the tokenizer used internally by GenieX for the same model.

Describe the solution you'd like

Allow geniex_llm_forward_logits() to accept prompt_utf8 in the same way as geniex_llm_generate(), while keeping the current input_ids path for callers that want explicit control over tokenization.

For example:

c
typedef struct {
    const char *prompt_utf8;

    const int32_t *input_ids;
    int32_t input_ids_count;

    bool all_positions;
    int32_t top_n;
} geniex_LlmForwardLogitsInput;

with exactly one of prompt_utf8 or input_ids supplied.

Ideally, the implementation would reuse the same backend tokenizer path already used by geniex_llm_generate().

Describe alternatives you've considered

The current workaround is to tokenize outside GenieX and pass input_ids.

That works, but it adds:

  • another tokenizer/runtime dependency;
  • duplicated tokenizer assets;
  • possible tokenizer/version mismatch with the loaded model bundle;
  • extra integration work for C and Go callers;
  • a different text-processing path from geniex_llm_generate().

A standalone geniex_llm_tokenize() API would also solve the problem, but accepting prompt_utf8 directly in forward_logits() seems simpler for callers and more symmetric with the existing generation API.

Additional context

I am using GenieX with the QAIRT backend on Snapdragon X Elite for a local System-One-style semantic decision service.

The workload is similar to Jev/Nimble-style bounded classification:

  1. Build a short prompt describing state, policy, and candidate actions.
  2. Run one prefill-only forward pass.
  3. Read logits for one-token labels such as A, B, C, D.
  4. Apply softmax/calibration and return the selected action.
  5. No autoregressive generation is required.

With Qwen3-1.7B W4A16 on QAIRT / Snapdragon X Elite, representative prompts below 128 tokens are currently around:

mean: ~157 ms
p95:  ~185 ms

The model is kept resident and the intended application is a small native daemon using the GenieX C ABI. Tokenization is currently the main awkward external dependency.

This also seems related to the logit-access requirements discussed in #1411, although the primary use case here is runtime inference rather than evaluation.

A useful optional follow-up would be support for returning logits only for explicitly requested token IDs.

For bounded classification, the caller may need only 2–8 values, while Qwen3 has a 151,936-token vocabulary. The full final-position FP32 logit buffer is roughly 594 KiB even when the application only needs a few floats.

Conceptually, something like:

c
int32_t geniex_llm_forward_selected_logits(
    geniex_LLM *llm,
    const char *prompt_utf8,
    const int32_t *candidate_token_ids,
    int32_t candidate_count,
    float *candidate_logits
);

could avoid copying the full vocabulary out of the runtime.

This optimization is not required for the main request; prompt_utf8 support in the existing forward_logits() API would already solve the core integration problem.

I can test this on Windows ARM64 with the QAIRT backend and Snapdragon X Elite.