Skip to content

refactor(llm): Clean up __init__.py - move logic to dedicated modules #143

@m96-chan

Description

@m96-chan

Problem

src/pygpukit/llm/__init__.py is 688 lines with too much logic that should be in dedicated modules.

Current State

src/pygpukit/llm/
└── __init__.py  (688 lines - imports + logic)

Issues

  • __init__.py should primarily be exports
  • Contains initialization logic that belongs elsewhere
  • Hard to understand module structure
  • Circular import risks

Proposed Changes

  1. Move model loading logic to loader.py
  2. Move configuration to config.py
  3. Keep only exports in __init__.py
  4. Target: < 100 lines in __init__.py

Proposed Structure

# __init__.py (< 100 lines)
from pygpukit.llm.models import QwenModel, LlamaModel
from pygpukit.llm.loader import load_model, from_safetensors
from pygpukit.llm.config import ModelConfig
from pygpukit.llm.chat import ChatSession

__all__ = [...]

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions