You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cli): add InferenceModelCheck and keep CLI import hub-free for offline flag
Consolidate inference env validation into a single preflight check and make the
Hugging Face offline switch reliable end to end.
- preflight: rename InferenceKeyCheck to InferenceModelCheck (env.inference);
validate NSS_INFERENCE_KEY, NSS_INFERENCE_MODEL, and NSS_INFERENCE_ENDPOINT
via single-dispatch match logic.
- cli: replace --local-files-only with --enable/--disable-huggingface-remote
(CLI-only, no NSS env var); propagate to HF_HUB_OFFLINE/TRANSFORMERS_OFFLINE.
- utils: add shared hf_offline_enabled() and env_flag_is_true(); detect.py
reads NSS_INFERENCE_MODEL at call time and GLiNER offline from env.
- imports: defer huggingface_hub in telemetry and datasets in utils so the
cli.cli import chain stays hub-free; HF_HUB_OFFLINE is then propagated before
huggingface_hub first loads. Add tests/cli/test_cli_import regression guard.
- docs: document the offline switch, CLI flag precedence, and import-time
caching of HF_HUB_OFFLINE.
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
|`NSS_INFERENCE_KEY`| nss |`--inference-api-key`| PII column classifier | -- | API key for `NSS_INFERENCE_ENDPOINT`| Required for LLM column classification |
52
52
|`NSS_INFERENCE_MODEL`| nss |`--inference-model-id`| PII column classifier |`qwen/qwen3-next-80b-a3b-instruct`| Model ID sent to the inference endpoint |[PII appendix](#pii-ner-and-column-classification)|
|`NSS_PII_REPLACER_CPU_COUNT`| nss |`--cpu-count`| NER worker pool |`max(1, cpu_count - 1)`| CPU processes for PII NER |[PII appendix](#pii-ner-and-column-classification)|
55
54
|`NEMO_TELEMETRY_ENABLED`| telemetry |`--emit_telemetry`| telemetry |`true`| Enable anonymous usage telemetry | Also `emit_telemetry` in YAML; see [Telemetry](#telemetry)|
56
55
|`HF_HOME`| third-party | -- | Hugging Face Hub | platform cache dir | Root directory for HF downloads |[HF appendix](#hugging-face-cache-and-offline)|
57
-
|`HF_HUB_OFFLINE`| third-party |-- | Hugging Face Hub | unset | Fail if a model is not cached | Preferred offline gate |
56
+
|`HF_HUB_OFFLINE`| third-party |`--enable-huggingface-remote` / `--disable-huggingface-remote`| Hugging Face Hub | unset | Fail if a model is not cached (covers base model and GLiNER) | Preferred offline gate; CLI flag also sets `TRANSFORMERS_OFFLINE`|
Copy file name to clipboardExpand all lines: docs/user-guide/running.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -274,7 +274,7 @@ execute in order (`config` → `dataframe` → `metadata` → `advisory`).
274
274
| Check name | Stage | What it validates |
275
275
|-------|-------|-------------------|
276
276
|`gpu.cuda`| config | PyTorch is importable and a CUDA GPU is visible |
277
-
|`env.inference_key`| config |`NSS_INFERENCE_KEY` is set when PII classification is enabled (warning only) |
277
+
|`env.inference`| config |Inference config for PII classification: `NSS_INFERENCE_KEY` is set, `NSS_INFERENCE_MODEL` is non-empty, and `NSS_INFERENCE_ENDPOINT`is a valid http(s) URL (warnings only) |
278
278
|`env.hf_model_availability`| config | The pretrained model reference is usable locally or can be fetched from Hugging Face; warns about a missing HF token only when online HF access may be needed |
279
279
|`dataset.size`| dataframe | Training split meets the hard minimum row count |
280
280
|`columns.groupby`| dataframe |`group_training_examples_by` column is present and has no nulls |
@@ -1230,9 +1230,11 @@ See [`artifacts clean`](#artifacts-clean) in the CLI Commands section for option
1230
1230
## Running in Offline Environments
1231
1231
1232
1232
Pre-cache models by running once with internet access, then set
1233
-
`HF_HUB_OFFLINE=1` in your target environment. For detailed cache setup
1234
-
and environment variables (`HF_HOME`, `HF_HUB_OFFLINE`, `NSS_LOCAL_FILES_ONLY`,
1235
-
`VLLM_CACHE_ROOT`), see
1233
+
`HF_HUB_OFFLINE=1` in your target environment. Export it before launching
|`no_gpu`| error |`gpu.cuda`| No CUDA GPU detected (required for training or generation) |
515
515
|`low_vram`| warning |`gpu.vram`| Free GPU VRAM may be insufficient |
516
-
|`inference_key_missing`| warning |`env.inference_key`|`NSS_INFERENCE_KEY` not set; PII classification degraded |
516
+
|`inference_key_missing`| warning |`env.inference`|`NSS_INFERENCE_KEY` not set; PII classification degraded |
517
+
|`inference_model_blank`| warning |`env.inference`|`NSS_INFERENCE_MODEL` set but empty; classification would send an empty model id and fail |
518
+
|`inference_endpoint_invalid`| warning |`env.inference`|`NSS_INFERENCE_ENDPOINT` set but not a valid http(s) URL; classification requests will fail |
517
519
|`hf_token_missing`| warning |`env.hf_model_availability`| Neither `HF_TOKEN` nor `HUGGING_FACE_HUB_TOKEN` set, and model loading may need online Hugging Face access |
518
520
|`hf_model_not_cached`| warning/error |`env.hf_model_availability`| Hugging Face model is not present in the local cache; severity is error when HF offline mode is enabled |
519
521
|`hf_model_cache_incomplete`| warning/error |`env.hf_model_availability`| Cached Hugging Face model snapshot is missing required config, tokenizer, weights, or shards; severity is error when HF offline mode is enabled |
@@ -545,7 +547,29 @@ The PII replacer downloads the GLiNER NER model on first use. If the download
545
547
fails, it raises an exception immediately.
546
548
547
549
Pre-download the model by running PII replacement once in an environment
548
-
with internet access, or set `NSS_LOCAL_FILES_ONLY=true` after the model is cached.
550
+
with internet access. To force offline use after the model is cached, set
551
+
`HF_HUB_OFFLINE=1` or pass `--disable-huggingface-remote`.
552
+
553
+
### Offline Mode Not Taking Effect
554
+
555
+
Symptom: `HF_HUB_OFFLINE=1` (or `--disable-huggingface-remote`) is set, yet the
556
+
run still attempts a download, or `--enable-huggingface-remote` does not
557
+
re-enable downloads.
558
+
559
+
Cause: huggingface_hub reads `HF_HUB_OFFLINE` once, at import time, and caches
560
+
it. If the variable is changed after huggingface_hub has been imported in the
561
+
process, the change is ignored.
562
+
563
+
Fixes:
564
+
565
+
- CLI: export `HF_HUB_OFFLINE` before launching `safe-synthesizer`, or use
566
+
`--enable-huggingface-remote` / `--disable-huggingface-remote`. The CLI
567
+
applies the flag before huggingface_hub loads, so the flag always wins over
568
+
an inherited environment value.
569
+
- Programmatic / SDK: set `HF_HUB_OFFLINE` before importing
570
+
`nemo_safe_synthesizer` (or any library that imports huggingface_hub, such as
571
+
`transformers` or `datasets`). Setting it afterward has no effect for that
0 commit comments