Describe the bug
I'm looking at representing quantization casting with tile invariant functions, so they can be easily tiled. This doesn't seem to work today with helion. I'm wondering if this is a bug or a limitation of the programming model.
For example, given the following pytorch code
def deepseek_1x128_f(x):
fp8_max = torch.finfo(torch.float8_e4m3fn).max # 448.0
*lead, last = x.shape
x_b = x.reshape(*lead, last // 128, 128)
amax = x_b.abs().amax(dim=-1, keepdim=True).clamp(min=1e-12).to(torch.float32)
scale = (amax / fp8_max).to(torch.float32) # forward scale
qdata = (x_b.to(torch.float32) * (1.0 / scale)).to(torch.float8_e4m3fn)
return qdata.reshape(*lead, last), scale.squeeze(-1)
I want, but currently cannot, write the following helion code
@helion.kernel(config=helion.Config(block_sizes=[32, BLOCK_N], num_warps=4))
def _tile_map_broken_kernel(x: torch.Tensor, f):
M, N = x.size()
out = torch.empty((M, N), dtype=torch.float8_e4m3fn, device=x.device)
aux = torch.empty((M, N // BLOCK_N), dtype=torch.float32, device=x.device)
for tile_m, tile_n in hl.tile([M, N]):
acc = x[tile_m, tile_n] # (BM, BLOCK_N)
# Pass the reference recipe straight through. It does
# x.reshape(*lead, last // 128, 128)
# on a symbolic tile -> Helion cannot prove the tile extent factors as
# (n_groups, 128), tracing fails here.
out_local, aux_local = f(acc)
out[tile_m, tile_n] = out_local
aux[tile_m, tile_n.begin // BLOCK_N] = aux_local.squeeze(-1)
return out, aux
def run_helion_does_not_work(x):
return _tile_map_broken_kernel(x, deepseek_1x128_f)
error:
helion.exc.TorchOpTracingError: RuntimeError: shape '[u1, (u2//128), 128]' is invalid for input of size u1*u2
To Reproduce
Full repro: https://gist.github.com/vkuzo/f2e2bf10e9526146ff836023f33b735c
Stdout of running the repro:
https://gist.github.com/vkuzo/afe6f2064fa44e58775c71da849ab4c5
Versions
torch 2.14.0.dev20260720+cu130, helion 1.2.0
Describe the bug
I'm looking at representing quantization casting with tile invariant functions, so they can be easily tiled. This doesn't seem to work today with helion. I'm wondering if this is a bug or a limitation of the programming model.
For example, given the following pytorch code
I want, but currently cannot, write the following helion code
error:
To Reproduce
Full repro: https://gist.github.com/vkuzo/f2e2bf10e9526146ff836023f33b735c
Stdout of running the repro:
https://gist.github.com/vkuzo/afe6f2064fa44e58775c71da849ab4c5
Versions
torch 2.14.0.dev20260720+cu130, helion 1.2.0