Skip to content

Add platform component registry for config-driven selection#112

Merged
Jack-Khuu merged 2 commits intoplatform/inner-interfacesfrom
platform/registry
Mar 3, 2026
Merged

Add platform component registry for config-driven selection#112
Jack-Khuu merged 2 commits intoplatform/inner-interfacesfrom
platform/registry

Conversation

@Jack-Khuu
Copy link
Contributor

Introduce PlatformRegistry that maps (component_key, impl_name) pairs to factory callables.
YAML configs like platform: {verifier: nvidia} now drive component selection at runtime.

  • registry.py: PlatformRegistry with register/create/create_from_config and _filter_kwargs for signature-safe factory construction. Built-in nvidia implementations registered at import time.
  • opt_manager.py: @config_injectable decorator, new platform param, _resolve_platform() replaces three default* factory methods. Worker-level config (string names) propagated via worker_kwargs.
  • opt_worker.py: new platform_config param and _resolve_platform_config() to resolve worker-level components from the registry in each worker process.
  • examples/configs/: beam_search.yaml, greedy.yaml, nvidia.yaml
  • run_opt_manager.py: --config CLI option for config-driven construction

python examples/run_opt_manager.py \
       --kernel-dir examples/optimize_01_matvec \
       --config examples/configs/beam_search.yaml

Introduce PlatformRegistry that maps (component_key, impl_name) pairs
to factory callables.  YAML configs like `platform: {verifier: nvidia}`
now drive component selection at runtime.

- registry.py: PlatformRegistry with register/create/create_from_config
  and _filter_kwargs for signature-safe factory construction.  Built-in
  nvidia implementations registered at import time.
- opt_manager.py: @config_injectable decorator, new `platform` param,
  _resolve_platform() replaces three _default_* factory methods.
  Worker-level config (string names) propagated via worker_kwargs.
- opt_worker.py: new `platform_config` param and
  _resolve_platform_config() to resolve worker-level components from
  the registry in each worker process.
- examples/configs/: beam_search.yaml, greedy.yaml, nvidia.yaml
- run_opt_manager.py: --config CLI option for config-driven construction
@Jack-Khuu Jack-Khuu requested a review from kaiming-cheng March 3, 2026 01:08
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 3, 2026
* Add no-op platform implementations for dry-run testing

No-op implementations pass the input kernel through unchanged, useful
for CI environments without GPU hardware and integration tests.

- noop.py: NoOpVerifier (returns True), NoOpBenchmarker (returns 1.0ms
  placeholder), NoOpWorkerRunner (returns parent kernel as success),
  plus worker-level stubs (NoOpSpecsProvider, NoOpProfiler,
  NoOpRooflineAnalyzer, NoOpBottleneckAnalyzer, NoOpRAGPrescriber).
- registry.py: register all noop implementations under "noop" name.
- __init__.py: re-export noop classes.
- examples/configs/noop.yaml: greedy strategy with platform: noop.

* Fix missing worker kwargs in config-driven construction

- Add gpu_name and other worker kwargs to the --config path in
  run_opt_manager.py (were always passed in hardcoded paths).
- Fix openai_model inconsistency across YAML configs.
- Pass profiling_semaphore to fallback KernelProfiler construction
  so NCU profiling is properly serialized.

* Fix config_injectable VAR_KEYWORD double-nesting bug

When a decorated function has **kwargs, apply_defaults() stores them
as {param_name: {}} in bound_args.arguments. Calling func(**result)
then passes that as a keyword arg, nesting it inside the real **kwargs.

Expand VAR_KEYWORD entries before returning so they stay flat.

* forward fix bugs
@Jack-Khuu Jack-Khuu merged commit ec9a27b into platform/inner-interfaces Mar 3, 2026
1 check passed
Jack-Khuu added a commit that referenced this pull request Mar 3, 2026
* Add outer platform interfaces and extract NVIDIA impls from opt_manager

Introduce KernelVerifier, KernelBenchmarker, and WorkerRunner abstract
interfaces that define the seams where platform-specific code enters
OptimizationManager.

Extract the existing NVIDIA-specific code (verification via
VerificationWorker, benchmarking via Benchmark, worker spawning via
mp.Process) into NvidiaVerifier, NvidiaBenchmarker, and
NvidiaWorkerRunner classes that implement these interfaces.

OptimizationManager now delegates to self.verifier, self.benchmarker,
and self.worker_runner instead of inlining the NVIDIA code. No
behavioral changes — the same NVIDIA defaults are always constructed.

* Add inner-worker platform interfaces and NVIDIA implementations

Add 5 worker-level abstract interfaces for components inside
OptimizationWorker: AcceleratorSpecsProvider, KernelProfilerBase,
RooflineAnalyzerBase, BottleneckAnalyzerBase, RAGPrescriberBase.

Add NVIDIA wrapper implementations that lazily delegate to the existing
concrete classes (KernelProfiler, RooflineAnalyzer, BottleneckAnalyzer,
RAGPrescriber, get_gpu_specs).

Add platform_components dict parameter to OptimizationWorker so
registry-resolved components can be injected from the manager level.
_init_components() checks platform_components before falling back to
the default NVIDIA construction.

* Add platform component registry for config-driven selection (#112) Add no-op platform implementations for dry-run testing (#113) 

* Add platform component registry for config-driven selection

Introduce PlatformRegistry that maps (component_key, impl_name) pairs
to factory callables.  YAML configs like `platform: {verifier: nvidia}`
now drive component selection at runtime.

- registry.py: PlatformRegistry with register/create/create_from_config
  and _filter_kwargs for signature-safe factory construction.  Built-in
  nvidia implementations registered at import time.
- opt_manager.py: @config_injectable decorator, new `platform` param,
  _resolve_platform() replaces three _default_* factory methods.
  Worker-level config (string names) propagated via worker_kwargs.
- opt_worker.py: new `platform_config` param and
  _resolve_platform_config() to resolve worker-level components from
  the registry in each worker process.
- examples/configs/: beam_search.yaml, greedy.yaml, nvidia.yaml
- run_opt_manager.py: --config CLI option for config-driven construction

* Add no-op platform implementations for dry-run testing (#113)

* Add no-op platform implementations for dry-run testing

No-op implementations pass the input kernel through unchanged, useful
for CI environments without GPU hardware and integration tests.

- noop.py: NoOpVerifier (returns True), NoOpBenchmarker (returns 1.0ms
  placeholder), NoOpWorkerRunner (returns parent kernel as success),
  plus worker-level stubs (NoOpSpecsProvider, NoOpProfiler,
  NoOpRooflineAnalyzer, NoOpBottleneckAnalyzer, NoOpRAGPrescriber).
- registry.py: register all noop implementations under "noop" name.
- __init__.py: re-export noop classes.
- examples/configs/noop.yaml: greedy strategy with platform: noop.

* Fix missing worker kwargs in config-driven construction

- Add gpu_name and other worker kwargs to the --config path in
  run_opt_manager.py (were always passed in hardcoded paths).
- Fix openai_model inconsistency across YAML configs.
- Pass profiling_semaphore to fallback KernelProfiler construction
  so NCU profiling is properly serialized.

* Fix config_injectable VAR_KEYWORD double-nesting bug

When a decorated function has **kwargs, apply_defaults() stores them
as {param_name: {}} in bound_args.arguments. Calling func(**result)
then passes that as a keyword arg, nesting it inside the real **kwargs.

Expand VAR_KEYWORD entries before returning so they stay flat.

* forward fix bugs

* lint
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