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

[Compiler] Split compiler pipeline into pass pipeline, compilation, and translation steps #284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jhalakpatel
Copy link
Collaborator

No description provided.

@jhalakpatel jhalakpatel changed the title Add an option to dump textual pipeline during compilation [Compiler] Add an option to dump textual pipeline during compilation Oct 17, 2024
@christopherbate
Copy link
Collaborator

christopherbate commented Oct 18, 2024

The API here seems much too adhoc. It's adding a dedicated option just to control something printed to stderr. There's already a mechanism for that via the debug options -debug, -debug-only, etc.

I think a better path would be some of the following options:

  1. add an API to get the textual pipeline as a string. This could would be something like
ir = client.get_textual_pipeline(opts)

Then you can print that or write to file as desired. That would also enable us to control how the pipeline is printed in the backend. As you know, several passes in the textual pipeline dump from a PassManager are not actually registered. We would instead inspect the opts and then print out a custom, higher-level, pipeline sequence that can actually be run with the mlir-tensorrt-opt tool.

  1. An alternative option would leverage MLIR's existing bindings to PassPipeline, which is already capable of printing out the textual pipeline. This opens more opportunities for TriPy to directly manipulate the pass pipeline. The API would change so that instead of directly invoking stablehlo_to_executable, you instead first get the pass pipeline object, run compilation, and then invoke translation, something like:
pm = client.get_stablehlo_to_executable_pipeline(opts)
print(pm)
lowered_module = pm.run(module)
exe = client.translate_to_runtime_executable(module)

Here exe is the equivalent of what would be returned from client.stablehlo_to_executable now.

Copy link
Collaborator

@christopherbate christopherbate left a comment

Choose a reason for hiding this comment

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

See comments above

@jhalakpatel
Copy link
Collaborator Author

The API here seems much too adhoc. It's adding a dedicated option just to control something printed to stderr. There's already a mechanism for that via the debug options -debug, -debug-only, etc.

I think a better path would be some of the following options:

  1. add an API to get the textual pipeline as a string. This could would be something like
ir = client.get_textual_pipeline(opts)

Then you can print that or write to file as desired. That would also enable us to control how the pipeline is printed in the backend. As you know, several passes in the textual pipeline dump from a PassManager are not actually registered. We would instead inspect the opts and then print out a custom, higher-level, pipeline sequence that can actually be run with the mlir-tensorrt-opt tool.

  1. An alternative option would leverage MLIR's existing bindings to PassPipeline, which is already capable of printing out the textual pipeline. This opens more opportunities for TriPy to directly manipulate the pass pipeline. The API would change so that instead of directly invoking stablehlo_to_executable, you instead first get the pass pipeline object, run compilation, and then invoke translation, something like:
pm = client.get_stablehlo_to_executable_pipeline(opts)
print(pm)
lowered_module = pm.run(module)
exe = client.translate_to_runtime_executable(module)

Here exe is the equivalent of what would be returned from client.stablehlo_to_executable now.

I liked the approach (2) where we could control the pipeline passes from Tripy if required.
CC: @parthchadha @pranavm-nvidia

@jhalakpatel jhalakpatel force-pushed the jhalakp-dump-textual-pipeline branch from b559e1d to d17d489 Compare October 24, 2024 04:45
@jhalakpatel jhalakpatel changed the title [Compiler] Add an option to dump textual pipeline during compilation [Compiler] Split compiler pipeline into pass pipeline, compilation, and translation steps Oct 24, 2024
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