From 6d65da5ab522e199a328b58b600c674bdb4752a0 Mon Sep 17 00:00:00 2001 From: Ishtiaq Ahmed Date: Thu, 26 Nov 2026 10:17:50 +0500 Subject: [PATCH] docs: fix docstring args that don't match their signatures TrainConfig documented a wandb_project field; the field is wandb_project_name, so TrainConfig(wandb_project=...) raises TypeError. Also complete the truncated max_grad_norm description, drop a stray comma after save_dir, use the real parameter name in BloomArchitectureAdapter. split_qkv_matrix, and describe what ParamProcessingConversion.convert and revert actually take and return (a tensor, not a modified state dict). --- .../param_processing_conversion.py | 20 ++++++++----------- .../supported_architectures/bloom.py | 2 +- transformer_lens/tools/training.py | 6 +++--- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/transformer_lens/conversion_utils/param_processing_conversion.py b/transformer_lens/conversion_utils/param_processing_conversion.py index 6bd4bcf916..5daa9ac3a0 100644 --- a/transformer_lens/conversion_utils/param_processing_conversion.py +++ b/transformer_lens/conversion_utils/param_processing_conversion.py @@ -51,15 +51,15 @@ def _resolve_key(self, current_key: str, template_key: str) -> str: def convert(self, state_dict: Dict[str, torch.Tensor], current_key: str) -> torch.Tensor: """Convert a parameter in the state dict. - Fetches tensor from source_key (or current_key if not specified), - applies conversion, and stores result at current_key. + Fetches tensor from source_key (or current_key if not specified) + and applies the conversion. Args: - state_dict: The state dictionary to modify - current_key: The key where the converted tensor should be stored + state_dict: The state dictionary to read from + current_key: The key of the parameter being converted Returns: - Modified state dictionary + The converted tensor """ # Determine which key to fetch from fetch_key = current_key @@ -73,17 +73,13 @@ def convert(self, state_dict: Dict[str, torch.Tensor], current_key: str) -> torc return self.tensor_conversion.convert(tensor, state_dict) def revert(self, tensor: torch.Tensor) -> torch.Tensor: - """Revert a parameter conversion in the state dict. - - Fetches tensor from current_key, applies reversion, - and stores result back at current_key. + """Revert a parameter conversion. Args: - state_dict: The state dictionary to modify - current_key: The key of the tensor to revert + tensor: The converted tensor to revert Returns: - Modified state dictionary + The reverted tensor """ # Apply reversion (handles None gracefully) return self.tensor_conversion.revert(tensor) diff --git a/transformer_lens/model_bridge/supported_architectures/bloom.py b/transformer_lens/model_bridge/supported_architectures/bloom.py index c82a365de9..2e6af38d2e 100644 --- a/transformer_lens/model_bridge/supported_architectures/bloom.py +++ b/transformer_lens/model_bridge/supported_architectures/bloom.py @@ -106,7 +106,7 @@ def split_qkv_matrix( ) -> tuple[torch.nn.Linear, torch.nn.Linear, torch.nn.Linear]: """Split the QKV matrix into separate linear transformations. Args: - attention_component: The original attention layer component + original_attention_component: The original attention layer component Returns: Tuple of nn.Linear modules for Q, K, and V transformations """ diff --git a/transformer_lens/tools/training.py b/transformer_lens/tools/training.py index 4bbef82040..dae394271d 100644 --- a/transformer_lens/tools/training.py +++ b/transformer_lens/tools/training.py @@ -31,15 +31,15 @@ class TrainConfig: lr (float): Learning rate to use for training seed (int): Random seed to use for training momentum (float): Momentum to use for training - max_grad_norm (float, *optional*): Maximum gradient norm to use for + max_grad_norm (float, *optional*): Maximum gradient norm to clip gradients to weight_decay (float, *optional*): Weight decay to use for training optimizer_name (str): The name of the optimizer to use device (str or torch.device, *optional*): Device to use for training warmup_steps (int, *optional*): Number of warmup steps to use for training save_every (int, *optional*): After how many batches should a checkpoint be saved - save_dir, (str, *optional*): Where to save checkpoints + save_dir (str, *optional*): Where to save checkpoints wandb (bool): Whether to use Weights and Biases for logging - wandb_project (str, *optional*): Name of the Weights and Biases project to use + wandb_project_name (str, *optional*): Name of the Weights and Biases project to use print_every (int, *optional*): Print the loss every n steps max_steps (int, *optional*): Terminate the epoch after this many steps. Used for debugging. """