#log-parser #pytorch #structured #env-var #compile #variables #trace

bin+lib tlparse

Parse TORCH_LOG logs produced by PyTorch torch.compile

30 releases

new 0.3.36 Mar 12, 2025
0.3.33 Jan 29, 2025
0.3.30 Dec 5, 2024
0.3.29 Nov 21, 2024
0.3.11 Mar 26, 2024

#168 in Machine learning

Download history 293/week @ 2024-11-20 101/week @ 2024-11-27 350/week @ 2024-12-04 190/week @ 2024-12-11 85/week @ 2024-12-18 31/week @ 2024-12-25 50/week @ 2025-01-01 39/week @ 2025-01-08 55/week @ 2025-01-15 381/week @ 2025-01-22 454/week @ 2025-01-29 129/week @ 2025-02-05 260/week @ 2025-02-12 269/week @ 2025-02-19 145/week @ 2025-02-26 183/week @ 2025-03-05

872 downloads per month

BSD-3-Clause

305KB
3K SLoC

Rust 3K SLoC // 0.0% comments JavaScript 355 SLoC // 0.2% comments

tlparse: Parse structured PT2 logs

tlparse parses structured torch trace logs and outputs HTML files analyzing data.

Quick start: Run PT2 with the TORCH_TRACE environment variable set:

TORCH_TRACE=/tmp/my_traced_log_dir example.py

Feed input into tlparse:

tlparse /tmp/my_traced_log_dir -o tl_out/

Adding custom parsers

You can extend tlparse with custom parsers which take existing structured log data and output any file. To do so, first implement StructuredLogParser with your own trait:

pub struct MyCustomParser;
impl StructuredLogParser for MyCustomParser {
    fn name(&self) -> &'static str {
        "my_custom_parser"
    }
    fn get_metadata<'e>(&self, e: &'e Envelope) -> Option<Metadata<'e>> {
        // Get required metadata from the Envelope.
        // You'll need to update Envelope with your custom Metadata if you need new types here
        ....
    }

    fn parse<'e>(&self,
        lineno: usize,
        metadata: Metadata<'e>,
        _rank: Option<u32>,
        compile_id: &Option<CompileId>,
        payload: &str
    ) -> anyhow::Result<ParserResult> {
       // Use the metadata and payload however you'd like
       // Return either a ParserOutput::File(filename, payload) or ParserOutput::Link(name, url)
    }
}

How to release

  1. Make a release commit by updating Cargo.toml and then running cargo update
  2. Push the release commit and a tag for it. This will trigger PyPI release
  3. cargo publish

Dependencies

~10–20MB
~257K SLoC