<?xml version="1.0" encoding="utf-8" standalone="yes"?><?xml-stylesheet href="/feed.css?v=208f42b55cff" type="text/css"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:site="https://lalitm.com/feed/ns#"><channel><title>Lalit Maganti (Tag: Pytorch)</title><link>https://lalitm.com/tags/pytorch/</link><description>Recent content tagged Pytorch on Lalit Maganti</description><site:notice>This is a feed.
Feeds let you subscribe to updates from this site using a feed reader. Copy this page's URL from your address bar and paste it into your reader.
New to feeds? Read: https://aboutfeeds.com</site:notice><docs>https://aboutfeeds.com</docs><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Fri, 03 Jul 2026 00:23:00 +0100</lastBuildDate><atom:link href="https://lalitm.com/tags/pytorch/index.xml" rel="self" type="application/rss+xml"/><item><title>Perfetto v57: fixing PyTorch traces, plus journald logs and an AI skill</title><link>https://lalitm.com/post/perfetto-v57/</link><pubDate>Fri, 03 Jul 2026 00:23:00 +0100</pubDate><guid>https://lalitm.com/post/perfetto-v57/</guid><description>We just released Perfetto v57 and I wanted to share the new things I’m most excited about. This is something I wanted to do for past releases but I just never quite got round to it. It’s also something I plan on doing more of going forward: there might even be dedicated pieces if I think the feature deserves it!
PyTorch traces reliably work!# What I’m most excited about in this release isn’t a feature but a bugfix. If you used the PyTorch profiler and opened the resulting trace in Perfetto, there was a decent chance some of your events would just not show up; specifically this would happen when these events overlapped each other on a single track.
Technically, PyTorch is in the wrong here. The Chrome Trace Event (JSON) format says duration events on a track have to nest and can’t overlap; if you need overlap, you’re supposed to use async events. chrome://tracing appears to handle them, but its rendering is actually buggy as soon as a trace has real overlaps; people just learned to live with it. So when a bug came in January about overlapping events being broken, I closed it as working-as-intended because I couldn’t see any easy fix from our end.</description><content:encoded>&lt;p&gt;We just
&lt;a href="https://github.com/google/perfetto/releases/tag/v57.1"&gt;released Perfetto v57&lt;/a&gt;
and I wanted to share the new things I&amp;rsquo;m most excited about. This is something I
wanted to do for past releases but I just never quite got round to it. It&amp;rsquo;s also
something I plan on doing more of going forward: there might even be dedicated
pieces if I think the feature deserves it!&lt;/p&gt;
&lt;h2 id="pytorch-traces-reliably-work"&gt;PyTorch traces reliably work!&lt;a class="heading-anchor" href="#pytorch-traces-reliably-work" aria-label="Permalink to PyTorch traces reliably work!"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;What I&amp;rsquo;m most excited about in this release isn&amp;rsquo;t a feature but a bugfix. If you
used the
&lt;a href="https://docs.pytorch.org/tutorials/recipes/recipes/profiler_recipe.html"&gt;PyTorch profiler&lt;/a&gt;
and opened the resulting trace in Perfetto, there was a decent chance some of
your events would just not show up; specifically this would happen when these
events overlapped each other on a single track.&lt;/p&gt;
&lt;p&gt;Technically, PyTorch is in the wrong here. The Chrome Trace Event (JSON) format
says duration events on a track have to nest and can&amp;rsquo;t overlap; if you need
overlap, you&amp;rsquo;re supposed to use async events. &lt;code&gt;chrome://tracing&lt;/code&gt; appears to
handle them, but its rendering is actually buggy as soon as a trace has real
overlaps; people just learned to live with it. So when a
&lt;a href="https://github.com/google/perfetto/issues/4280"&gt;bug&lt;/a&gt; came in January about
overlapping events being broken, I closed it as working-as-intended because I
couldn&amp;rsquo;t see any easy fix from our end.&lt;/p&gt;
&lt;p&gt;Then over time, I realized it wasn&amp;rsquo;t just one person with a weird trace. The bug
had affected many different PyTorch traces, and even
&lt;a href="https://github.com/google/perfetto/issues/6277"&gt;JAX traces&lt;/a&gt;. I even discovered
that people were maintaining forks and hosting old versions of Perfetto just to
deal with this issue. This is basically
&lt;a href="https://www.hyrumslaw.com/"&gt;Hyrum&amp;rsquo;s Law&lt;/a&gt;: it doesn&amp;rsquo;t much matter what the spec
says, once enough people rely on some behaviour, that behaviour is your
contract.&lt;/p&gt;
&lt;p&gt;This is also a very similar situation to what I discussed in
&lt;a href="https://lalitm.com/perfetto-oss-company-prio/"&gt;Perfetto and open source&lt;/a&gt;: it
was genuinely hard for me to tell just how many people it was affecting at the
beginning: if I had understood, I would have dealt with this very differently.&lt;/p&gt;
&lt;p&gt;In any case, in v57, Perfetto now imports the overlapping events instead of
dropping them, overflowing the extras onto a different line in the same UI
track. I do have to credit &lt;a href="https://github.com/i-komarov"&gt;@i_komarov&lt;/a&gt; who helped
me understand how big this issue was and to converge on the fix.&lt;/p&gt;
&lt;h2 id="recording-systemd-journald-logs"&gt;Recording systemd journald logs&lt;a class="heading-anchor" href="#recording-systemd-journald-logs" aria-label="Permalink to Recording systemd journald logs"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Perfetto has always tried to give you as much context as possible about what the
system is doing and put it all on a single timeline. One missing piece of that
on Linux has been in logs from journald; there&amp;rsquo;s a ton of useful information
there but until now it was hard to correlate that with e.g. scheduling or other
app level information.&lt;/p&gt;
&lt;p&gt;With v57, there&amp;rsquo;s now a &lt;code&gt;linux.systemd_journald&lt;/code&gt; data source that records
journald entries straight into the trace, on the same timeline as everything
else. You can filter by minimum syslog priority, by &lt;code&gt;SYSLOG_IDENTIFIER&lt;/code&gt;, or by
systemd unit, so you are not pulling in the entire journal when you only care
about one service.&lt;/p&gt;
&lt;p&gt;To show it in action, here&amp;rsquo;s
&lt;a href="https://ui.perfetto.dev/#!/?url=https://lalitm.com/traces/journald-demo.pftrace"&gt;a trace I recorded on my own machine&lt;/a&gt;.
Alongside a few log lines I generated myself, it happened to capture a real
udisks SMART error that fired while I was recording; exactly the kind of thing
you&amp;rsquo;d otherwise miss.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://lalitm.com/img/perfetto-v57/journald-logs.png" alt="Journald logs on the Perfetto timeline, with the log panel showing the captured entries including a udisks SMART error"&gt;&lt;/p&gt;
&lt;p&gt;I have to shout out &lt;a href="https://github.com/staticfloat"&gt;@staticfloat&lt;/a&gt; who
contributed this feature; thanks a lot for doing this!&lt;/p&gt;
&lt;h2 id="an-ai-skill-for-recording-and-analysis"&gt;An AI skill for recording and analysis&lt;a class="heading-anchor" href="#an-ai-skill-for-recording-and-analysis" aria-label="Permalink to An AI skill for recording and analysis"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;For a while now, people have been building their own AI tooling around Perfetto.
&lt;a href="https://github.com/Gracker/SmartPerfetto"&gt;SmartPerfetto&lt;/a&gt; and
&lt;a href="https://github.com/antarikshc/perfetto-mcp"&gt;perfetto-mcp&lt;/a&gt; are two public
examples I&amp;rsquo;ve come across but many teams inside Google have built their versions
of these which each handle a subset of Perfetto&amp;rsquo;s functionality. To us, this is
a sign that there&amp;rsquo;s demand out there to build something upstream so that
everyone can benefit.&lt;/p&gt;
&lt;p&gt;v57 includes an installable AI skill that works with Claude Code, Codex, Pi,
Opencode, Antigravity, and anything else that speaks the Agent Skills format. It
explains to the agent how to record traces (Android only for now!) and then
query them. It also includes dedicated workflows for debugging Android memory, a
specific area of focus for us; we plan on expanding these workflows over time
including to Linux.&lt;/p&gt;
&lt;p&gt;The skill is just one piece of a much larger AI plan, which I wrote up as
&lt;a href="https://github.com/google/perfetto/discussions/5763"&gt;an RFC&lt;/a&gt;. We will be doing
much more in this space in the coming months.&lt;/p&gt;
&lt;h2 id="state-tracks"&gt;State tracks&lt;a class="heading-anchor" href="#state-tracks" aria-label="Permalink to State tracks"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;State tracks are a new kind of primitive in Perfetto, sitting alongside slices
and counters. They represent something that is always in exactly one state: a
connection that is open or closed, a device that is on or off, a worker that is
idle or busy. You could already model this with slices, by emitting a slice that
starts when a state begins and ends when it changes. This works but you have to
be careful to emit events &lt;em&gt;exactly&lt;/em&gt; at the same timestamps or you end up having
gaps.&lt;/p&gt;
&lt;p&gt;With a state track you don&amp;rsquo;t emit start and end events at all. At each point
where the state changes, you emit one event that says what the state is now. The
previous state ends automatically. Clearing the track marks it idle. This just
makes it a lot simpler to manage.&lt;/p&gt;
&lt;p&gt;While the simpler emission model is the obvious win, the reason we made it a
first-class primitive goes further than that. Because a state track holds
exactly one value at any moment, it can never overlap itself, and the trace
processor can lean on that guarantee to treat it specially. You can attach
arguments that change as the state does. And in ring-buffer traces, where old
events get overwritten as the buffer wraps, you can periodically re-emit the
current state, so a trace that starts mid-stream still knows what state
everything is in.&lt;/p&gt;
&lt;p&gt;State tracks are still quite new so there are likely to be some rough edges
here, but we think they&amp;rsquo;ll become an important primitive: because they&amp;rsquo;re
guaranteed never to overlap, you can do things with them you simply couldn&amp;rsquo;t
before.&lt;/p&gt;
&lt;h2 id="querying-traces-over-https"&gt;Querying traces over HTTPS&lt;a class="heading-anchor" href="#querying-traces-over-https" aria-label="Permalink to Querying traces over HTTPS"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;I recently discovered that quite a few folks have written scripts which download
a trace and then run queries against it with the trace_processor CLI. Which made
me think: why don&amp;rsquo;t we just support that natively inside the CLI itself?&lt;/p&gt;
&lt;p&gt;So in v57, &lt;code&gt;trace_processor&lt;/code&gt; takes an &lt;code&gt;http(s)&lt;/code&gt; URL or a &lt;code&gt;ui.perfetto.dev&lt;/code&gt; share
link directly. It streams the trace and runs your query with no local copy. Here
it is against the journald trace from the previous section:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ trace_processor query \
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;https://lalitm.com/traces/journald-demo.pftrace&amp;#34; \
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;select log_source, count(*) as n from logs where msg is not null group by log_source&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#34;log_source&amp;#34;,&amp;#34;n&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#34;systemd_journald&amp;#34;,30
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It&amp;rsquo;s one of those small polish features which you wouldn&amp;rsquo;t necessarily think of
immediately but when you have it, you&amp;rsquo;d never want to go back.&lt;/p&gt;
&lt;h2 id="lightning-round"&gt;Lightning round&lt;a class="heading-anchor" href="#lightning-round" aria-label="Permalink to Lightning round"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;A few smaller things also landed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Shift + mouse wheel scrolls the timeline horizontally.&lt;/strong&gt; A tiny change that
removes a daily papercut when you are panning around a wide trace.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The query results grid got a real overhaul.&lt;/strong&gt; You can sort, reorder, and
hide columns, the sidebar collapses, and SQL errors now show up in the grid
instead of disappearing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Adjacent slices that share a boundary render with a 1px gap,&lt;/strong&gt; so a run of
back-to-back slices reads as separate slices rather than one solid block.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Saved textproto record configs are editable,&lt;/strong&gt; saving the trouble of
downloading the config, deleting it, editing it locally, and then reuploading.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="wrap-up"&gt;Wrap up&lt;a class="heading-anchor" href="#wrap-up" aria-label="Permalink to Wrap up"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Overall this was a pretty solid release of Perfetto; it&amp;rsquo;s always satisfying to
fix a bug blocking a lot of people. AI skills and state tracks are both first
steps in a much longer journey, and journald logs are an important new
capability that improves our Linux support. The rest are mostly a bunch of small
quality of life improvements which are always nice to see!&lt;/p&gt;</content:encoded></item></channel></rss>