From 846a2826ab4bc00056a366b0dcbd5df17047e016 Mon Sep 17 00:00:00 2001 From: qazal <77887910+Qazalin@users.noreply.github.com> Date: Tue, 5 Aug 2025 05:00:03 +0800 Subject: [PATCH] viz: remove TracingKey.fmt (#11482) * viz: remove TracingKey.fmt * remove from test too --- test/unit/test_viz.py | 3 +-- tinygrad/engine/realize.py | 2 +- tinygrad/helpers.py | 1 - tinygrad/viz/serve.py | 7 +++++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/unit/test_viz.py b/test/unit/test_viz.py index e6a4ddefd6..a8e2f44c94 100644 --- a/test/unit/test_viz.py +++ b/test/unit/test_viz.py @@ -106,13 +106,12 @@ class TestViz(BaseTestViz): # name can also come from a function that returns a TracingKey def test_tracing_key(self): - @track_rewrites(name=lambda inp,ret: TracingKey("custom_name", (inp,), fmt=f"input={inp.render()}")) + @track_rewrites(name=lambda inp,ret: TracingKey("custom_name", (inp,))) def test(s:UOp): return graph_rewrite(s, PatternMatcher([])) test(UOp.variable("a", 1, 10)+1) lst = get_viz_list() # NOTE: names from TracingKey do not get deduped self.assertEqual(lst[0]["name"], "custom_name") - self.assertEqual(lst[0]["fmt"], "input=(a+1)") def test_colored_label(self): # NOTE: dataclass repr prints literal escape codes instead of unicode chars diff --git a/tinygrad/engine/realize.py b/tinygrad/engine/realize.py index 111676d2d0..f4cd06c5bf 100644 --- a/tinygrad/engine/realize.py +++ b/tinygrad/engine/realize.py @@ -13,7 +13,7 @@ from tinygrad.uop.spec import type_verify # **************** Program Creation **************** -@track_rewrites(name=lambda _ast,_renderer,ret: TracingKey(ret.name, (ret.function_name, ret.ast), ret.src, ret=ret)) +@track_rewrites(name=lambda _ast,_renderer,ret: TracingKey(ret.name, (ret.function_name, ret.ast), ret=ret)) def get_program(ast:UOp, renderer:Renderer) -> ProgramSpec: """ Transform an AST into a ProgramSpec. May trigger BEAM search. diff --git a/tinygrad/helpers.py b/tinygrad/helpers.py index 34306e22ac..90914c7d22 100644 --- a/tinygrad/helpers.py +++ b/tinygrad/helpers.py @@ -196,7 +196,6 @@ class Profiling(contextlib.ContextDecorator): class TracingKey: display_name:str # display name of this trace event keys:tuple[str, ...]=() # optional keys to search for related traces - fmt:str|None=None # optional detailed formatting cat:str|None=None # optional category to color this by ret:Any=None diff --git a/tinygrad/viz/serve.py b/tinygrad/viz/serve.py index c4f4a0cbb1..e9a0b11a18 100755 --- a/tinygrad/viz/serve.py +++ b/tinygrad/viz/serve.py @@ -30,10 +30,13 @@ def get_metadata(keys:list[TracingKey], contexts:list[list[TrackedGraphRewrite]] for i,(k,v) in enumerate(zip(keys, contexts)): steps = [{"name":s.name, "loc":s.loc, "depth":s.depth, "match_count":len(s.matches), "code_line":printable(s.loc), "query":f"/ctxs?ctx={i}&idx={j}"} for j,s in enumerate(v)] - if isinstance(k.ret, ProgramSpec): steps.append({"name":"View Disassembly", "query":f"/disasm?ctx={i}"}) - ret.append(r:={"name":k.display_name, "fmt":k.fmt, "steps":steps}) + ret.append(r:={"name":k.display_name, "steps":steps}) # use the first key to get runtime profiling data about this context if getenv("PROFILE_VALUE") >= 2 and k.keys: r["runtime_stats"] = get_runtime_stats(k.keys[0]) + # program spec metadata + if isinstance(k.ret, ProgramSpec): + steps.append({"name":"View Disassembly", "query":f"/disasm?ctx={i}"}) + r["fmt"] = k.ret.src for key in k.keys: ref_map[key] = i return ret