mlc-ai / mlc-llm

Universal LLM Deployment Engine with ML Compilation
https://llm.mlc.ai/
Apache License 2.0
19.08k stars 1.56k forks source link

[Bug] Error when trying to compile rwkv-raven-3b model. #893

Closed scottorly closed 1 year ago

scottorly commented 1 year ago

🐛 Bug

Error when trying to compile rwkv-raven-3b model.

To Reproduce

Steps to reproduce the behavior:

  1. python3 -m mlc_llm.build --hf-path=RWKV/rwkv-raven-3b --target iphone --quantization q8f16_1
Target configured: metal -keys=metal,gpu -libs=iphoneos -max_function_args=31 -max_num_threads=256 -max_shared_memory_per_block=32768 -max_threads_per_block=256 -thread_warp_size=1
Host CPU dection:
  Target triple: arm64-apple-darwin23.0.0
  Process triple: arm64-apple-darwin23.0.0
  Host CPU: apple-m1
Automatically using target for weight quantization: metal -keys=metal,gpu -max_function_args=31 -max_num_threads=256 -max_shared_memory_per_block=32768 -max_threads_per_block=1024 -thread_warp_size=32
Compilation error:
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:10:1: error: expected parameter declarator
;
^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:10:1: error: expected ')'
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:8:28: note: to match this '('
kernel void encode_kernel_1(  device half* max_abs_value [[ buffer(0) ]],
                           ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:8:61: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
kernel void encode_kernel_1(  device half* max_abs_value [[ buffer(0) ]],
                                                            ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:9:25: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device half* scale [[ buffer(1) ]],
                        ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:13:1: error: expected parameter declarator
;
^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:13:1: error: expected ')'
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:11:27: note: to match this '('
kernel void encode3_kernel(  device half* A [[ buffer(0) ]],
                          ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:11:48: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
kernel void encode3_kernel(  device half* A [[ buffer(0) ]],
                                               ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:12:33: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device half* max_abs_value [[ buffer(1) ]],
                                ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:17:1: error: expected parameter declarator
;
^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:17:1: error: expected ')'
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:14:28: note: to match this '('
kernel void encode_kernel_2(  device half* A [[ buffer(0) ]],
                           ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:14:49: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
kernel void encode_kernel_2(  device half* A [[ buffer(0) ]],
                                                ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:15:25: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device half* scale [[ buffer(1) ]],
                        ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:16:30: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device uint* w_gathered [[ buffer(2) ]],
                             ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:20:1: error: expected parameter declarator
;
^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:20:1: error: expected ')'
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:18:29: note: to match this '('
kernel void encode1_kernel_1(  device half* max_abs_value [[ buffer(0) ]],
                            ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:18:62: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
kernel void encode1_kernel_1(  device half* max_abs_value [[ buffer(0) ]],
                                                             ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:19:25: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device half* scale [[ buffer(1) ]],
                        ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:23:1: error: expected parameter declarator
;
^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:23:1: error: expected ')'
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:21:27: note: to match this '('
kernel void encode1_kernel(  device half* A [[ buffer(0) ]],
                          ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:21:48: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
kernel void encode1_kernel(  device half* A [[ buffer(0) ]],
                                               ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:22:33: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device half* max_abs_value [[ buffer(1) ]],
                                ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:26:1: error: expected parameter declarator
;
^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:26:1: error: expected ')'
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:24:26: note: to match this '('
kernel void encode_kernel(  device half* A [[ buffer(0) ]],
                         ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:24:47: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
kernel void encode_kernel(  device half* A [[ buffer(0) ]],
                                              ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:25:33: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device half* max_abs_value [[ buffer(1) ]],
                                ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:29:1: error: expected parameter declarator
;
^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:29:1: error: expected ')'
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:27:29: note: to match this '('
kernel void encode2_kernel_1(  device half* max_abs_value [[ buffer(0) ]],
                            ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:27:62: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
kernel void encode2_kernel_1(  device half* max_abs_value [[ buffer(0) ]],
                                                             ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:28:25: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device half* scale [[ buffer(1) ]],
                        ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:33:1: error: expected parameter declarator
;
^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:33:1: error: expected ')'
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:30:29: note: to match this '('
kernel void encode1_kernel_2(  device half* A [[ buffer(0) ]],
                            ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:30:50: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
kernel void encode1_kernel_2(  device half* A [[ buffer(0) ]],
                                                 ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:31:25: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device half* scale [[ buffer(1) ]],
                        ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:32:30: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device uint* w_gathered [[ buffer(2) ]],
                             ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:37:1: error: expected parameter declarator
;
^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:37:1: error: expected ')'
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:34:29: note: to match this '('
kernel void encode2_kernel_2(  device half* A [[ buffer(0) ]],
                            ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:34:50: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
kernel void encode2_kernel_2(  device half* A [[ buffer(0) ]],
                                                 ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:35:25: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device half* scale [[ buffer(1) ]],
                        ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:36:30: warning: 'buffer' attribute ignored on function declaration [-Wignored-attributes]
  device uint* w_gathered [[ buffer(2) ]],
                             ^
/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.metal:40:1: error: expected parameter declarator
;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
21 warnings and 20 errors generated.
LLVM ERROR: Error opening '/var/folders/78/dqc2672d7nb8b5vp67c4n0n80000gn/T/tmpjmal_vsp/my_lib.air': No such file or directory!
Traceback (most recent call last):
  File "/opt/homebrew/anaconda3/envs/mlc-chat-venv/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/anaconda3/envs/mlc-chat-venv/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/scott/Developer/mlc-llm/mlc_llm/build.py", line 13, in <module>
    main()
  File "/Users/scott/Developer/mlc-llm/mlc_llm/build.py", line 10, in main
    core.build_model_from_args(parsed_args)
  File "/Users/scott/Developer/mlc-llm/mlc_llm/core.py", line 571, in build_model_from_args
    new_params = utils.convert_weights(param_manager, params, args)
  File "/Users/scott/Developer/mlc-llm/mlc_llm/utils.py", line 255, in convert_weights
    ex = relax.build(mod_transform, target=target)
  File "/opt/homebrew/anaconda3/envs/mlc-chat-venv/lib/python3.8/site-packages/tvm/relax/vm_build.py", line 338, in build
    return _vmlink(builder, target, tir_mod, ext_libs, params, system_lib=system_lib)
  File "/opt/homebrew/anaconda3/envs/mlc-chat-venv/lib/python3.8/site-packages/tvm/relax/vm_build.py", line 242, in _vmlink
    lib = tvm.build(
  File "/opt/homebrew/anaconda3/envs/mlc-chat-venv/lib/python3.8/site-packages/tvm/driver/build_module.py", line 281, in build
    rt_mod_host = _driver_ffi.tir_to_runtime(annotated_mods, target_host)
  File "tvm/_ffi/_cython/./packed_func.pxi", line 331, in tvm._ffi._cy3.core.PackedFuncBase.__call__
  File "tvm/_ffi/_cython/./packed_func.pxi", line 262, in tvm._ffi._cy3.core.FuncCall
  File "tvm/_ffi/_cython/./packed_func.pxi", line 251, in tvm._ffi._cy3.core.FuncCall3
  File "tvm/_ffi/_cython/./base.pxi", line 181, in tvm._ffi._cy3.core.CHECK_CALL
tvm.error.InternalError: Traceback (most recent call last):
  File "/Users/catalyst/Workspace/mlc-ai-package-self-runner/_work/package/package/tvm/include/tvm/runtime/packed_func.h", line 838
InternalError: Check failed: type_code_ == kTVMStr (4 vs. 11) : expected str but got NULL

Expected behavior

Environment

Hzfengsy commented 1 year ago

This PR https://github.com/apache/tvm/pull/15725 should fix the error. Waiting for the next sync with unity branch

scottorly commented 1 year ago

fix confirmed 🖖