lit_wsl.cli
source module lit_wsl.cli
Command-line interface for lit-wsl weight mapping visualization.
Functions
-
load_checkpoint — Load a checkpoint file and extract state dict.
-
load_model_class — Load a model class from a module path.
-
cmd_visualize_hierarchy — Command: visualize model hierarchy tree.
-
cmd_visualize_mapping — Command: visualize weight mapping results.
-
cmd_analyze_mapping — Command: comprehensive mapping analysis with hierarchies and scores.
-
cmd_version — Command: print version information.
-
create_parser — Create the argument parser with all subcommands.
-
main — Main entry point for the CLI.
source load_checkpoint(checkpoint_path: str) → dict
Load a checkpoint file and extract state dict.
Parameters
-
checkpoint_path : str — Path to checkpoint file
Returns
-
dict — State dictionary from checkpoint
Raises
-
FileNotFoundError — If checkpoint file doesn't exist
-
RuntimeError — If checkpoint can't be loaded
source load_model_class(model_spec: str) → type[nn.Module]
Load a model class from a module path.
Parameters
-
model_spec : str — Module path like 'package.module:ClassName'
Returns
-
type[nn.Module] — Model class
Raises
-
ValueError — If model_spec format is invalid
-
ImportError — If module can't be imported
-
AttributeError — If class not found in module
-
TypeError
source cmd_visualize_hierarchy(args: argparse.Namespace) → int
Command: visualize model hierarchy tree.
Parameters
-
args : argparse.Namespace — Parsed command-line arguments
Returns
-
int — Exit code (0 for success, 1 for error)
source cmd_visualize_mapping(args: argparse.Namespace) → int
Command: visualize weight mapping results.
Parameters
-
args : argparse.Namespace — Parsed command-line arguments
Returns
-
int — Exit code (0 for success, 1 for error)
source cmd_analyze_mapping(args: argparse.Namespace) → int
Command: comprehensive mapping analysis with hierarchies and scores.
Parameters
-
args : argparse.Namespace — Parsed command-line arguments
Returns
-
int — Exit code (0 for success, 1 for error)
source cmd_version(args: argparse.Namespace) → int
Command: print version information.
Parameters
-
args : argparse.Namespace — Parsed command-line arguments
Returns
-
int — Exit code (always 0)
source create_parser() → argparse.ArgumentParser
Create the argument parser with all subcommands.
Returns
-
argparse.ArgumentParser — Configured ArgumentParser
Main entry point for the CLI.
Returns
-
int — Exit code