Skip to content

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

Closed
@XJY990705

Description

@XJY990705

❓ 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about the usage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions