Skip to content

chore(utils): add type annotations to public functions in utils.py#2237

Open
nuthalapativarun wants to merge 3 commits into
Lightning-AI:mainfrom
nuthalapativarun:chore/type-hints-utils
Open

chore(utils): add type annotations to public functions in utils.py#2237
nuthalapativarun wants to merge 3 commits into
Lightning-AI:mainfrom
nuthalapativarun:chore/type-hints-utils

Conversation

@nuthalapativarun

Copy link
Copy Markdown

What does this PR do?

Adds Python 3.10+ style type annotations to 13 functions in litgpt/utils.py that were missing parameter or return type annotations. This follows the pattern established in #2221 (which bumped the ruff target-version to py310 and updated type annotations across the codebase).

Functions annotated

Function Added
choose_logger -> Any
get_argument_names cls: type, -> set[str]
instantiate_bnb_optimizer optimizer: str | dict, model_parameters: Any, -> Any
instantiate_torch_optimizer optimizer: str | dict, model_parameters: Any, **kwargs: Any, -> torch.optim.Optimizer
check_file_size_on_cpu_and_warn checkpoint_path: Path | str, device: torch.device | str, size_limit: int, -> float
auto_download_checkpoint model_name: str, access_token: str | None, ignore_tokenizer_files: bool, -> Path
check_nvlink_connectivity fabric: L.Fabric | None, -> None
_check_nvidia_connectivity custom_print: Any, -> None
_check_amd_connectivity custom_print: Any, -> None
fix_and_load_json s: str, -> Any
create_finetuning_performance_report training_time: float, token_counts: dict[str, int], device_type: str, -> str
select_sft_generate_example eval: Any, data: Any, -> str
kill_process_tree -> None
_RunIf **kwargs: Any, -> Any

No new imports were needed. All existing tests pass.

Add Python 3.10+ style type annotations to 13 public and semi-public
functions in litgpt/utils.py that were missing parameter or return type
annotations:

- choose_logger: add -> Any return type
- get_argument_names: add cls: type param and -> set[str] return type
- instantiate_bnb_optimizer: add optimizer: str | dict, model_parameters: Any, -> Any
- instantiate_torch_optimizer: add optimizer: str | dict, model_parameters: Any, **kwargs: Any, -> torch.optim.Optimizer
- check_file_size_on_cpu_and_warn: add checkpoint_path: Path | str, device: torch.device | str, size_limit: int, -> float
- auto_download_checkpoint: add model_name: str, access_token: str | None, ignore_tokenizer_files: bool, -> Path
- check_nvlink_connectivity: add fabric: L.Fabric | None, -> None
- _check_nvidia_connectivity: add custom_print: Any, -> None
- _check_amd_connectivity: add custom_print: Any, -> None
- fix_and_load_json: add s: str, -> Any
- create_finetuning_performance_report: add training_time: float, token_counts: dict[str, int], device_type: str, -> str
- select_sft_generate_example: add eval: Any, data: Any, -> str
- kill_process_tree: add -> None
- _RunIf: add **kwargs: Any, -> Any
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
4 pipeline(s) require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
4 pipeline(s) require an authorized user to comment /azp run to run.

@nuthalapativarun

Copy link
Copy Markdown
Author

Hi! Just checking in — CI appears to be waiting on an authorized /azp run trigger. Happy to make any changes needed to move this forward. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant