ml_switcheroo.discovery.scaffolder¶

Scaffolding Tool for Knowledge Base Discovery.

This module provides the Scaffolder class, which automates the population of the Semantic Knowledge Base by scanning installed libraries (e.g., Torch, JAX). It uses heuristic pattern matching to categorize discovered APIs into semantic tiers (Neural vs Math vs Extras) and persists them into the semantics/ JSON specifications and snapshots/ mapping overlays.

Optimization Update: - Implements Indexing for Catalog Lookups to prevent O(N^2) complexity. - Uses pre-computed indices keyed by lowercase API names for fast retrieval.

Classes¶

Scaffolder

Automated discovery tool that aligns framework APIs.

Module Contents¶

class ml_switcheroo.discovery.scaffolder.Scaffolder(semantics: ml_switcheroo.semantics.manager.SemanticsManager | None = None, similarity_threshold: float = 0.8, arity_penalty: float = 0.3)¶

Automated discovery tool that aligns framework APIs.

This class scans multiple frameworks, identifies common operations based on name similarity (e.g., ‘torch.abs’ == ‘jax.numpy.abs’), and generates the initial JSON mappings required for the transpiler.

inspector¶
console¶
semantics¶
similarity_threshold = 0.8¶
arity_penalty = 0.3¶
staged_specs: Dict[str, Dict[str, Any]]¶
staged_mappings: Dict[str, Dict[str, Any]]¶
scaffold(frameworks: List[str], root_dir: pathlib.Path | None = None)¶

Main entry point. Scans frameworks and builds/updates JSON mappings.

  1. Scans all requested frameworks using ApiInspector.

  2. Aligns APIs against known standards (Specs).

  3. Uses fuzzy matching to align APIs between frameworks.

  4. Writes results to disk (semantics/ and snapshots/).

Parameters:
  • frameworks – List of framework keys to scan (e.g. [‘torch’, ‘jax’]).

  • root_dir – Optional root directory path. Defaults to package paths.