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

ResNet50 compile failed #1117

Open
littletomatodonkey opened this issue Oct 4, 2024 · 0 comments
Open

ResNet50 compile failed #1117

littletomatodonkey opened this issue Oct 4, 2024 · 0 comments

Comments

@littletomatodonkey
Copy link

Hi, something wrong when i run resnet50 with onediff, could you please help to have a look? Thanks !

  • code
    import time
    import torch
    import torch.nn as nn
    import torch_tensorrt
    import torchvision.models as models
    model = models.resnet18(pretrained=True).eval().to("cuda").half()
    input_ = torch.randn((1, 3, 224, 224)).to("cuda").half()
    from onediff.infer_compiler import compile
    options = '{"mode": "O3"}'
    onediff_model = compile(model, backend="nexfort", options=options)
    y = onediff_model(input_)
  • The following error occurs
E1004 10:16:18.625517 139940834625344 torch/_inductor/runtime/triton_heuristics.py:433] [0/0]             ^
Traceback (most recent call last):
  File "/mnt/bn/multimodel/code/model_infer_scripts/trt10.1/torch2trt_demo.py", line 66, in <module>
    test_resnet_with_onediff()
  File "/mnt/bn/multimodel/code/model_infer_scripts/trt10.1/torch2trt_demo.py", line 59, in test_resnet_with_onediff
    onediff_time = benchmark_model(onediff_model, input_)
  File "/mnt/bn/multimodel/code/model_infer_scripts/trt10.1/torch2trt_demo.py", line 28, in benchmark_model
    run_one_iteration(model, *inputs)
  File "/mnt/bn/multimodel/code/model_infer_scripts/trt10.1/torch2trt_demo.py", line 22, in run_one_iteration
    y = model(*inputs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/onediff/infer_compiler/backends/nexfort/deployable_module.py", line 27, in forward
    return self._deployable_module_model(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 433, in _fn
    return fn(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1116, in __call__
    return self._torchdynamo_orig_callable(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 948, in __call__
    result = self._inner_convert(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 472, in __call__
    return _compile(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_utils_internal.py", line 84, in wrapper_function
    return StrobelightCompileTimeProfiler.profile_compile_time(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_strobelight/compile_time_profiler.py", line 129, in profile_compile_time
    return func(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 817, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 636, in compile_inner
    out_code = transform_code_object(code, transform)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1185, in transform_code_object
    transformations(instructions, code_options)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 178, in _fn
    return fn(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 582, in transform
    tracer.run()
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2451, in run
    super().run()
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 893, in run
    while self.step():
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 805, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2642, in RETURN_VALUE
    self._return(inst)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2627, in _return
    self.output.compile_subgraph(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 1098, in compile_subgraph
    self.compile_and_call_fx_graph(tx, list(reversed(stack_values)), root)
  File "/opt/tiger/miniconda3/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 1318, in compile_and_call_fx_graph
    compiled_fn = self.call_user_compiler(gm)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 1409, in call_user_compiler
    raise BackendCompilerFailed(self.compiler_fn, e).with_traceback(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 1390, in call_user_compiler
    compiled_fn = compiler_fn(gm, self.example_inputs())
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/repro/after_dynamo.py", line 129, in __call__
    compiled_gm = compiler_fn(gm, example_inputs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/__init__.py", line 1990, in __call__
    return self.compiler_fn(model_, inputs_, **self.kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/nexfort/dynamo/backends/nexfort.py", line 34, in nexfort
    out = compile_fx(gm, example_inputs, mode=mode, options=options)
  File "src/nexfort/fx_compiler/fx_compiler.py", line 40, in nexfort.fx_compiler.fx_compiler.compile_fx
  File "src/nexfort/fx_compiler/fx_compiler.py", line 50, in nexfort.fx_compiler.fx_compiler.compile_fx
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/nexfort/utils/cost.py", line 25, in clocked
    return func(*args, **kwargs)
  File "src/nexfort/fx_compiler/fx_compiler.py", line 140, in nexfort.fx_compiler.fx_compiler.compile_fx_inner
  File "src/nexfort/fx_compiler/fx_compiler.py", line 140, in nexfort.fx_compiler.fx_compiler.compile_fx_inner
  File "src/nexfort/fx_compiler/fx_compiler.py", line 167, in nexfort.fx_compiler.fx_compiler.compile_fx_inner
  File "src/nexfort/fx_compiler/overrides.py", line 73, in nexfort.fx_compiler.overrides.with_override_torch_env.decorator.wrapper
  File "src/nexfort/fx_compiler/overrides.py", line 74, in nexfort.fx_compiler.overrides.with_override_torch_env.decorator.wrapper
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/nexfort/utils/cost.py", line 25, in clocked
    return func(*args, **kwargs)
  File "src/nexfort/fx_compiler/fx_compiler.py", line 186, in nexfort.fx_compiler.fx_compiler.fx_compile
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/nexfort/utils/cost.py", line 25, in clocked
    return func(*args, **kwargs)
  File "src/nexfort/fx_compiler/fx_compiler.py", line 203, in nexfort.fx_compiler.fx_compiler.gm_compile
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/nexfort/utils/cost.py", line 25, in clocked
    return func(*args, **kwargs)
  File "src/nexfort/fx_compiler/fx_compiler.py", line 256, in nexfort.fx_compiler.fx_compiler.with_inductor
  File "src/nexfort/fx_compiler/fx_compiler.py", line 264, in nexfort.fx_compiler.fx_compiler.with_inductor
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/__init__.py", line 1951, in __call__
    return compile_fx(model_, inputs_, config_patches=self.config)
  File "/opt/tiger/miniconda3/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 1505, in compile_fx
    return aot_autograd(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/backends/common.py", line 69, in __call__
    cg = aot_module_simplified(gm, example_inputs, **self.kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 954, in aot_module_simplified
    compiled_fn, _ = create_aot_dispatcher_function(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 687, in create_aot_dispatcher_function
    compiled_fn, fw_metadata = compiler_fn(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py", line 461, in aot_dispatch_autograd
    compiled_fw_func = aot_config.fw_compiler(fw_module, adjusted_flat_args)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 1410, in fw_compiler_base
    return inner_compile(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/repro/after_aot.py", line 84, in debug_wrapper
    inner_compiled_fn = compiler_fn(gm, example_inputs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/debug.py", line 304, in inner
    return fn(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/opt/tiger/miniconda3/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 527, in compile_fx_inner
    compiled_graph = fx_codegen_and_compile(
  File "/opt/tiger/miniconda3/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 831, in fx_codegen_and_compile
    compiled_fn = graph.compile_to_fn()
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/graph.py", line 1751, in compile_to_fn
    return self.compile_to_module().call
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/graph.py", line 1701, in compile_to_module
    mod = PyCodeCache.load_by_key_path(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/codecache.py", line 3073, in load_by_key_path
    mod = _reload_python_module(key, path)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/runtime/compile_tasks.py", line 45, in _reload_python_module
    exec(code, mod.__dict__, mod.__dict__)
  File "/tmp/torchinductor_tiger/dp/cdpsfzkzmnlyvvgohzf32kfayb6ms6n27lztn6tobqcpiennb4zo.py", line 119, in <module>
    triton_poi_fused__native_batch_norm_legit_no_training_relu_2 = async_compile.triton('triton_poi_fused__native_batch_norm_legit_no_training_relu_2', '''
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/async_compile.py", line 183, in triton
    kernel.precompile()
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/runtime/triton_heuristics.py", line 232, in precompile
    compiled_binary, launcher = self._precompile_config(
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/torch/_inductor/runtime/triton_heuristics.py", line 431, in _precompile_config
    binary = triton.compile(*compile_args, **compile_kwargs)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/triton/compiler/compiler.py", line 276, in compile
    module = src.make_ir(options, codegen_fns, context)
  File "/opt/tiger/miniconda3/lib/python3.10/site-packages/triton/compiler/compiler.py", line 113, in make_ir
    return ast_to_ttir(self.fn, self, context=context, options=options, codegen_fns=codegen_fns)
torch._dynamo.exc.BackendCompilerFailed: backend='nexfort' raised:
CompilationError: at 31:12:
    tmp10 = tl.full([1], 1, tl.int32)
    tmp11 = tmp10 / tmp9
    tmp12 = 1.0
    tmp13 = tmp11 * tmp12
    tmp14 = tmp4 * tmp13
    tmp16 = tmp15.to(tl.float32)
    tmp17 = tmp14 * tmp16
    tmp19 = tmp18.to(tl.float32)
    tmp20 = tmp17 + tmp19
    tmp21 = tmp20.to(tl.float32)
    tmp22 = tl.full([1], 0, tl.int32)
    tmp23 = nexfort_triton_helpers.maximum_ftz(tmp22, tmp21)
  • requirements as follows.
pip install onediff==1.2.0 nexfort torch==2.4.1 torchvision==0.19.1
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

1 participant