You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On TPU, XLA keys its compiled graph on the per-image ground-truth box-count tuple, not only on image shape. #1058's Task 1.5 covers image-shape variance (multi_scale); this is a second axis it doesn't mention.
With image shape held constant, a repeated tuple runs in 0.18 s and a new one costs ~47 s plus 4 fresh compilations. Tested as a predictor over 30 steps:
candidate key
predicts cache hit
total_boxes (sum)
21/30
per-image count tuple
28/30
On COCO (0–93 objects/image) that space is effectively unbounded, so a run never reaches steady state.
Impact
Padding each training image's targets to a fixed row count in collate, measured on the same 15 steps and data:
compiling steps
steady state
total wall
baseline
14 / 15
1.17 s
684.1 s
padded
3 / 15
0.26 s
92.8 s
7.4× on a v5litepod-4; −55.62% median fit time on a v6e-1. The unpadded baseline also climbs to 30 GB RSS, because every new shape leaves another compiled graph cached.
It is semantically transparent, not an approximation: over 40 random batches the Hungarian assignment on real targets is identical, loss_ce is bit-identical, and box terms differ only in float32 summation order. Padded columns get a query-independent matcher cost, so they cannot displace a real target. Only the training loader would be padded — padding eval would feed filler rows to COCO matching.
Questions before implementing
Is a TrainConfig field (e.g. pad_targets_to) the shape you want, defaulting off?
Problem
On TPU, XLA keys its compiled graph on the per-image ground-truth box-count tuple, not only on image shape. #1058's Task 1.5 covers image-shape variance (
multi_scale); this is a second axis it doesn't mention.With image shape held constant, a repeated tuple runs in 0.18 s and a new one costs ~47 s plus 4 fresh compilations. Tested as a predictor over 30 steps:
total_boxes(sum)On COCO (0–93 objects/image) that space is effectively unbounded, so a run never reaches steady state.
Impact
Padding each training image's targets to a fixed row count in collate, measured on the same 15 steps and data:
7.4× on a v5litepod-4; −55.62% median fit time on a v6e-1. The unpadded baseline also climbs to 30 GB RSS, because every new shape leaves another compiled graph cached.
It is semantically transparent, not an approximation: over 40 random batches the Hungarian assignment on real targets is identical,
loss_ceis bit-identical, and box terms differ only in float32 summation order. Padded columns get a query-independent matcher cost, so they cannot displace a real target. Only the training loader would be padded — padding eval would feed filler rows to COCO matching.Questions before implementing
TrainConfigfield (e.g.pad_targets_to) the shape you want, defaulting off?pack_targets(perf(training): pack per-sample targets across the DataLoader boundary #1399)? Both touch the same collate seam. Pad-then-pack looks natural and should make packing more uniform, but that's a design call.@Borda, Happy to open the PR once the approach is agreed
Refs #1058.