{"library":"nv-one-logger-pytorch-lightning-integration","title":"NV One Logger PyTorch Lightning Integration","description":"The `nv-one-logger-pytorch-lightning-integration` library (current version 2.3.1) provides wrappers to enable training job telemetry for PyTorch Lightning applications. It integrates with PyTorch Lightning's callback mechanism, supplementing it to ensure support for asynchronous checkpointing and certain application lifecycle events not fully covered by Lightning's native callbacks. The library aims for automatic telemetry collection and seamless integration with the NVIDIA One Logger training telemetry system, and has a healthy version release cadence.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install nv-one-logger-pytorch-lightning-integration"],"cli":null},"imports":["from nv_one_logger.training_telemetry.integration.pytorch_lightning import hook_trainer_cls","from nv_one_logger.training_telemetry.api.training_telemetry_provider import TrainingTelemetryProvider"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport torch\nfrom pytorch_lightning import LightningModule, Trainer\nfrom torch.utils.data import DataLoader, Dataset\nfrom nv_one_logger.training_telemetry.api.training_telemetry_provider import TrainingTelemetryProvider\nfrom nv_one_logger.training_telemetry.integration.pytorch_lightning import hook_trainer_cls\n\n# --- Dummy components for a runnable example ---\nclass DummyDataset(Dataset):\n    def __len__(self):\n        return 64\n    def __getitem__(self, idx):\n        return torch.randn(10), torch.randint(0, 2, (1,)).squeeze()\n\nclass SimpleModel(LightningModule):\n    def __init__(self):\n        super().__init__()\n        self.linear = torch.nn.Linear(10, 2)\n    def training_step(self, batch, batch_idx):\n        x, y = batch\n        y_hat = self.linear(x)\n        loss = torch.nn.functional.cross_entropy(y_hat, y)\n        self.log('train_loss', loss)\n        return loss\n    def configure_optimizers(self):\n        return torch.optim.Adam(self.parameters(), lr=0.02)\n\n# --- NV One Logger Integration ---\n# 1. Configure the TrainingTelemetryProvider (e.g., with a simple console exporter for demo)\n# In a real scenario, this would be configured with a proper exporter like OpenTelemetry, WandB, etc.\n# For a console exporter, you might not need extensive config, but for others, it's crucial.\n# For demonstration, we'll assume a basic provider without complex exporter setup is sufficient.\n# In a real application, you'd likely use .with_exporter(OTELHttpExporter(...))\nTrainingTelemetryProvider.instance().configure_provider()\n\n# 2. Hook the PyTorch Lightning Trainer class\nHookedTrainer, nv_one_logger_callback = hook_trainer_cls(Trainer, TrainingTelemetryProvider.instance())\n\n# 3. Instantiate your model and data loaders\nmodel = SimpleModel()\ntrain_dataset = DummyDataset()\ntrain_dataloader = DataLoader(train_dataset, batch_size=4)\n\n# 4. Use the HookedTrainer instance\n# Pass it the same parameters you would pass to the regular Lightning Trainer.\n# The nv_one_logger_callback is automatically added, no need to pass it explicitly.\ntrainer = HookedTrainer(\n    max_epochs=1,\n    limit_train_batches=2, # Limit batches for a quick run\n    logger=False, # Disable default PTL loggers if not needed, or add others\n    accelerator='cpu' # Ensure it runs on CPU for general demonstration\n)\n\n# 5. Train the model\ntrainer.fit(model, train_dataloader)\n\nprint(\"Training complete with NV One Logger integration.\")\n","lang":"python","description":"This quickstart demonstrates how to integrate `nv-one-logger` with a basic PyTorch Lightning training loop. It involves configuring the `TrainingTelemetryProvider` and then using `hook_trainer_cls` to wrap the standard `Trainer`. The `HookedTrainer` automatically adds the necessary callbacks for telemetry collection. For production, the `TrainingTelemetryProvider` would be configured with a specific exporter (e.g., OpenTelemetry, Weights & Biases) to send telemetry data to a backend.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"2.3.1","pypi_latest":"2.3.1","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":40,"avg_install_s":75.7,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"nv-one-logger-pytorch-lightning-integration","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"nv-one-logger-pytorch-lightning-integration","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":85,"import_time_s":null,"mem_mb":null,"disk_size":"4.7G"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"nv-one-logger-pytorch-lightning-integration","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"nv-one-logger-pytorch-lightning-integration","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":82.5,"import_time_s":null,"mem_mb":null,"disk_size":"4.8G"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"nv-one-logger-pytorch-lightning-integration","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"nv-one-logger-pytorch-lightning-integration","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":72.9,"import_time_s":null,"mem_mb":null,"disk_size":"4.8G"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"nv-one-logger-pytorch-lightning-integration","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"nv-one-logger-pytorch-lightning-integration","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":62.5,"import_time_s":null,"mem_mb":null,"disk_size":"4.8G"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"nv-one-logger-pytorch-lightning-integration","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"nv-one-logger-pytorch-lightning-integration","exit_code":1,"wheel_type":null,"failure_reason":"timeout","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}