Re-export Depth Anything V2 Small with full GPU delegation

#1
by snnn001 - opened

Re-export both TFLite files from depth-anything/Depth-Anything-V2-Small-hf (revision 5426e4f0f36572d16453bbda7a8389317b1bef99) using local conversion changes. Both exports now run fully on native LiteRT WebGPU on the tested Linux host. This also avoids the dynamic INT8 FC pattern reported in google-ai-edge/LiteRT#9481.

The files overwrite the existing paths and preserve the serving_default(args_0) β†’ output_0 signature, input [1,3,518,686], output [1,518,686], FP32 interfaces and the dynamic INT8 weight format.

  • 746 β†’ 519 operators: freeze constant positional interpolation, simplify shape handling, share normalization work and fold attention scaling into Q weights/biases. All FCs preserve rank; no new composite/custom ops are introduced.
  • Dynamic INT8 is regenerated with dynamic_wi8_afp32() after FP32 optimization.
  • Validation: identical inputs for 100 natural images, compared with the original PyTorch checkpoint. FP32 pooled relative L2: 7.13e-7 CPU / 7.18e-7 GPU. INT8: 2.080% CPU / 1.868% GPU. Published INT8 CPU is 2.056%; this is comparable quantization parity, not a claim of improved task accuracy. No ground-truth depth labels were used.
  • The normalization/scaling rewrites are bit-identical to the earlier local exports on all 100 images, both CPU and GPU.

Repeated latency measurements on an i9-12900K (four physical P-cores) / Radeon AI PRO R9700, LiteRT 2.3.0, native WebGPU with FP32 compute:

File Published CPU New CPU New GPU
FP32 356.03 ms 353.94 ms 19.83 ms
Dynamic INT8 246.83 ms 244.81 ms 19.88 ms

Six interleaved rounds, synchronized invocation plus output read; compilation and preprocessing excluded. GPU: 20 warmups + 60 measured calls/round; CPU: 5 + 12. Against the earlier local graphs, CPU latency falls 11.1% / 14.9%; GPU latency is essentially unchanged.

A valid published-GPU speed comparison is unavailable on this runtime: the original INT8 file fails GPU compilation, and the FP32 GPU+CPU path produces incorrect depth maps. New files pass both CPU and GPU parity checks. Browser JavaScript, phones and NPUs were not tested.

Please explicitly request FP32 GPU computation when running this model on the LiteRT native WebGPU runtime tested here. In Python's CompiledModel API, pass:

from ai_edge_litert.options import GpuOptions

# Use this in Options(gpu_options=...).
gpu_options = GpuOptions(enforce_f32=True)

All GPU accuracy and performance results already reported in this PR used this flag, including the dynamic INT8 file. FP32 input/output tensor types alone do not force FP32 internal GPU computation; the default precision policy can select FP16.

A follow-up check of the FP32 model on the same 100 images found:

GPU precision Pooled relative L2 error vs PyTorch
Default (enforce_f32=False) 94.94% β€” incorrect depth maps
enforce_f32=True 7.18e-7

The original local export also fails under default precision, so the severe failure predates the normalization-sharing and attention-scaling rewrites. Their bit-identical GPU validation applies to FP32-enforced execution.

This requirement is based on the tested LiteRT 2.3.0 native WebGPU configuration. Browser JavaScript and other GPU runtimes were not validated.

captainspock changed pull request status to merged

Sign up or log in to comment