Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/setup-python-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,7 @@ runs:
uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Disable telemetry in CI
shell: bash
run: echo "NEMO_TELEMETRY_ENABLED=false" >> "$GITHUB_ENV"
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ Options:
via NSS_DATASET_REGISTRY env var. If both
env var and CLI option are provided, the CLI
option takes precedence.
--no-emit-telemetry Disable NeMo Safe Synthesizer telemetry for
this command.
--help Show this message and exit.

Commands:
Expand Down Expand Up @@ -402,6 +404,30 @@ Config values passed as CLI arguments always take precendence, then any override
- `load_args` - Extra arguments needed by the data reader for a specific dataset.
For example, changing the separator used by `pd.read_csv` for a `.csv` file with a different delimiter.

## Telemetry & Privacy

NeMo Safe Synthesizer includes an optional function to share anonymous telemetry data with NVIDIA for product improvement. Data collected is limited to run-level operational metrics (such as final run status, processing time, record and token counts, configuration parameters, top-level quality and privacy scores, base model used, deployment type, and GPU type). No user or device information is collected. This data is used to prioritize product improvements and will be shared in aggregate with the community. It is not used to track any individual user behavior.
Comment thread
mckornfield marked this conversation as resolved.
Resolved

You may opt out of telemetry collection at any time. Opting out applies only to data collection by the NeMo Safe Synthesizer library itself. To disable telemetry in a YAML config, set:

```yaml
emit_telemetry: false
```

To disable telemetry for one CLI invocation, pass `--no-emit-telemetry`:

```bash
safe-synthesizer run --no-emit-telemetry --data-source my_data.csv
```

To disable telemetry for the current shell, set `NEMO_TELEMETRY_ENABLED=false` (other accepted disabling values: `0`, `no`) in your environment before running:

```bash
export NEMO_TELEMETRY_ENABLED=false
```

Comment thread
mckornfield marked this conversation as resolved.
Resolved
Use of third-party endpoints, including NVIDIA Build: NeMo Safe Synthesizer can be configured to use various inference endpoints, including build.nvidia.com (NVIDIA Build). If you choose to use NVIDIA Build or any other third-party endpoint, that endpoint's own terms of service and privacy practices apply independently of this library. Any opt-out you exercise within NeMo Safe Synthesizer does not extend to data collection by your chosen endpoint. NVIDIA Build is intended for evaluation and testing purposes only and may not be used in production environments. Do not submit any confidential information or personal data when using NVIDIA Build.

## License

NeMo Safe Synthesizer is licensed under the [Apache License 2.0](https://github.com/NVIDIA-NeMo/Safe-Synthesizer/blob/main/LICENSE).
Expand Down
16 changes: 16 additions & 0 deletions docs/user-guide/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,22 @@ export SAFE_SYNTHESIZER_CPU_COUNT=4
Defaults to `max(1, cpu_count - 1)` (one CPU left free), further capped so
there are at least 1,000 records per worker.

### `NEMO_TELEMETRY_ENABLED`

Controls whether telemetry is sent for train/generate events.

Defaults to `true`. Set it to `false` to disable telemetry for the current shell:

```bash
export NEMO_TELEMETRY_ENABLED=false
```

You can also disable telemetry in a Safe Synthesizer config file:

```yaml
emit_telemetry: false
```

---

## Container Usage
Expand Down
1 change: 1 addition & 0 deletions script/slurm/env_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export UV_PYTHON_BIN_DIR="${LUSTRE_DIR}/.local/bin"
export UV_TOOL_DIR="${LUSTRE_DIR}/.local/share/uv/tools"
export HF_HOME="${LUSTRE_DIR}/.cache/huggingface"
export WANDB_MODE="online" # "online", "offline" or "disabled"
export NEMO_DEPLOYMENT_TYPE="slurm" # sets the values for telemetry
Comment thread
mckornfield marked this conversation as resolved.
Resolved

# NSS CLI environment variables (used by safe-synthesizer CLI via pydantic-settings)
# These are picked up automatically by CLISettings in the CLI:
Expand Down
54 changes: 45 additions & 9 deletions src/nemo_safe_synthesizer/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys
from collections.abc import Callable
from pathlib import Path
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

import click

Expand All @@ -20,6 +20,7 @@
)
from ..errors import UserError
from ..observability import traced_user
from ..telemetry import DeploymentTypeEnum, TaskStatusEnum
from ..tooling import PreflightRenderContext, render_preflight_report
from .settings import CLISettings
from .utils import (
Expand Down Expand Up @@ -158,12 +159,28 @@ def common_run_options(f: Callable[..., object]) -> Callable[..., object]:
"If both env var and CLI option are provided, the CLI option takes precedence.",
)
)
options.append(
click.option(
"--no-emit-telemetry",
is_flag=True,
default=False,
help="Disable NeMo Safe Synthesizer telemetry for this command.",
)
)
Comment thread
mckornfield marked this conversation as resolved.
Resolved
Comment thread
mckornfield marked this conversation as resolved.
Resolved
# Apply each option decorator in reverse order (decorators apply bottom-up)
for option in reversed(options):
f = option(f)
return f


