|
| 1 | +# NeMo Safe Synthesizer on DGX Spark |
| 2 | + |
| 3 | +Generate synthetic tabular data with quality and privacy guarantees — train, generate, and evaluate in one command. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +### 1. Build and launch the container |
| 8 | + |
| 9 | +```bash |
| 10 | +git clone https://github.com/NVIDIA-NeMo/Safe-Synthesizer.git && cd Safe-Synthesizer |
| 11 | +docker build -f containers/Dockerfile.spark -t nss-spark . |
| 12 | +docker run --gpus all --ipc=host --ulimit memlock=-1 -it --ulimit stack=67108864 nss-spark |
| 13 | +``` |
| 14 | + |
| 15 | +### 2. Run |
| 16 | + |
| 17 | +```python |
| 18 | +python -c " |
| 19 | +import pandas as pd, numpy as np |
| 20 | +from nemo_safe_synthesizer.sdk.library_builder import SafeSynthesizer |
| 21 | + |
| 22 | +# Sample data — replace with your own CSV or DataFrame |
| 23 | +np.random.seed(42) |
| 24 | +df = pd.DataFrame({ |
| 25 | + 'age': np.random.randint(18, 85, 500), |
| 26 | + 'income': np.random.lognormal(10.5, 0.8, 500).astype(int), |
| 27 | + 'credit_score': np.random.randint(300, 850, 500), |
| 28 | + 'default': np.random.choice(['yes', 'no'], 500, p=[0.15, 0.85]), |
| 29 | +}) |
| 30 | + |
| 31 | +builder = ( |
| 32 | + SafeSynthesizer() |
| 33 | + .with_data_source(df) |
| 34 | + .with_replace_pii() |
| 35 | + .with_generate(num_records=500) |
| 36 | + .with_evaluate() |
| 37 | +) |
| 38 | +builder.run() |
| 39 | + |
| 40 | +s = builder.results.summary |
| 41 | +print(f'Quality (SQS): {s.synthetic_data_quality_score}/10') |
| 42 | +print(f'Privacy (DPS): {s.data_privacy_score}/10') |
| 43 | +builder.save_results() |
| 44 | +" |
| 45 | +``` |
| 46 | + |
| 47 | +Expected: SQS ~8-9, DPS ~9-10. |
| 48 | + |
| 49 | +> **First run is slower.** Model weights (~6 GB) download from HuggingFace and Triton |
| 50 | +> JIT-compiles LoRA kernels for the GB10. Subsequent runs reuse cached weights and kernels. |
| 51 | + |
| 52 | +## Use Your Own Data |
| 53 | + |
| 54 | +```python |
| 55 | +from nemo_safe_synthesizer.sdk.library_builder import SafeSynthesizer |
| 56 | + |
| 57 | +builder = ( |
| 58 | + SafeSynthesizer() |
| 59 | + .with_data_source("your_data.csv") # or pass a DataFrame |
| 60 | + .with_replace_pii() |
| 61 | + .with_generate(num_records=1000) |
| 62 | + .with_evaluate() |
| 63 | +) |
| 64 | +builder.run() |
| 65 | +builder.save_results() |
| 66 | +``` |
| 67 | + |
| 68 | +Outputs are saved to `safe-synthesizer-artifacts/` — synthetic CSV and an HTML evaluation report. |
| 69 | + |
| 70 | +## Optional: Improve PII Detection |
| 71 | + |
| 72 | +Set a NIM API key for LLM-based column classification (more accurate than NER-only): |
| 73 | + |
| 74 | +```bash |
| 75 | +export NIM_ENDPOINT_URL="https://integrate.api.nvidia.com/v1" |
| 76 | +export NIM_API_KEY="your-key" # get one at build.nvidia.com/settings/api-keys |
| 77 | +``` |
| 78 | + |
| 79 | +## Optional: Differential Privacy |
| 80 | + |
| 81 | +```python |
| 82 | +builder = ( |
| 83 | + SafeSynthesizer() |
| 84 | + .with_data_source(df) |
| 85 | + .with_replace_pii() |
| 86 | + .with_generate(num_records=1000) |
| 87 | + .with_differential_privacy(dp_enabled=True, epsilon=8.0) |
| 88 | + .with_evaluate() |
| 89 | +) |
| 90 | +``` |
| 91 | + |
| 92 | +## Troubleshooting |
| 93 | + |
| 94 | +**Slow first generation batch?** Triton JIT-compiles LoRA kernels for the GB10 on first use. This is normal and only happens once per container session. |
| 95 | + |
| 96 | +**Memory issues between runs?** Flush the cache: |
| 97 | +```bash |
| 98 | +sudo sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches' |
| 99 | +``` |
| 100 | + |
| 101 | +**Why a container?** DGX Spark's CUDA 13 + aarch64 requires specific Triton, vLLM, and PyTorch versions. The container (`nvcr.io/nvidia/vllm:26.02-py3`) provides a tested stack where Unsloth training and vLLM generation work natively. |
| 102 | + |
| 103 | +**Full documentation:** [Safe Synthesizer User Guide](https://github.com/NVIDIA-NeMo/Safe-Synthesizer/blob/main/docs/user-guide/getting-started.md) |
0 commit comments