← Questions

Write and speed up an image filter for on-device use

0
AppleAI/ML designLast asked Mar 2026

An AI/ML design interview question asked in Apple's AI/ML design round, last asked Mar 2026. It tests image processing, on-device and performance.

You are shipping an image filter that must run entirely on a phone. Write the filter (for example a blur or other convolution over the pixels), then make it fast: the live preview must stay under 30 ms on common phones, with little extra memory and minimal battery drain, while the output still looks right.

Requirements

  • Functional: apply the filter to a camera frame or photo and produce a preview in real time and a full-resolution result on save.
  • Non-functional: preview latency below 30 ms per frame, low memory overhead, minimal battery and heat, acceptable visual quality compared with a reference implementation.

Clarifying questions

  • Which filter, and what kernel size? Is it fixed or set by the user?
  • What resolutions for preview and for the saved photo?
  • Which devices must it run on, and what hardware do they have (GPU, neural accelerator, vector instructions)?
  • Is the filter a learned model or a hand-written kernel?
  • How do we judge quality: pixel difference, a perceptual metric, or people?

What a strong answer covers

  • The cost per pixel of a direct k x k convolution, O(k²), and how separable kernels bring it to O(2k); box-blur or integral-image tricks; how edges are handled (clamp, mirror, zero).
  • Running the preview at lower resolution and the full filter only on save.
  • Numerical precision: 8-bit or half-precision arithmetic, and how to check the quality loss.
  • Hardware: vectorized CPU code versus a GPU shader versus the neural accelerator, including the cost of moving data between them.
  • Memory layout and tiling: process in tiles or rows that fit in cache, avoid extra full-size copies, reuse buffers.
  • Thermal limits over a long session and how to measure latency, memory, power and quality before and after each change.

Follow-ups

  • The filter is now a small neural network. What changes in how you optimize it?
  • Latency is fine for one minute but grows after five. Why, and what do you do?
  • How would you catch a quality regression across a range of devices?

Where it's asked

  • Apple · AI/ML design · Last asked Mar 2026

What it tests

image processing · on-device · performance

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing