Skip to content

Circular imports #1383

@ebsmothers

Description

@ebsmothers

Bug description

Running e.g.

from torchtitan.components.validate import BaseValidator

throws an error about attempting to import from a partially initialized module. The import chain is

  1. In torchtitan/components/validate.py: from torchtitan.distributed import utils as dist_utils
  2. In torchtitan/distributed/utils.py: from torchtitan.models.attention import ScaledDotProductAttention
  3. In torchtitan/models/__init__.py: import torchtitan.models.deepseek_v3
  4. In torchtitan/models/deepseek_v3/__init__.py: from torchtitan.experiments.llama4.optimizer import build_llama4_optimizers
  5. In torchtitan/experiments/__init__.py: import torchtitan.experiments.llama4
  6. In torchtitan/experiments/llama4/__init__.py: from torchtitan.models.llama3 import pipeline_llama
  7. In torchtitan/models/llama3/__init__.py: from torchtitan.components.validate import build_validator

(4) seems like the problem, since the core repo shouldn't be importing from the experiments directory. I assume this is from DeepSeek's recent move to core, probably build_llama4_optimizers can also be moved to core (and maybe renamed)?

Versions

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions