Skip to content

Fix reading rocm-activity-profile for rocm>7 format#181

Open
michaelmckinsey1 wants to merge 2 commits intollnl:developfrom
michaelmckinsey1:michaelmckinsey1-patch-1
Open

Fix reading rocm-activity-profile for rocm>7 format#181
michaelmckinsey1 wants to merge 2 commits intollnl:developfrom
michaelmckinsey1:michaelmckinsey1-patch-1

Conversation

@michaelmckinsey1
Copy link
Copy Markdown
Collaborator

@michaelmckinsey1 michaelmckinsey1 commented Apr 3, 2026

Fixes an error when reading rocm-activity-profile files, of the form:

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Cell In[6], line 3
      1 tks = []
      2 for f in glob(dir_of_cali_files, recursive=True):
----> 3     tk_roofline = tt.Thicket.from_caliperreader(f)
      5     # Fix for duplicate cali idx
      6     tk_roofline.dataframe = tk_roofline.dataframe[tk_roofline.dataframe["time (gpu)"] != 0].reset_index(level="rank", drop=True)

File /usr/workspace/mckinsey/data-driven/venv/lib/python3.11/site-packages/thicket/thicket.py:459, in Thicket.from_caliperreader(filename_or_caliperreader, intersection, fill_perfdata, disable_tqdm, node_ordering, **kwargs)
    440 @staticmethod
    441 def from_caliperreader(
    442     filename_or_caliperreader,
   (...)    447     **kwargs,
    448 ):
    449     """Helper function to read one caliper file.
    450 
    451     Arguments:
   (...)    457         node_ordering (bool): whether to apply node ordering to the graph
    458     """
--> 459     return Thicket.reader_dispatch(
    460         GraphFrame.from_caliperreader,
    461         intersection,
    462         fill_perfdata,
    463         disable_tqdm,
    464         filename_or_caliperreader,
    465         node_ordering=node_ordering,
    466         **kwargs,
    467     )

File /usr/workspace/mckinsey/data-driven/venv/lib/python3.11/site-packages/thicket/thicket.py:609, in Thicket.reader_dispatch(func, intersection, fill_perfdata, disable_tqdm, *args, **kwargs)
    607 # if single file
    608 elif os.path.isfile(obj):
--> 609     return Thicket.thicketize_graphframe(func(*args, **kwargs), args[0])
    611 # Perform ensembling operation
    612 calltree = "union"

File /usr/workspace/mckinsey/data-driven/venv/lib/python3.11/site-packages/hatchet/graphframe.py:222, in GraphFrame.from_caliperreader(filename_or_caliperreader, native, string_attributes, node_ordering)
    217 # import this lazily to avoid circular dependencies
    218 from .readers.caliper_native_reader import CaliperNativeReader
    220 return CaliperNativeReader(
    221     filename_or_caliperreader, native, string_attributes, node_ordering
--> 222 ).read()

File /usr/workspace/mckinsey/data-driven/venv/lib/python3.11/site-packages/hatchet/readers/caliper_native_reader.py:470, in CaliperNativeReader.read(self)
    467         self.filename_or_caliperreader.read(cali_file)
    469 with self.timer.phase("graph construction"):
--> 470     list_roots = self.create_graph()
    471 self.df_nodes = pd.DataFrame(data=list(self.idx_to_node.values()))
    473 # create a graph object once all the nodes have been added

File /usr/workspace/mckinsey/data-driven/venv/lib/python3.11/site-packages/hatchet/readers/caliper_native_reader.py:348, in CaliperNativeReader.create_graph(self, ctx)
    345     parent_callpath = node_callpath[:-1]
    346     node_type = "function"
--> 348 hnode = self.callpath_to_node.get(node_callpath)
    350 if not hnode:
    351     # set the _hatchet_nid by the node order column if it exists, else -1
    352     if (
    353         self.node_ordering
    354         and "min#min#aggregate.slot" in record
    355     ):

UnboundLocalError: cannot access local variable 'node_callpath' where it is not associated with a value

@michaelmckinsey1 michaelmckinsey1 self-assigned this Apr 3, 2026
@michaelmckinsey1 michaelmckinsey1 changed the title Update caliper_native_reader.py Fix reading rocm-activity-profile for rocm>7 format Apr 3, 2026
@michaelmckinsey1 michaelmckinsey1 added the status-ready-for-review This PR is ready to be reviewed by assigned reviewers label Apr 3, 2026
@slabasan
Copy link
Copy Markdown
Collaborator

slabasan commented Apr 7, 2026

Should we expect to handle both rocm>7 and rocm <=7?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status-ready-for-review This PR is ready to be reviewed by assigned reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants