Skip to content

Commit 7eb882a

Browse files
ralphbeanclaude
andcommitted
Remove cache_dir parameter in favor of environment variables
Following feedback on PR vllm-project#1902, this removes the cache_dir parameter entirely from ModelArguments, DatasetArguments, and the oneshot() API. By removing explicit cache_dir parameters and setting all calls to cache_dir=None, the HuggingFace libraries will automatically respect the standard environment variable hierarchy (HF_HOME, HF_HUB_CACHE) for determining cache locations. This approach: - Simplifies the codebase by removing parameter propagation - Follows standard HuggingFace patterns - Prevents cache_dir from being accidentally ignored - Still fully supports offline mode via environment variables Breaking change: Users who previously used the cache_dir parameter should now use HF_HOME or HF_HUB_CACHE environment variables instead. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Ralph Bean <[email protected]>
1 parent fdd3138 commit 7eb882a

File tree

5 files changed

+6
-18
lines changed

5 files changed

+6
-18
lines changed

src/llmcompressor/args/model_arguments.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ class ModelArguments:
5050
"help": "Pretrained processor name or path if not the same as model_name"
5151
},
5252
)
53-
cache_dir: str | None = field(
54-
default=None,
55-
metadata={"help": "Where to store the pretrained data from huggingface.co"},
56-
)
5753

5854
use_auth_token: bool = field(
5955
default=False,

src/llmcompressor/args/utils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,4 @@ def parse_args(
8383
# silently assign tokenizer to processor
8484
resolve_processor_from_model_args(model_args)
8585

86-
# copy cache_dir from model_args to dataset_args to support offline mode
87-
# with a single unified cache directory. This allows both models and datasets
88-
# to use the same cache when cache_dir is specified
89-
dataset_args.cache_dir = model_args.cache_dir
90-
9186
return model_args, dataset_args, recipe_args, training_args, output_dir

src/llmcompressor/entrypoints/oneshot.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ def oneshot(
225225
config_name: Optional[str] = None,
226226
tokenizer: Optional[Union[str, PreTrainedTokenizerBase]] = None,
227227
processor: Optional[Union[str, ProcessorMixin]] = None,
228-
cache_dir: Optional[str] = None,
229228
use_auth_token: bool = False,
230229
precision: str = "auto",
231230
tie_word_embeddings: bool = False,
@@ -273,8 +272,6 @@ def oneshot(
273272
model_name.
274273
:param processor: Pretrained processor name or path if not the same as
275274
model_name.
276-
:param cache_dir: Where to store the pretrained data from
277-
huggingface.co.
278275
:param use_auth_token: Whether to use Hugging Face auth token for private
279276
models.
280277
:param precision: Precision to cast model weights to, default to auto.

src/llmcompressor/entrypoints/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def initialize_model_from_path(
175175
model_path = model_args.model
176176
config = AutoConfig.from_pretrained(
177177
model_args.config_name if model_args.config_name else model_path,
178-
cache_dir=model_args.cache_dir,
178+
cache_dir=None,
179179
revision=model_args.model_revision,
180180
use_auth_token=True if model_args.use_auth_token else None,
181181
trust_remote_code=model_args.trust_remote_code_model,
@@ -211,7 +211,7 @@ def initialize_model_from_path(
211211
)
212212
teacher_kwargs = {
213213
"config": teacher_config,
214-
"cache_dir": model_args.cache_dir,
214+
"cache_dir": None,
215215
"use_auth_token": True if model_args.use_auth_token else None,
216216
"torch_dtype": parse_dtype(model_args.precision),
217217
"device_map": teacher_device_map,
@@ -233,7 +233,7 @@ def initialize_model_from_path(
233233

234234
model_kwargs = {
235235
"config": config,
236-
"cache_dir": model_args.cache_dir,
236+
"cache_dir": None,
237237
"revision": model_args.model_revision,
238238
"use_auth_token": True if model_args.use_auth_token else None,
239239
"torch_dtype": parse_dtype(model_args.precision),
@@ -266,7 +266,7 @@ def initialize_processor_from_path(
266266
try:
267267
processor = AutoProcessor.from_pretrained(
268268
processor_src,
269-
cache_dir=model_args.cache_dir,
269+
cache_dir=None,
270270
use_fast=True,
271271
revision=model_args.model_revision,
272272
use_auth_token=True if model_args.use_auth_token else None,
@@ -285,7 +285,7 @@ def initialize_processor_from_path(
285285
logger.debug("Could not load fast processor, loading slow processor instead")
286286
processor = AutoProcessor.from_pretrained(
287287
processor_src,
288-
cache_dir=model_args.cache_dir,
288+
cache_dir=None,
289289
use_fast=False,
290290
revision=model_args.model_revision,
291291
use_auth_token=True if model_args.use_auth_token else None,

src/llmcompressor/transformers/finetune/data/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def load_dataset(self):
195195
logger.debug(f"Loading dataset {self.dataset_args.dataset}")
196196
return get_raw_dataset(
197197
self.dataset_args,
198-
cache_dir=self.dataset_args.cache_dir,
198+
cache_dir=None,
199199
split=self.split,
200200
streaming=self.dataset_args.streaming,
201201
**self.dataset_args.raw_kwargs,

0 commit comments

Comments
 (0)