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

bin+lib tlparse

Parse TORCH_LOG logs produced by PyTorch torch.compile

27 releases

0.3.33 Jan 29, 2025
0.3.30 Dec 5, 2024
0.3.29 Nov 21, 2024
0.3.23 Jul 30, 2024
0.3.11 Mar 26, 2024

#166 in Machine learning

Download history 197/week @ 2024-10-20 151/week @ 2024-10-27 64/week @ 2024-11-03 110/week @ 2024-11-10 276/week @ 2024-11-17 123/week @ 2024-11-24 311/week @ 2024-12-01 225/week @ 2024-12-08 134/week @ 2024-12-15 41/week @ 2024-12-22 23/week @ 2024-12-29 47/week @ 2025-01-05 58/week @ 2025-01-12 149/week @ 2025-01-19 560/week @ 2025-01-26 230/week @ 2025-02-02

998 downloads per month

BSD-3-Clause

215KB
2.5K 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
~250K SLoC