Skip to content

feat: torch.compile for OCR det/rec inference - #12

Open
abimaelmartell wants to merge 2 commits into
mainfrom
feat/torch-compile
Open

abimaelmartell wants to merge 2 commits into
mainfrom
feat/torch-compile

Conversation

@abimaelmartell

Copy link
Copy Markdown
Member

Summary

  • Patch OCR-det and OCR-rec models to use torch.compile(dynamic=True) for optimized GPU kernels via Triton
  • Controlled via TORCH_COMPILE env var (set to 0 to disable)
  • Compilation mode configurable via TORCH_COMPILE_MODE (default: default)
  • First inference triggers compilation, subsequent calls use cached optimized kernels

Targets the two models with the most forward passes per request (OCR-det has ~255 resolution groups). YOLO models (layout/MFD) are skipped since they go through ultralytics' predict pipeline.

Pairs well with the warmup PR (#11) — warmup inference triggers compilation so real requests hit pre-compiled kernels.

Patch OCR detection and recognition models to use torch.compile with
dynamic shapes. Controlled via TORCH_COMPILE env var (default: enabled).
Compilation happens lazily on first inference, then subsequent calls
use optimized Triton kernels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant