Skip to content

Commit 6367b36

Browse files
committed
Refactor HF_MODULE_KEY
GitOrigin-RevId: 166f661
1 parent 4bd8b19 commit 6367b36

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

axlearn/common/module.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ def forward(self, x: Tensor) -> Tensor:
177177

178178
_CallableT = TypeVar("_CallableT", bound=Callable)
179179

180+
HF_MODULE_KEY = "hf_module"
181+
180182

181183
def nowrap(fun: _CallableT) -> _CallableT:
182184
"""Marks the specified module method as one that doesn't need to be wrapped.

axlearn/experiments/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from axlearn.common.checkpointer import every_n_steps_policy
2828
from axlearn.common.config import TrainerConfigFn
2929
from axlearn.common.evaler import every_n_steps_policy as eval_every_n_steps_policy
30+
from axlearn.common.module import HF_MODULE_KEY
3031
from axlearn.common.summary_writer import SummaryWriter
3132
from axlearn.common.test_utils import (
3233
ParamInitSpec,
@@ -37,7 +38,6 @@
3738
)
3839
from axlearn.common.trainer import SpmdTrainer
3940
from axlearn.common.utils import NestedTree, Tensor, flatten_items, set_data_dir
40-
from axlearn.huggingface.hf_module import HF_MODULE_KEY
4141

4242

4343
def named_parameters(

axlearn/huggingface/hf_module.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
from axlearn.common.base_layer import ParameterSpec
2020
from axlearn.common.base_model import BaseModel
2121
from axlearn.common.config import REQUIRED, Required, RequiredFieldMissingError, config_class
22-
from axlearn.common.module import Module, NestedTensor # pylint: disable=unused-import
22+
from axlearn.common.module import HF_MODULE_KEY, Module, NestedTensor
2323
from axlearn.common.utils import Nested, Tensor
2424

25-
HF_MODULE_KEY = "hf_module"
26-
2725

2826
def get_hf_models_cache_dir() -> Path:
2927
"""Returns the directory where HF models are cached.

0 commit comments

Comments
 (0)