It's advisable to create a virtual environment using Python 3.10.2.
# Create a virtual environment
$ python3 -m venv chakra_env
# Activate the virtual environment
$ source chakra_env/bin/activate
With the virtual environment activated, install the Chakra package using pip.
# Install package from source
$ pip install .
# Install latest from GitHub
$ pip install https://github.com/mlcommons/chakra/archive/refs/heads/main.zip
# Install specific revision from GitHub
$ pip install https://github.com/mlcommons/chakra/archive/ae7c671db702eb1384015bb2618dc753eed787f2.zip
Installing PARAM is necessary for Chakra to function properly as it imports essential components from it.
$ git clone git@github.com:facebookresearch/param.git
$ cd param/train/compute/python/
$ git checkout c83ce8429110a86549c40fec5a01acbd9fbd54a4
$ pip install .
To uninstall Chakra, use the following command within the virtual environment.
$ pip uninstall chakra
Merge PyTorch Chakra host trace and Kineto trace to encode GPU operators into the output execution trace.
$ chakra_trace_link \
--pytorch-et-file /path/to/pytorch_et \
--kineto-file /path/to/kineto \
--output-file /path/to/merged_et
Converts the merged execution traces into the Chakra schema.
$ chakra_converter \
--input_filename /path/to/merged_et \
--output_filename /path/to/chakra_et \
--input_type <input_type>
The Execution Trace Feeder (et_feeder) is a C++ library designed to feed Chakra traces into any compatible C++ simulator. This library specifically provides dependency-free nodes to a simulator, which must import the feeder as a library. Currently, ASTRA-sim is the only simulator that supports this trace feeder. Below are the commands to run execution traces on ASTRA-sim:
$ git clone --recurse-submodules git@github.com:astra-sim/astra-sim.git
$ cd astra-sim
$ git checkout Chakra
$ git submodule update --init --recursive
$ cd extern/graph_frontend/chakra/
$ git checkout main
$ cd -
$ ./build/astra_analytical/build.sh -c
$ cd extern/graph_frontend/chakra/
$ python -m chakra.et_generator.et_generator\
--num_npus <num_npus>
$ cd -
$ ./run.sh
This tool visualizes execution traces in various formats. Here is an example command:
$ chakra_visualizer \
--input_filename /path/to/chakra_et
--output_filename /path/to/output.[graphml|pdf|dot]
Provides a readable JSON format of execution traces:
$ chakra_jsonizer \
--input_filename /path/to/chakra_et \
--output_filename /path/to/output_json
Visualizes the execution timeline of traces. This tool serves as a reference implementation for visualizing the simulation of Chakra traces. After simulating Chakra traces, you can visualize the timeline of operator executions. Update the simulator to present when operators are issued and completed. Below is the format needed:
issue,<dummy_str>=npu_id,<dummy_str>=curr_cycle,<dummy_str>=node_id,<dummy_str>=node_name
callback,<dummy_str>=npu_id,<dummy_str>=curr_cycle,<dummy_str>=node_id,<dummy_str>=node_name
...
You can visualize the timeline with the command below.
$ chakra_timeline_visualizer \
--input_filename /path/to/input.csv \
--output_filename /path/to/output.json \
--num_npus 4 \
--npu_frequency 1.5GHz
When you open the output file with chrome://tracing
, you will see an execution timeline like the one below.