File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -217,4 +217,17 @@ This PR improves training monitoring and logging across runs besides some other
217217* Add tutorials on Einsum Transformer (Example model integration) and profiling
218218
219219** Breaking Changes**
220- * experiments_root_path is now exposed on an API level
220+ * experiments_root_path is now exposed on an API level
221+
222+ ## PR #XXX Torch-free dataloader utilities for CPU-only tooling
223+
224+ ** ` TokenizerInstantiationModel ` .** Lets a tool reuse a packing config for its tokenizer without
225+ also having to satisfy that config's settings, which name a specific source file the tool has no
226+ interest in.
227+
228+ ** ` get_logger ` no longer requires torch.** The ` import torch ` in ` utils/logger_utils.py ` is only
229+ there for the rank prefix, but it is the reason ` dataloader/create_index.py ` -- and therefore
230+ ` IndexGenerator ` -- could not be imported without torch. Since modalities declares torch in its
231+ ` cpu ` /` cu12x ` extras rather than as a base dependency, that made CPU-only data-preprocessing
232+ tooling install a multi-gigabyte wheel it never called. The import is now guarded and the rank
233+ prefix is simply omitted when torch is absent; behaviour with torch installed is unchanged.
Original file line number Diff line number Diff line change @@ -223,6 +223,18 @@ class PackedDatasetSettings(BaseModel):
223223 settings : PackedDatasetSettings
224224
225225
226+ class TokenizerInstantiationModel (BaseModel ):
227+ """Builds only the tokenizer of a config.
228+
229+ Lets a tool reuse a packing config for its tokenizer without also having to satisfy
230+ that config's settings, which name a specific source file the tool has no interest
231+ in. Building from the packing config is what guarantees the same tokenizer is used
232+ for measuring token estimates and for the packing those estimates predict.
233+ """
234+
235+ tokenizer : PydanticTokenizerIFType
236+
237+
226238class TextGenerationInstantiationModel (BaseModel ):
227239 class TextGenerationSettings (BaseModel ):
228240 model_path : FilePath
Original file line number Diff line number Diff line change 11import logging
22
3- import torch
3+ try :
4+ # Only needed for the rank prefix. Guarded so that CPU-only tooling -- data
5+ # preprocessing in particular -- can import the dataloader utilities without
6+ # pulling in torch, which modalities declares in its cpu/cu12x extras rather
7+ # than as a base dependency.
8+ import torch
9+ except ImportError : # pragma: no cover - exercised only in torch-free installs
10+ torch = None
411
512
613def get_logger (name : str = "main" ) -> logging .Logger :
714 rank_info = ""
815
9- if torch .distributed .is_initialized ():
16+ if torch is not None and torch .distributed .is_initialized ():
1017 rank_info = f"[RANK { torch .distributed .get_rank ()} ] "
1118
1219 logger = logging .getLogger (name )
You can’t perform that action at this time.
0 commit comments