Integrating Custom Backends via JSON Platform Configs#109
Open
can-gaa-hou wants to merge 1 commit intometa-pytorch:mainfrom
Open
Integrating Custom Backends via JSON Platform Configs#109can-gaa-hou wants to merge 1 commit intometa-pytorch:mainfrom
can-gaa-hou wants to merge 1 commit intometa-pytorch:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change extends KernelAgent’s multi-platform support by allowing users to integrate a custom backend (or override existing platform settings) via an external JSON file. The JSON is loaded at import time and merged into the in-memory platform registry, enabling new
--target-platform <name>values (e.g.,npu) without modifying repository code.Motivation
KernelAgent already supports CUDA and Intel XPU via a built-in
PlatformConfigregistry. However, adding a new backend (e.g., an NPU platform) typically requires:This PR introduces a lightweight escape hatch: JSON-defined platform configs that can be set per-environment. It lowers the friction for downstream teams with custom backends (rocm, tpu, npu, etc.) experimenting.
Usage
Define a custom platform (example: NPU)
{ "npu": { "name": "npu", "device_string": "npu", "guidance_block": "...", "kernel_guidance": "...", "cuda_hacks_to_strip": [] } }export KERNELAGENT_PLATFORM_JSON=/abs/path/to/platforms.jsonProgrammatic usage
Testing
This PR does not add new unit tests since it requires external JSON files, but the following verification has been tested: