Skip to content

Conversation

@LukeRouleau
Copy link

A simple addition to the codebase to add graph structure logging. From the README:

GGML GRAPH LOGGING FORK OF LLAMA.CPP

This fork includes a feature to log the computation graph of the model to a CSV file.

Graph Logging

To enable graph logging, set the environment variable GGML_LOG_GRAPH to 1 or true:

export GGML_LOG_GRAPH=1

By default, the graph will be written to ggml_graph.csv in the current working directory. You can specify a different filename using the GGML_LOG_GRAPH_FILENAME environment variable:

export GGML_LOG_GRAPH_FILENAME=/path/to/your/graph_log.csv

Important: When graph logging is enabled, the program will terminate immediately after writing the log file.

Output Format

The output CSV file contains the following columns for each node (tensor) in the graph:

  • node_id: The memory address of the tensor, serving as a unique ID.
  • name: The name assigned to the tensor (if any).
  • op: The GGML operation that produces this tensor.
  • dim0, dim1, dim2, dim3: The dimensions of the tensor.
  • bytes: The size of the tensor data in bytes.
  • flags: Tensor flags (e.g., PARAM, INPUT, OUTPUT, LEAF).
  • src0...srcN: The node_id (memory address) of the source tensors for this node, up to GGML_MAX_SRC.

luker added 2 commits April 17, 2025 18:10
This commit introduces a new feature to log the computation graph of the model to a CSV file. The logging can be enabled by setting the environment variable `GGML_LOG_GRAPH` to `1` or `true`. The output file can be customized using `GGML_LOG_GRAPH_FILENAME`. The CSV includes details such as node IDs, names, operations, dimensions, sizes, and flags for each tensor in the graph. The program will terminate after logging the graph.

Additionally, the necessary header and source files for graph logging have been added, and the logging function is called after building the model graph.
@github-actions github-actions bot added the ggml changes relating to the ggml tensor library for machine learning label Apr 20, 2025
@LukeRouleau LukeRouleau deleted the luro/tensor_usage_logging branch April 20, 2025 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant