Skip to content

feat(xla): admit image requests in CLI and continuous-batch serving #861

Closed

Description

@inureyes

Parent and dependency

Problem

XlaServeWorker::admit currently rejects any image, audio, or video input. spawn_xla_model_worker loads only a tokenizer and XlaBatchEngine; it owns no multimodal preprocessor. The single-session dispatch also has a historical path that can ignore input embeddings. As a result, having an embeddings-capable IREE engine is not enough to make either CLI or OpenAI-compatible serving correct.

Goal

Wire the prepared image-prefill path into XLA CLI generation and continuous-batch serving, while preserving media security limits, per-request failure isolation, truthful capabilities, and text batching behavior.

Required implementation

  • Make the XLA worker own the host multimodal preprocessor selected for the loaded checkpoint. Construct it once during model startup and fail startup when the model advertises a supported XLA VLM family but required processor/projector weights are missing.
  • Reuse the existing server image decoding, URL/data handling, byte/pixel/count limits, and validation policy. Do not add an XLA-only network or decoding path.
  • Perform decode/preprocessing in a bounded stage that cannot block the scheduler loop or allow unbounded per-request host memory. Preserve request ordering and cancellation while preprocessing is in flight.
  • For supported image requests, tokenize/expand placeholders, create the prepared-prefill DTO, run context-capacity admission on its effective length, and submit it through XlaBatchEngine.
  • Keep logical token IDs for detokenization, penalties, stop matching, streaming chunks, and API usage accounting. Track expanded prefill length separately for cache positions and internal metrics; document which value is exposed by each metric.
  • Route CLI --image/multimodal generation through the same prepared-prefill/session contract rather than a CLI-only shortcut.
  • Set SessionCapabilities.multimodal for XLA only when the loaded model and runtime bundle actually support the path. Capability checks and execution dispatch must use the same predicate.
  • Continue to reject audio and video until their dedicated foundation is implemented. Return explicit modality/model/backend errors rather than silently dropping media.
  • Preserve per-request isolation: decode, preprocessing, admission, or native failures must finish only that request and leave the worker and other slots healthy.
  • Preserve existing unsupported-option behavior for features such as XLA logprobs; adding images must not make unrelated request fields appear supported.

Non-goals

  • Emitting the vision encoder through StableHLO.
  • Adding Qwen M-RoPE, Gemma image masks, audio, or video support.
  • Changing public OpenAI-compatible request schemas.

Validation

  • Add worker tests with the deterministic fake preprocessor for successful image admission, malformed media, placeholder mismatch, capacity overflow, cancellation during preprocessing, and preprocessing failure beside active text requests.
  • Add mixed continuous-batch tests with text and image requests, verifying independent streaming, stop conditions, token histories, cache lengths, slot reuse, and metrics.
  • Add capability tests for text-only XLA, supported image VLM XLA, unsupported VLM XLA, and MLX sessions.
  • Add a regression test proving images/audio/video can never be accepted and then ignored.
  • Exercise one real image request through the CLI path and one through the OpenAI-compatible streaming server path on an available IREE target.
  • Run existing text-only server, scheduler, and XLA batch suites.

Acceptance criteria

  • Supported XLA image requests reach embeddings prefill in both CLI and server paths.
  • Existing media decode/security limits are reused exactly once.
  • Preprocessing is bounded, cancellable, and does not block the scheduler loop.
  • Capability reporting and execution support cannot disagree.
  • Unsupported modalities fail explicitly and are never dropped.
  • A failed image request cannot corrupt another slot or stop the worker.
  • Existing text-only continuous batching and API accounting remain unchanged.

Activity

  1. added
    status:blockedBlocked by dependencies or other issues
    type:enhancementNew features, capabilities, or significant additions
    area:architectureArchitecture and code structure changes
    area:inferenceGeneration, sampling, decoding (incl. speculative, DRY)
    area:cliCommand-line interface / CLI flags
    on Jul 22, 2026
  2. inureyes commented on Jul 23, 2026

    @inureyes
    MemberAuthor

    Review follow-up evidence is now on PR #895 at head 8880d6e.

    • Declared media metadata is preserved to XLA admission; dropped/partial images and malformed audio/video can no longer become text requests.
    • Bounded preprocessing now has deterministic cancellation, FIFO, capacity, disconnect, failure-isolation, accounting, and slot-reuse regressions.
    • Capability reporting and execution share the qualified runtime/preprocessor predicate.
    • Real IREE CLI and OpenAI streaming image requests both passed; the server returned to active_sequences=0, queue_depth=0.
    • Full affected suites passed: root XLA+IREE 4,488 passed, mlxcel-xla 195 passed, plus default/XLA Clippy with warnings denied and formatting checks.

    No CSV files changed. The PR remains open in review; this update does not merge it.

  3. self-assigned this
    on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:architectureArchitecture and code structure changesarea:cliCommand-line interface / CLI flagsarea:inferenceGeneration, sampling, decoding (incl. speculative, DRY)priority:highHigh prioritystatus:doneCompletedtype:enhancementNew features, capabilities, or significant additions

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions