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

Stride mismatch error with correct contiguity info #3957

Open
IvanYashchuk opened this issue Feb 25, 2025 · 2 comments
Open

Stride mismatch error with correct contiguity info #3957

IvanYashchuk opened this issue Feb 25, 2025 · 2 comments
Assignees

Comments

@IvanYashchuk
Copy link
Collaborator

When running the following code snippet I get a stride mismatch error. The error message says that the contiguity is [t, t] even though it's specified in the FusionDefinition to be [False, True]:

RuntimeError: Stride mismatch with contiguity info.  allocation domain: iS14{2}, iS15{2}: sizes: [2, 2]: strides: [3, 1]; contiguity: t, t; dim: 0; expected stride: 2; actual stride: 3
Exception raised from validateAllocationSizesAndStrides at /home/iyashchuk/dev/Fuser/csrc/tensor_metadata.cpp:262
# torch version: 2.7.0a0+git1335882
# cuda version: 12.8
# nvfuser version: 0.2.25+git6b0b17e
import torch
from nvfuser import FusionDefinition, DataType

def nvfuser_fusion_id0(fd : FusionDefinition) -> None :
    T0 = fd.define_tensor(shape=[2, 2], contiguity=[False, True], dtype=DataType.Float, is_cpu=False, stride_order=[1, 0])
    S1 = fd.define_scalar(0.00000, dtype=DataType.Double)
    T2 = fd.ops.gt(T0, S1)
    S3 = fd.define_scalar(0.00000, dtype=DataType.Double)
    T4 = fd.ops.where(T2, T0, S3)
    T5 = fd.ops.cast(T4, dtype=DataType.Float)
    T6 = fd.ops.set(T5)
    fd.add_output(T6, T0)
    fd.add_output(T6)

with FusionDefinition() as fd:
    nvfuser_fusion_id0(fd)

inputs = [
    torch.randn(5, dtype=torch.float32, device='cuda:0').as_strided((2, 2), (3, 1)),
]
fd.execute(inputs)
@IvanYashchuk
Copy link
Collaborator Author

Is the T0 definition correct for the given input?

@naoyam
Copy link
Collaborator

naoyam commented Feb 25, 2025

Looks like the contiguity vector gets modified somewhere:

contiguity: t, t;

@jjsjann123 Could you please take a look?

@jjsjann123 jjsjann123 self-assigned this Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants