Repository: pytorch
Issue: unreasonable ConstraintViolationError when using torch dynamo to compile torch model
Labels: triaged,oncall: pt2,module: dynamic shapes,module: dynamo,oncall: export

### 🐛 Describe the bug

I'm using torch dynamo backend to compile model to export to tensorrt.
```python
    inputs = [torch.randn(1, 3, 28, 288, 512).cuda().to(torch.float16)]
    
    dynamic_h = torch.export.Dim("dim_3", min=224, max=640)
    dynamic_w = torch.export.Dim("dim_4", min=224, max=640)
    dynamic_t = torch.export.Dim("dim_2", min=1, max=200)
    dynamic_shapes={"x": {2:dynamic_t, 3: dynamic_h, 4: dynamic_w}}

    exp_program = torch.export.export(encoder_model, args=tuple(inputs), dynamic_shapes=dynamic_shapes, strict=True)

    trt_model = torch_tensorrt.dynamo.compile(
        exported_program=exp_program,
        assume_dynamic_shape_support=True,
        inputs=inputs, 
        make_refitable=True, 
        disable_tf32=True, 
        debug=True, 
        enabled_precisions={torch.half, torch.float},
        torch_executed_ops={},
        min_block_size=17,
        truncate_double=True,
        use_python_runtime=False)
```
I've confirmed that the h, w dim can be dynamic without constraint error but the dim_2 cannot. It's quite strange.
I trace the cause and found it's in here
```python
class GroupNormSpatial(nn.Module):
    """GroupNorm with spatial dimensions ignored."""
    def __init__(self, num_groups, num_channels, epsilon: float = 1e-5, affine=True):
        super().__init__()
        # affine=False # TODO: for tensorrt only
        self.norm_fn = nn.GroupNorm(num_groups=num_groups, num_channels=num_channels, eps=epsilon, affine=affine)

    def forward(self, inputs: torch.Tensor) -> torch.Tensor:
        if int(inputs.ndim) == 5: # video
            b, c, t, h, w = inputs.shape
            inputs = inputs.permute(0,2,1,3,4).flatten(start_dim=0, end_dim=1) # ERROR
            out = self.norm_fn(inputs)
            out = out.reshape(b, t, c, h, w).permute(0,2,1,3,4) # ERROR
            return out
        else: # Image, b c h w -> b c h w
            out = self.norm_fn(inputs)
            return out
```

```
I1218 02:40:31.595000 155463 torch/_utils_internal.py:116] [0/0] CompilationMetrics(compile_id='0/0', frame_key='1', co_name='forward', co_filename='xxx,py', co_firstlineno=50, cache_size=0, accumulated_cache_size=0, guard_count=None, shape_env_guard_count=None, graph_op_count=None, graph_node_count=None, graph_input_count=None, start_time=1734489622.2484767, entire_frame_compile_time_s=None, backend_compile_time_s=None, inductor_compile_time_s=None, code_gen_time_s=None, fail_type="<class 'torch.fx.experimental.symbolic_shapes.ConstraintViolationError'>", fail_reason='Constraints violated (dim_2)! For more information, run with TORCH_LOGS="+dynamic".\n  - Not all values of dim_2 = L[\'x\'].size()[2] in the specified range dim_2 <= 200 satisfy the generated guard Ne(Mod(1, ((L[\'x\'].size()[2] - 1)//2) + 1), 0).\n  - Not all values of dim_2 = L[\'x\'].size()[2] in the specified range dim_2 <= 200 satisfy the generated guard Ne(Mod(1, ((L[\'x\'].size()[2] - 1)//4) + 1), 0).\n  - Not all values of dim_2 = L[\'x\'].size()[2] in the specified range dim_2 <= 200 satisfy the generated guard 9 <= L[\'x\'].size()[2] and L[\'x\'].size()[2] <= 200', fail_user_frame_filename=None, fail_user_frame_lineno=None, non_compliant_ops=set(), compliant_custom_ops=set(), restart_reasons=set(), dynamo_time_before_restart_s=9.347490787506104, has_guarded_code=False, possibly_missed_reinplacing_opportunities=None)
```

### Versions

I'm using ngc torch `nvcr.io/nvidia/pytorch:24.10-py3`

cc @chauhang @penguinwu @ezyang @bobrenjc93 @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @amjames @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @suo @ydwu4