Skip to content

chore(model,prompts): add type annotations to module-level functions and __init__ methods#2242

Open
Koushik-Salammagari wants to merge 1 commit into
Lightning-AI:mainfrom
Koushik-Salammagari:type-hints/prompts-model
Open

chore(model,prompts): add type annotations to module-level functions and __init__ methods#2242
Koushik-Salammagari wants to merge 1 commit into
Lightning-AI:mainfrom
Koushik-Salammagari:type-hints/prompts-model

Conversation

@Koushik-Salammagari
Copy link
Copy Markdown

What does this PR do?

Adds missing Python 3.10+ style type annotations to litgpt/model.py and litgpt/prompts.py. These two files had the second and third highest counts of unannotated functions after utils.py (which was covered in #2237).

litgpt/model.py

Function Added
yarn_get_mscale scale: float, mscale: float, -> float
batched_index_select t: torch.Tensor, dim: int, idx: torch.Tensor, -> torch.Tensor
batched_index_copy_ t: torch.Tensor, dim: int, idx: torch.Tensor, val: torch.Tensor, -> torch.Tensor
find_correction_dim (nested in build_rope_cache) num_rotations: float, dim: int, base_val: float, max_pos: int, -> float

litgpt/prompts.py

Added -> None return annotation to all __init__ methods that were missing it:

Class
ChatML
Qwen2_5
Qwen2_5_Math
QwQ
Qwen3
SmolLM2
Salamandra

No new imports needed in either file.

Before submitting

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