Metadata-Version: 2.4
Name: denpex-sdk
Version: 0.2.4
Summary: Denpex SDK: API client for GPU training-failure diagnosis, plus SDC detection and checkpoint validation.
Author: Denpex
License: Proprietary
Project-URL: Homepage, https://denpex.com
Project-URL: Documentation, https://denpex.com/docs/integrations
Project-URL: API Reference, https://denpex.com/docs/api
Project-URL: Python Agent & CLI, https://denpex.com/docs/agent
Project-URL: VS Code Extension, https://denpex.com/vscode
Project-URL: Open VSX Extension, https://denpex.com/openvsx
Project-URL: GPU Failure Encyclopedia, https://denpex.com/failures
Project-URL: Free GPU Debugging Tools, https://denpex.com/tools
Project-URL: Changelog, https://denpex.com/changelog
Project-URL: Repository, https://github.com/Denpex/gpu-failure-cheatsheet
Project-URL: Issue Tracker, https://denpex.com/contact
Keywords: denpex,gpu,cuda,nccl,pytorch,slurm,vllm,xid,mlops,diagnostics
Classifier: Programming Language :: Python :: 3
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: torch
Requires-Dist: torch>=2.1; extra == "torch"

# denpex-sdk

Zero-third-party Python helpers for SDC detection (per-layer weight/gradient
norms, NaN/Inf checks, optimizer state validation) and asynchronous
checkpoint validation (manifest integrity + content checksums) for S3/Lustre.

## Cloud diagnosis client

```python
from denpex_sdk import DenpexClient

client = DenpexClient(api_key="dpx_...")
result = client.diagnose(
    open("training.log").read(),
    jobName="llama3-405b-pretrain",
    telemetry={"jobId": "slurm-1842"},
)
print(result["meta"]["failureType"], result["meta"].get("confidence"))
print(result["fix"]["summary"])
print(result["fix"]["action"])
client.feedback(result["diagnosisId"], "worked")
```

The client reads `DENPEX_API_KEY` when `api_key` is omitted and calls the live
`/api/diagnose` contract. Its default 320-second timeout covers the API's
290-second deep-diagnosis window. Optional arguments such as `telemetry`,
`codeContext`, `topologyMap`, `runtimeHours`, and `gpuRate` pass through.

## SDC detection

```python
from denpex_sdk import SdcHook, install_sdc_hooks

hook = install_sdc_hooks(model, SdcHook(max_weight_norm=1e4, max_grad_norm=1e4))
weight_report = hook.inspect()
grad_report = hook.inspect_gradients()
opt_report = hook.inspect_optimizer(optimizer)
```

## Checkpoint validation

```python
from denpex_sdk import build_manifest, manifest_to_json, manifest_from_json, validate_checkpoint

manifest = build_manifest(["/checkpoints/step-1000/"], metadata={"job_id": "..."})
with open("/checkpoints/step-1000/manifest.json", "w") as handle:
    handle.write(manifest_to_json(manifest))

with open("/checkpoints/step-1000/manifest.json") as handle:
    expected = manifest_from_json(handle.read())

result = validate_checkpoint(["/checkpoints/step-1000/"], expected_manifest=expected)
assert result.valid
```

---

## Official Denpex Ecosystem & Documentation

| Resource | Description | Link |
| :--- | :--- | :--- |
| **Denpex Platform** | Deterministic GPU and ML training failure diagnostics | [denpex.com](https://denpex.com) |
| **Documentation Hub** | Quickstart guides, architecture, and operational reference | [denpex.com/docs](https://denpex.com/docs) |
| **Python Agent & CLI** | On-host monitoring, evidence capture, and zero-egress CLI | [denpex.com/docs/agent](https://denpex.com/docs/agent) |
| **REST API Reference** | Programmatic `/api/diagnose` and preflight endpoints | [denpex.com/docs/api](https://denpex.com/docs/api) |
| **VS Code Extension** | Offline GPU crash diagnostics in VS Code | [denpex.com/vscode](https://denpex.com/vscode) |
| **Open VSX Extension** | Extension for Cursor, Windsurf, VSCodium, and Gitpod | [denpex.com/openvsx](https://denpex.com/openvsx) |
| **Failure Encyclopedia** | 500+ documented CUDA, NCCL, Xid, Slurm, and vLLM failures | [denpex.com/failures](https://denpex.com/failures) |
| **Free GPU Tools** | VRAM, NCCL, DeepSpeed ZeRO, and Slurm calculators | [denpex.com/tools](https://denpex.com/tools) |
| **NVIDIA Xid Reference** | Hardware vs software Xid fault routing table | [denpex.com/xid](https://denpex.com/xid) |
| **Release Changelog** | Platform, agent, SDK, and extension release notes | [denpex.com/changelog](https://denpex.com/changelog) |

