BentoMLvLLM

Dynamic shapes configuration affects guard behavior and performance

info
configurationUpdated Mar 24, 2026
How to detect:

The dynamic_shapes_config type setting controls how torch.compile handles dynamic batch sizes. BACKED (default) may unsafely drop guards for performance. UNBACKED provides strongest guarantee against guards but may miss optimizations. BACKED_SIZE_OBLIVIOUS is experimental but safer than BACKED.

Recommended action:

Choose dynamic shapes mode based on requirements: Use BACKED for maximum performance with potential unsafe guard dropping. Use UNBACKED when you need strongest guarantee against guards and can accept missed optimization opportunities. Use BACKED_SIZE_OBLIVIOUS for balance between avoiding guards and performance. Configure via --compilation-config '{"dynamic_shapes_config": {"type": "unbacked"}}' for serving or CompilationConfig(dynamic_shapes_config=DynamicShapesConfig(type=DynamicShapesType.UNBACKED)) for LLM class.