Skip to content

feat: agentic region kernel generation - #4914

Open
bowang007 wants to merge 3 commits into
region_annotationfrom
region_agentic_kernels
Open

bowang007 wants to merge 3 commits into
region_annotationfrom
region_agentic_kernels

Conversation

@bowang007

@bowang007 bowang007 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This feature introduces agentic kernel generation for the region that user specifies.

Type of change

Please delete options that are not relevant and/or add your own.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@meta-cla meta-cla Bot added the cla signed label Oct 22, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation component: tests Issues re: Tests component: core Issues re: The core compiler component: build system Issues re: Build system component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Oct 22, 2026
@github-actions
github-actions Bot requested a review from zewenli98 October 22, 2026 04:08
@bowang007 bowang007 changed the title feat: optimize agentic region kernel generation feat: agentic region kernel generation Oct 22, 2026
@bowang007
bowang007 requested a review from narendasan October 22, 2026 04:13
Generate bounded candidate batches and backend tuning variants through the
existing evaluator. Search decisions follow measured results, keep progress
toward baseline targets, and reserve final validation for alternative finalists.

Checkpoint unfinished searches, remeasure restored candidates, and expose
optional compilation diagnostics. Extend the public API, replay CLI, packaged
instructions, and runnable example while preserving single-candidate providers.

Validation: 481 region regression tests including real GPU integration;
72 focused controller tests and 71 policy tests after follow-up changes;
all targeted pre-commit hooks passed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we add cuteDSL if possible?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@narendasan Our automatic kernel generation system only support cuda tile, triton and cuda python now. That's the reason why such is not included in this PR. But we could add it as another option anytime soon

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can stuff like this piggy back on infra we built for kernels? Like we can walk through the whole custom op registration process the same way. Just break before building the plugin and test in eager?

Comment thread py/torch_tensorrt/dynamo/region_compilation/_generation/_worker.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you know if there is a good way to invoke this as part of the compilation process instead of a stand alone app?

class Model(torch.nn.Module):
def __init__(self, generator):
super().__init__()
self.generator = generator

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is quite invasive, you need to change the constructor of the model to use this feature

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ideally for training mode / eager execution this code is non invasive, transparently passes through and only gets invoked under torch_tensorrt.compile if possible


def forward(self, x, bias, scale):
x = x + 1.0
with fuse_in_plugin(generator=self.generator, name="bias_relu_scale"):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I feel like it would be great to be able to pass a dataloader with real data to validate against

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed component: api [Python] Issues re: Python API component: build system Issues re: Build system component: core Issues re: The core compiler component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: tests Issues re: Tests documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants