Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compiled_autograd_id to CompileId #83

Merged
merged 5 commits into from
Dec 21, 2024
Merged

Add compiled_autograd_id to CompileId #83

merged 5 commits into from
Dec 21, 2024

Conversation

xmfan
Copy link
Collaborator

@xmfan xmfan commented Dec 6, 2024

// Read the test file
// simple.log was generated from the following:
// artifacts.log was generated from the following:
// NOTE: test output looks nothing like artifacts.log
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesjwu do you remember which test we need to run for this?

tests/integration_test.rs Outdated Show resolved Hide resolved
@xmfan xmfan force-pushed the ca branch 2 times, most recently from 8ff043f to fb20d4d Compare December 6, 2024 06:26
@ezyang
Copy link
Owner

ezyang commented Dec 6, 2024

Plz fix lint

"0_0_0/aot_forward_graph",
"0_0_0/dynamo_output_graph",
"-_0_0_0/aot_forward_graph",
"-_0_0_0/dynamo_output_graph",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems not so nice. Just omit the -_ delimiter when there is no compiled autograd. There isn't ambiguity because the first 0 can only be a digit anyway.

src/types.rs Outdated
dynamo_id: Option<DynamoId>,
},
// When user calls torch.compile
UserInitiated(DynamoId)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to have an untagged union here? Why not just have a single struct with optional fields everywhere?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I am generally a big union stan but JSON is a lot more straightforward to deserialize and evolve if you don't do unions, since it has no built-in notion of union)

Copy link
Collaborator Author

@xmfan xmfan Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untagged to be backwards compatible with old logs, and to keep evolving with a flat json structure. The tricky part going forward is to maintain the ordering of fields and the ordering of enums. If that's too much, we can revert back to just a struct of optionals since the data format doesn't change

The single struct with optionals feels too permissive because it's not obvious from looking at the definition what set of CompileId you can expect.

@xmfan xmfan marked this pull request as ready for review December 6, 2024 23:29
// simple.log was generated from the following:
// TORCH_TRACE=~/trace_logs/test python test/inductor/test_torchinductor.py -k TORCH_TRACE=~/trace_logs/comp_metrics python test/dynamo/test_misc.py -k test_graph_break_compilation_metrics
// comp_metrics.log was generated from the following:
// TORCH_TRACE=~/trace_logs/comp_metrics python test/dynamo/test_misc.py -k test_graph_break_compilation_metrics
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, you don't have to regenerate the old logs, because it's important for us to be compatible with parsing old logs, so having old logs around is useful too.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I wouldn't change your code here, because this becomes successively less important as time goes on lol)

xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 9, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 9, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
@xmfan xmfan changed the title Introduce CompileId variants and CompiledAutogradInitiated CompileId variant Add compiled_autograd_id to CompileId Dec 9, 2024
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 9, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 9, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
src/lib.rs Outdated
let attempt_str = attempt.map_or("-".to_string(), |v| v.to_string());

if let Some(ca_id) = compiled_autograd_id {
format!("{ca_id}_{frame_id_str}_{frame_compile_id_str}_{attempt_str}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the file naming here isn't load bearing, I wonder if we should do something wordier like "compiled_autograd_{ca_id}_..." so it's obvious that compiled autograd is involved here. Well, I guess the filename doesn't matter that much.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use abbreviations like ca{id}_... to keep things compact and to stick under the 255 char limit for windows

src/parsers.rs Outdated
} else {
format!("{frame_id_str}_{frame_compile_id_str}_{attempt_str}")
}
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this and your earlier site have to be updated in lockstep, so now that it is this complicated you should actually factor this out to a dedicated function.

if let Some(attempt) = self.attempt {
if attempt != 0 {
write!(f, "_{}", attempt)?;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so this is for the display, and I think it's worth bikeshedding this part a little. My main concern is that if we render as 0/1/0_0, people are not going to know what this means. In the old days, I designed the compile id to be compact so that I could put it in front of every log message so you knew what compile id it was associated with. But now in the tlparse era it is less important for it to be compact (though I guess it is still nice for TORCH_TRACE to be compact). I feel like there are two ways we can address this. One is to have some expanded syntax for compiled autograd like "compiled autograd 0: 1/0_0" which makes it obvious it's compiled autograd. The other is to make this an HTML renderer and then add a tooltip so when you mouse over you see the complete thing. I'm happy to defer to implementor's privilege here but at the very minimum, if you are going to stick to this syntax, you need to update the help text in tlparse to explain what it does.

By the way, when all three latter fields are empty, I think it's still helpful to just elide the rhs entirely, so you just have "compiled autograd 0". You can't do this without a special compiled autograd sigil though, because o/w it's ambiguous!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should render the id as hierarchical in the tlparse, and the different id fields would be displayed separately:

image

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ok too! But it is nice to have a globally unique id too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we want a globally unique id that's visible to the user, and that's consistent with how we save it in our datastores, i think we should just keep using [x/y/z_a] and [y/z_a] out of simplicity.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I have another question for you about future proofing. Another place we may need to insert another level of hierarchy is for DDPOptimizer, which splits a single Dynamo graph into multiple subgraphs. Here, this would be done most logically by adding another level of hierarchy below z, i.e. [y/z_a/h]. When a is 0 (and therefore elided), how do we disambiguate between [x/y/z] and [y/z/h]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok regathering the requirements:

  1. We want CompileId to be a program-level uid
  2. We want this displayed to the user so it should be short. It's not necessary for tlparse, but it's very nice to have for TORCH_TRACE and internal dashboards
  3. We want this used in downstream data pipelines so it should be easily parsable from a string

One option is only allow eliding arguments that use prefix/suffix unique tokens: [!0/1/0] vs [0/1/@0]. The compact form is favorable to be directly used by internal dashboards widegets where it might be hard to have custom rendering

We probably want compile directory to also be unique, but special tokens don't work well with filesystems, so we could continue with a no eliding approach: 0_0_0_0_0

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the filesystem directory I really don't care haha, just as long as it's unique

Copy link
Owner

@ezyang ezyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing here is irreversible so go for it. I would appreciate if you considered the comments though!

xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 11, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 11, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 11, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 11, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 12, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 12, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 12, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 12, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames yf225

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 13, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 13, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 13, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 13, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 15, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 15, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 17, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 17, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 20, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 20, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 20, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
xmfan added a commit to pytorch/pytorch that referenced this pull request Dec 20, 2024
tlparse PR: ezyang/tlparse#83




cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Dec 21, 2024
@xmfan xmfan merged commit 62ab847 into ezyang:main Dec 21, 2024
14 checks passed
facebook-github-bot pushed a commit to pytorch/benchmark that referenced this pull request Dec 21, 2024
Summary:
tlparse PR: ezyang/tlparse#83

X-link: pytorch/pytorch#141907
Approved by: https://github.com/ezyang

Reviewed By: huydhn

Differential Revision: D67551013

Pulled By: xmfan

fbshipit-source-id: 86af69d24568874ce4eb72faafa7084a293e957a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants