Android
AuraScore 77/100

Android Multimodal Embedding Quantization and Benchmarking Suite

Automate on-device quantization, compilation, and ADB latency benchmarking for multimodal visual prompt encoders.

Deploy this workflow when preparing multimodal vision-language prompt encoders for edge deployment on Android devices. It automates model quantization, ABI packaging, and profiling across hardware targets.

Template

Role: Staff Android AI Infrastructure & Performance Engineer

Context

  • Source PyTorch or ONNX multimodal model path: {{onnx_source_model}}
  • Quantization scheme and precision target: {{quantization_precision}}
  • Native Android Architecture ABI target: {{target_android_abi}}
  • Physical test device identifier: {{benchmark_device_serial}}
  • Multimodal visual token vector dimension: {{clip_embedding_dimension}}
  • Maximum inference latency ceiling: {{max_latency_budget_ms}}

Task

Author an automated Python and Bash optimization script that converts multimodal vision-language prompt encoders into an optimized Android LiteRT/NNAPI artifact, benchmarks inference on connected hardware, and produces integration manifests.

Method

  1. Parse the input model {{onnx_source_model}} and isolate the visual prompt projection heads and text tokenizer graph.
  2. Apply representative calibration datasets matching {{clip_embedding_dimension}} to calculate tensor activation dynamic ranges.
  3. Execute static INT8/FP16 quantization based on {{quantization_precision}} using LiteRT model optimizer flags.
  4. Package the compiled artifact targeting native libraries for {{target_android_abi}} with fused operator kernels.
  5. Deploy the compiled binary and test harness via ADB to device {{benchmark_device_serial}}.
  6. Run 100 warmup cycles followed by 500 timed inference passes measuring latency against {{max_latency_budget_ms}}.
  7. Extract per-layer NPU, GPU, and CPU execution splits via Android Systrace and generate a hardware affinity matrix.
  8. Validate that cosine similarity between fp32 golden outputs and quantized on-device embeddings exceeds 0.985.

Constraints

  • The script MUST abort pipeline execution if median device latency exceeds {{max_latency_budget_ms}}.
  • The output model MUST NOT produce NaN or Inf values when handling out-of-distribution visual tokens.
  • Include automated ADB device state verification before executing benchmarks (battery level > 50%, thermal status normal).
  • Ensure all generated model metadata headers conform to Android LiteRT schema standards.

Output format

A structured executable automation script and report generator containing:

  1. Environment Setup & Dependency Verification (Bash)
  2. Optimization & Quantization Script (quantize_multimodal.py)
  3. ADB Remote Benchmark Runner (benchmark_android.sh)
  4. JSON Telemetry Schema for latency, memory RSS, and cosine accuracy.

Self-review

  • Are ADB shell commands parameterized safely against device disconnects?
  • Does the quantization logic correctly preserve multi-head attention precision?
  • Is cosine similarity validation executed against real tensor outputs?
AuraScore breakdown
77/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering8/12 · Adequate

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-android
image-multimodal-prompting
android
quantization
litert