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

bin+lib tlparse

Parse TORCH_LOG logs produced by PyTorch torch.compile

22 releases

new 0.3.28 Oct 15, 2024
0.3.25 Aug 7, 2024
0.3.23 Jul 30, 2024
0.3.11 Mar 26, 2024

#129 in Machine learning

Download history 159/week @ 2024-06-29 133/week @ 2024-07-06 224/week @ 2024-07-13 112/week @ 2024-07-20 223/week @ 2024-07-27 311/week @ 2024-08-03 124/week @ 2024-08-10 136/week @ 2024-08-17 172/week @ 2024-08-24 69/week @ 2024-08-31 94/week @ 2024-09-07 137/week @ 2024-09-14 158/week @ 2024-09-21 370/week @ 2024-09-28 185/week @ 2024-10-05 586/week @ 2024-10-12

1,317 downloads per month

BSD-3-Clause

145KB
2K SLoC

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 example.py

Feed input into tlparse:

tlparse /tmp/my_traced_log -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
~255K SLoC