Skip to content

[Compiler] Added backend registry#1967

Merged
hinriksnaer merged 12 commits intopytorch:mainfrom
hinriksnaer:backend-registry-pr1
Apr 13, 2026
Merged

[Compiler] Added backend registry#1967
hinriksnaer merged 12 commits intopytorch:mainfrom
hinriksnaer:backend-registry-pr1

Conversation

@hinriksnaer
Copy link
Copy Markdown
Collaborator

@hinriksnaer hinriksnaer commented Apr 7, 2026

Backend lookup is currently scattered across hardcoded dicts in compile_environment.py and settings.py, each duplicating the same name-to-class mapping. Adding a new backend requires updating multiple locations. This PR introduces a centralized backend registry as a single source of truth for backend registration and lookup.

The registry also moves the experimental backend warning from a hardcoded string set (settings.backend in ("pallas", "cute", "metal")) to a Backend.experimental property, so each backend declares its own status rather than being listed in shared code.

This infrastructure can later be leveraged to provide aggregate metadata that requires knowledge across all backends, such as collecting all reserved launch parameter names for kernel portability, or listing available backends at runtime.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 7, 2026
Comment thread helion/runtime/settings.py Outdated
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 still a closed Literal. should this be widened to str (or derived from the registry) now that backends are dynamically registered?

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.

Left this in for IDE and autocomplete support, otherwise we lose that since the list would be generated at runtime.

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.

I think we need to update this otherwise out of tree backends will get lint errors.

Comment thread helion/_compiler/backend_registry.py Outdated
Comment thread helion/_compiler/backend_registry.py Outdated
Copy link
Copy Markdown
Contributor

@jansel jansel left a comment

Choose a reason for hiding this comment

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

Add tests?

Comment thread helion/_compiler/backend.py Outdated
Comment thread helion/runtime/settings.py Outdated
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.

I think we need to update this otherwise out of tree backends will get lint errors.

@hinriksnaer hinriksnaer requested a review from jansel April 9, 2026 18:51
@hinriksnaer
Copy link
Copy Markdown
Collaborator Author

Added tests and cleaned up the literal. @jansel

@hinriksnaer hinriksnaer merged commit 7092de1 into pytorch:main Apr 13, 2026
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants