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

[Question] print value to debug in relax ir #3075

Open
XJY990705 opened this issue Dec 23, 2024 · 2 comments
Open

[Question] print value to debug in relax ir #3075

XJY990705 opened this issue Dec 23, 2024 · 2 comments
Labels
question Question about the usage

Comments

@XJY990705
Copy link

XJY990705 commented Dec 23, 2024

❓ General Questions

I want to print kv cache value for debug, and I noticed T.evaluate function can help me print some message as below

`
@T.prim_func
def test_evaluate(var_a: T.handle, var_b: T.handle):
T.func_attr({"global_symbol": "test_evaluate", "tir.noalias": T.bool(True)})
n = T.int32()
a = T.match_buffer(var_a, (n,), "float32")
b = T.match_buffer(var_b, (n,), "float32")

  T.evaluate(T.call_packed("tvm.contrib.debugger.debug_print", a, "a"))
  T.evaluate(T.call_packed("tvm.contrib.debugger.debug_print", b, "b"))

  T.evaluate(T.call_packed("tvm.contrib.debugger.debug_print", a.shape[0], "a shape[0]"))
  T.evaluate(T.call_packed("tvm.contrib.debugger.debug_print", a.dtype, "a dtype"))
  T.evaluate(T.call_packed("tvm.contrib.debugger.debug_print", b.shape[0], "b shape[0]"))
  T.evaluate(T.call_packed("tvm.contrib.debugger.debug_print", b.dtype, "b dtype"))

  for i in T.serial(n):
      b[i] = a[i] + 1.0

`

this test code can print message if I run it alone, but when I use T.evaluate(T.call_packed("tvm.contrib.debugger.debug_print", a, "a")) in python/mlc_llm/nn/kv_cache.py _kv_cache_transpose_append(kv_cache_config: BaseKVConfig) function, after compliation and running, there is no print message. Is there some pipeline delete this line after compilation? If so, how can I modify python/mlc_llm/compiler_pass to allow these message?

@XJY990705 XJY990705 added the question Question about the usage label Dec 23, 2024
@MasterJH5574
Copy link
Member

MasterJH5574 commented Jan 5, 2025

Hi @XJY990705 thank you for asking this. First, may I ask if your local MLC is the latest? The function _kv_cache_transpose_append was moved to python/tvm/relax/frontend/nn/llm/kv_cache.py in TVM source code a while ago for some reason. Besides, I couldn't find BaseKVConfig in the source code, so would you mind pointing to me which _kv_cache_transpose_append(kv_cache_config: BaseKVConfig) you are referring to?

Ideally no changes in compiler_pass is needed I think. So if you can share some more information that would be very helpful.

@XJY990705
Copy link
Author

I tried more times and I found it concerned with some temp files, I deleted those temp files and compiled mlc again, and it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about the usage
Projects
None yet
Development

No branches or pull requests

2 participants