Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: tuple index out of range when using a high dimensional Sum_Reduction #256

Closed
c0g opened this issue Jul 1, 2022 · 1 comment
Assignees
Labels
bug Something isn't working c++ related to compilation and c++xx

Comments

@c0g
Copy link

c0g commented Jul 1, 2022

I'm using the GeomLoss library and trying to use a Sinkhorn loss with the online backend. For a high dimensional (>=512 I think) tensor it gives me an error when compiling the backward code. Here's the repro with GeomLoss:

from geomloss import SamplesLoss
loss = SamplesLoss(loss="sinkhorn", p=2, blur=.05, backend="online")
x = torch.randn(1000, 512, requires_grad=True)
y = torch.randn(1000, 512)
loss(x, y).backward()

I also have this direct repro by copying values from the debugger:

tagCPUGPU, tag1D2D, tagHostDevice, use_ranges, device_id_request = 1, 0, 0, None, 0
formula, aliases, len_args, dtype = ('Grad_WithSavedForward(Max_SumShiftExp_Reduction(( B - (P * (SqDist(X,Y) / IntCst(2)) ) ),0), Var(0,768,0), Var(4,2,0), Var(5,2,0))', ['X = Vi(768)', 'Y = Vj(768)', 'B = Vj(1)', 'P = Pm(1)', 'Var(4,2,0)', 'Var(5,2,0)'], 6, 'float32')
optional_flags = {'dtype_acc': 'auto', 'sum_scheme': 'block_sum', 'enable_chunks': 1, 'multVar_highdim': 1}


from pykeops.common.keops_io import keops_binder
keops_binder["nvrtc" if tagCPUGPU else "cpp"](tagCPUGPU,
    tag1D2D,
    tagHostDevice,
    use_ranges,
    device_id_request,
    formula,
    aliases,
    len_args,
    dtype,
    "torch",
    optional_flags,
).import_module()

Both give:

File /opt/conda/lib/python3.8/site-packages/keopscore/mapreduce/gpu/GpuReduc1D_finalchunks.py:103, in GpuReduc1D_finalchunks.get_code(self)
     98 fun_internal = Sum_Reduction(
     99     self.red_formula.formula.children[0], self.red_formula.tagI
    100 )
    101 formula = fun_internal.formula
--> 103 varfinal = self.red_formula.formula.children[1]
    104 nchunks = 1 + (varfinal.dim - 1) // dimfinalchunk
    105 dimlastfinalchunk = varfinal.dim - (nchunks - 1) * dimfinalchunk

IndexError: tuple index out of range

Versions

> python --version
Python 3.8.12
> pip freeze | rg "geom|keops"
geomloss==0.2.5
keopscore==2.1
pykeops==2.1
@jeanfeydy jeanfeydy added bug Something isn't working c++ related to compilation and c++xx labels Jul 27, 2022
joanglaunes added a commit that referenced this issue Aug 5, 2022
@jeanfeydy
Copy link
Contributor

Can confirm that the problem now seems to be fixed, so closing the issue. Please feel free to re-open if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working c++ related to compilation and c++xx
Projects
None yet
Development

No branches or pull requests

3 participants