The existing community export,
onnx-community/colSmol-256M-ONNX,
is traced at exactly 13 tiles and rejects any other count. Idefics3 tiles an
image according to its aspect ratio, so the tile count is a property of the
input, not a constant:
aspect ratio
tiles
16:10 (typical desktop)
7
landscape
13
5:4 / square
17
A 13-tile-only export therefore cannot process a 16:10 screenshot at all. This
export makes the tile axis dynamic, so one model handles every aspect ratio.
What changed
Two places in Idefics3 use data-dependent shapes, which is what bakes the tile
count into a trace. Both are replaced with shape-static equivalents:
Idefics3Model.get_image_features filters "padding" tiles with
boolean-mask indexing (pixel_values[real_images_inds]). The result's size
depends on the data, so tracing freezes it. The filter is dropped — callers
must pass only real tiles, which is this export's documented precondition.
The per-patch attention mask is also rebuilt with a reshape-and-sum instead of
two unfold calls, which ONNX cannot export once the leading dim is dynamic.
Idefics3VisionEmbeddings.forward does a masked assignment
(position_ids[mask] = pos_ids[mask]). Replaced with torch.where, which is
numerically identical — masked-out positions keep the zero fill — but static.
Precondition: pass only real tiles. This export has no padding-tile filter,
so padding tiles would be embedded as if they were content.