Skip to content

[profiler] Suppress Callable field from tyro CLI parsing - #3038

Merged
tianyu-l merged 2 commits into
pytorch:mainfrom
saforem2:fix/profiler-tyro-callable
Apr 21, 2026
Merged

tianyu-l merged 2 commits into
pytorch:mainfrom
saforem2:fix/profiler-tyro-callable

Conversation

@saforem2

Copy link
Copy Markdown
Contributor

Summary

Fixes a crash introduced by #2926 where trace_post_processor: Function.Config | None in Profiler.Config causes tyro.cli() to fail because tyro cannot parse Callable[..., Any] types from CLI arguments.

Error:

Invalid input to tyro.cli()
Unsupported type annotation for field profiler.trace-post-processor.fn
with type collections.abc.Callable[..., typing.Any]

Fix: Annotate trace_post_processor with tyro.conf.Suppress, matching the existing pattern used for:

  • model_spec in trainer.py:62
  • sample_processor in text_datasets.py:502

The field defaults to None and is only set programmatically by CUDAGraphWrapper, never via CLI.

Test plan

  • Verify python -m torchtitan.train ... no longer crashes at config parsing
  • Verify graph_trainer still works (trace_post_processor set programmatically)

The `trace_post_processor` field added in pytorch#2926 uses `Function.Config`
which contains `fn: Callable[..., R]`. tyro cannot parse `Callable`
types from CLI arguments, causing all training runs to crash with:

    Invalid input to tyro.cli()
    Unsupported type annotation for field profiler.trace-post-processor.fn
    with type collections.abc.Callable[..., typing.Any]

Fix: annotate with `tyro.conf.Suppress`, matching the existing pattern
used for `model_spec` in `trainer.py` and `sample_processor` in
`text_datasets.py`. The field defaults to `None` and is only set
programmatically by graph_trainer's `CUDAGraphWrapper`.
Copilot AI review requested due to automatic review settings April 21, 2026 14:34
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 21, 2026
@pytorch-bot

pytorch-bot Bot commented Apr 21, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a config-parsing crash in Torchtitan’s CLI by preventing tyro from attempting to parse a Callable[..., Any] embedded in Profiler.Config.trace_post_processor (introduced via Function.Config).

Changes:

  • Mark Profiler.Config.trace_post_processor as tyro.conf.Suppress via typing.Annotated so it’s excluded from CLI parsing/help generation.
  • Add a clarifying docstring note that the field is set programmatically (not via CLI).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wwwjn wwwjn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks this PR looks good to me and I also verified it fixed locally, can you fix the lint before merging?

@tianyu-l
tianyu-l merged commit 0de35f9 into pytorch:main Apr 21, 2026
13 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants