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

🐛 [Bug] Encountered bug when using torch.split in dynamic shapes #3347

Open
yjjinjie opened this issue Jan 8, 2025 · 4 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@yjjinjie
Copy link

yjjinjie commented Jan 8, 2025

Bug Description

when I use the torch.split , it get the error: File "/opt/conda/lib/python3.11/site-packages/torch_tensorrt/dynamo/conversion/impl/split.py", line 37, in split
assert input.shape[dim] != -1, "Can't chunk on dynamic shape dimension!"

To Reproduce

Steps to reproduce the behavior:

import torch.nn as nn
import torch

from typing import Any, Callable, Dict, List, Optional, Tuple, Union


class Split(nn.Module):
    def forward(self, x:torch.Tensor,y:torch.Tensor):
        values = []
        values.append(x)
        values.append(y)
        length_per_key=[x.numel() for x in values]
        values=torch.cat(values, dim=-1)
        return torch.split(values,length_per_key)


a=torch.randn(66093).cuda()
b=torch.randn(50).cuda()

model = Split().cuda()
res = model(a,b)
print(res[0].shape)



batch = torch.export.Dim("batch",min=1,max=1000000)
batch2 = torch.export.Dim("batch2",min=1,max=1000000)

dynamic_shapes={"x":{0:batch},"y": {0:batch2}}

from torch.fx import symbolic_trace
model = symbolic_trace(model)
import torch_tensorrt
exp_program = torch.export.export(model, tuple([a,b]),dynamic_shapes=dynamic_shapes)
trt_gm = torch_tensorrt.dynamo.compile(exp_program, [a,b],min_block_size=1,allow_shape_tensors=True,assume_dynamic_shape_support=True)
# # # Run inference
print(trt_gm.code)

Expected behavior

Environment

Byte Order:                      Little Endian
CPU(s):                          104
On-line CPU(s) list:             0-103
Vendor ID:                       GenuineIntel
Model name:                      Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz
CPU family:                      6
Model:                           85
Thread(s) per core:              2
Core(s) per socket:              26
Socket(s):                       2
Stepping:                        7
CPU max MHz:                     3800.0000
CPU min MHz:                     1200.0000
BogoMIPS:                        5000.00
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
Virtualization:                  VT-x
L1d cache:                       1.6 MiB (52 instances)
L1i cache:                       1.6 MiB (52 instances)
L2 cache:                        52 MiB (52 instances)
L3 cache:                        71.5 MiB (2 instances)
NUMA node(s):                    1
NUMA node0 CPU(s):               0-103
Vulnerability Itlb multihit:     KVM: Mitigation: Split huge pages
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Enhanced IBRS, IBPB conditional, RSB filling
Vulnerability Tsx async abort:   Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.3
[pip3] nvidia-cublas-cu12==12.1.3.1
[pip3] nvidia-cuda-runtime-cu12==12.1.105
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-nccl-cu12==2.21.5
[pip3] torch==2.5.0+cu121
[pip3] torch_tensorrt==2.5.0
[pip3] torchmetrics==1.0.3
[pip3] torchrec==1.0.0+cu121
[pip3] triton==3.1.0
[conda] numpy                     1.26.3                   pypi_0    pypi
[conda] nvidia-cublas-cu12        12.1.3.1                 pypi_0    pypi
[conda] nvidia-cuda-runtime-cu12  12.1.105                 pypi_0    pypi
[conda] nvidia-cudnn-cu12         9.1.0.70                 pypi_0    pypi
[conda] nvidia-nccl-cu12          2.21.5                   pypi_0    pypi
[conda] torch                     2.5.0+cu121              pypi_0    pypi
[conda] torch-tensorrt            2.5.0               pypi_0    pypi
[conda] torchmetrics              1.0.3                    pypi_0    pypi
[conda] torchrec                  1.0.0+cu121              pypi_0    pypi
[conda] triton                    3.1.0                    pypi_0    pypi

Additional context

@yjjinjie yjjinjie added the bug Something isn't working label Jan 8, 2025
@yjjinjie
Copy link
Author

yjjinjie commented Jan 8, 2025

@apbose can you help me to solve this problem? my model has split the torch_executed_ops=["aten::split_with_sizes"] also cannot slove this problem

@yjjinjie
Copy link
Author

yjjinjie commented Jan 9, 2025

@apbose can you help me solve this problem

1 similar comment
@yjjinjie
Copy link
Author

@apbose can you help me solve this problem

@apbose apbose self-assigned this Jan 14, 2025
@apbose
Copy link
Collaborator

apbose commented Jan 14, 2025

Taking a look at this

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

No branches or pull requests

2 participants