def _parse_run_overrides(kwargs: dict[str, Any], *, no_emit_telemetry: bool) -> dict[str, Any]:
"""Parse generated config options plus manual run aliases into config overrides."""
overrides = parse_overrides(kwargs)
if no_emit_telemetry:
overrides["emit_telemetry"] = False
return overrides


def _format_dataset_runtime_info(data: pd.DataFrame) -> str:
"""Format dataset size summary for validate runtime info."""
return f"{len(data):,} rows, {len(data.columns):,} columns"
Expand Down Expand Up @@ -312,6 +329,7 @@ def run(
wandb_mode: str | None = None,
wandb_project: str | None = None,
dataset_registry: str | None = None,
no_emit_telemetry: bool = False,
validate: bool = False,
**kwargs: object,
) -> None:
Expand All @@ -336,7 +354,7 @@ def run(
verbose=verbose,
wandb_mode=wandb_mode,
wandb_project=wandb_project,
synthesis_overrides=parse_overrides(kwargs),
synthesis_overrides=_parse_run_overrides(kwargs, no_emit_telemetry=no_emit_telemetry),
dataset_registry=dataset_registry,
)

Expand All @@ -361,7 +379,12 @@ def run(
from ..sdk.library_builder import SafeSynthesizer

assert df is not None
nss: SafeSynthesizer = SafeSynthesizer(config=config, workdir=workdir).with_data_source(df)
nss: SafeSynthesizer = SafeSynthesizer(
config=config,
workdir=workdir,
emit_telemetry=config.emit_telemetry,
deployment_type=DeploymentTypeEnum.CLI,
).with_data_source(df)

if validate:
_run_validate_and_render(nss, settings=settings, workdir=workdir, config=config, data=df)
Expand Down Expand Up @@ -402,6 +425,7 @@ def run_train(
wandb_mode: str | None = None,
wandb_project: str | None = None,
dataset_registry: str | None = None,
no_emit_telemetry: bool = False,
validate: bool = False,
**kwargs: object,
) -> None:
Expand All @@ -422,7 +446,7 @@ def run_train(
verbose=verbose,
wandb_mode=wandb_mode,
wandb_project=wandb_project,
synthesis_overrides=parse_overrides(kwargs),
synthesis_overrides=_parse_run_overrides(kwargs, no_emit_telemetry=no_emit_telemetry),
dataset_registry=dataset_registry,
)

Expand All @@ -443,7 +467,12 @@ def run_train(
try:
with traced_user("SafeSynthesizer"):
assert df is not None
nss = SafeSynthesizer(config, workdir=workdir).with_data_source(df)
nss = SafeSynthesizer(
config,
workdir=workdir,
emit_telemetry=config.emit_telemetry,
deployment_type=DeploymentTypeEnum.CLI,
).with_data_source(df)

if validate:
_run_validate_and_render(nss, settings=settings, workdir=workdir, config=config, data=df)
Expand Down Expand Up @@ -489,6 +518,7 @@ def run_generate(
auto_discover_adapter: bool = False,
wandb_resume_job_id: str | None = None,
dataset_registry: str | None = None,
no_emit_telemetry: bool = False,
**kwargs: object,
) -> None:
"""Run the generation stage only.
Expand All @@ -513,7 +543,7 @@ def run_generate(
verbose=verbose,
wandb_mode=wandb_mode,
wandb_project=wandb_project,
synthesis_overrides=parse_overrides(kwargs),
synthesis_overrides=_parse_run_overrides(kwargs, no_emit_telemetry=no_emit_telemetry),
dataset_registry=dataset_registry,
)

Expand All @@ -526,11 +556,16 @@ def run_generate(
auto_discover_adapter=auto_discover_adapter,
wandb_resume_job_id=wandb_resume_job_id,
)
from ..sdk.library_builder import SafeSynthesizer
from ..sdk.library_builder import SafeSynthesizer, _emit_nss_telemetry

final_output_file = settings.output_file or workdir.output_file
with traced_user("SafeSynthesizer"):
nss = SafeSynthesizer(config, workdir=workdir)
nss = SafeSynthesizer(
config,
workdir=workdir,
emit_telemetry=config.emit_telemetry,
deployment_type=DeploymentTypeEnum.CLI,
)

# Only set data source if provided via --data-source
# Otherwise, load_from_save_path() will load from cached files
Expand All @@ -542,9 +577,10 @@ def run_generate(
nss.load_from_save_path()
.process_data()
.generate()
.evaluate()
.evaluate(emit_telemetry=False)
.save_results(output_file=final_output_file)
)
_emit_nss_telemetry(nss, TaskStatusEnum.COMPLETED)
nss.results.summary.log_summary(run_logger)
nss.results.summary.timing.log_timing(run_logger)
run_logger.info(f"Generation complete. Results saved to: {final_output_file}")
Expand Down
7 changes: 7 additions & 0 deletions src/nemo_safe_synthesizer/config/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class SafeSynthesizerParameters(Parameters):
default_factory=PreflightParameters,
)

emit_telemetry: bool = Field(
default=True,
description="Whether to emit anonymous Safe Synthesizer telemetry events.",
)

@field_validator("privacy", mode="after", check_fields=False)
def check_dp_compatibility(
cls, dp_params: DifferentialPrivacyHyperparams | None, info: ValidationInfo
Expand Down Expand Up @@ -176,4 +181,6 @@ def from_params(cls, **kwargs) -> "SafeSynthesizerParameters":
extra["replace_pii"] = kwargs["replace_pii"]
if "preflight" in kwargs:
extra["preflight"] = kwargs["preflight"]
if "emit_telemetry" in kwargs:
extra["emit_telemetry"] = kwargs["emit_telemetry"]
return cls(**extra)
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def convert(
"""
if value == AUTO_STR:
return AUTO_STR
return self.base_type.convert(value, param, ctx) # type: ignore[return-value]
return self.base_type.convert(value, param, ctx)


def _has_string_literal(args: set) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion src/nemo_safe_synthesizer/generation/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def _process_text_generation(self, text: str) -> ParsedResponse:
valid_indices = [i for i, r in enumerate(group_records) if r.is_valid]
valid_sorted = sorted(
(group_records[i] for i in valid_indices),
key=lambda r: r.parsed[self.order_by], # type: ignore[index]
key=lambda r: r.parsed[self.order_by],
Comment thread
mckornfield marked this conversation as resolved.
Resolved
)
for i, record in zip(valid_indices, valid_sorted, strict=True):
group_records[i] = record
Expand Down
10 changes: 10 additions & 0 deletions src/nemo_safe_synthesizer/llm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,13 @@ def get_quantization_config(quantization_bits: Literal[4, 8]) -> BitsAndBytesCon
)
else:
raise ValueError(f"Invalid quantization bits: {quantization_bits}")


def get_device_name() -> str:
"""Get the name of the current device (first index). Returns 'undefined' if the device is not available."""
try:
import torch

return torch.cuda.get_device_properties(0).name
except Exception:
return "undefined"
4 changes: 3 additions & 1 deletion src/nemo_safe_synthesizer/sdk/config_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ConfigBuilder(object):
def __init__(self, config: SafeSynthesizerParameters | None = None) -> None:
self._nss_config: SafeSynthesizerParameters | None = config
if self._nss_config is not None:
self._emit_telemetry_config = self._nss_config.emit_telemetry
self._evaluation_config = self._nss_config.evaluation
self._replace_pii_config = self._nss_config.replace_pii
self._privacy_config: DifferentialPrivacyHyperparams | None = self._nss_config.privacy
Expand All @@ -84,6 +85,7 @@ def __init__(self, config: SafeSynthesizerParameters | None = None) -> None:
self._privacy_config: DifferentialPrivacyHyperparams = DifferentialPrivacyHyperparams()
self._training_config: TrainingHyperparams = TrainingHyperparams()
self._time_series_config: TimeSeriesParameters = TimeSeriesParameters()
self._emit_telemetry_config = True
Comment thread
nina-xu marked this conversation as resolved.
Resolved

self._data_source: DataSource | None = None
self._classify_model_provider: str | None = None
Expand Down Expand Up @@ -313,7 +315,7 @@ def _resolve_nss_config(self) -> None:
logger.debug(f"Using default values for {pg}")
case _:
raise ValueError(f"Input must be a BaseModel, dictionary, or None: {type(param)}")
self._nss_config = SafeSynthesizerParameters(**params_to_use)
self._nss_config = SafeSynthesizerParameters(**params_to_use, emit_telemetry=self._emit_telemetry_config)

# Inject classify_model_provider into PII replacer config if set
if self._classify_model_provider and self._nss_config.replace_pii:
Expand Down
Loading
Loading