ks* kernel args (symbolic scalars like alpha in torch.add) are always
int64 in the Triton signature (per _decide_tl_dtype), but index_expr
was setting the CSE variable dtype to the kernel's index_dtype which
can be int32 for small tensors. This caused two issues:
- When a ks* arg needed casting (e.g., int64 -> float for math.sqrt),
the CSE variable's wrong dtype could cause the cast to be skipped. - runtime_triton_dtype_assert would fire incorrect static_assert
checks comparing against int32 when the actual type was int64.
Fix: use torch.promote_types(dtype, index_dtype) so that int32
requests follow the kernel's index dtype, but int64 requests are never
downcast to int32 (which would overflow values like randint's high
bound). Also skip redundant dtype/shape assertions in
CSEProxy._default for ops like index_expr that manage their own
checking internally.
This enables test_op_dtype_propagation to run with dynamic=True.
Authored with Claude.
Pull Request resolved: #182872
Approved by: https://github.com/ezyang, https://github.com/liqiangxl
SOCIAL SHARE CARD GENERATOR