Python Sdk Reference
Install
pip install denpex
Modules
denpex— top-level wrapper for training scripts.denpex.sdc— SDC canary + runs.denpex.instrument— per-layer metric hooks.denpex.ddp— DDP context.denpex.fsdp— FSDP integration.denpex.deepspeed— DeepSpeed integration.denpex.megatron— Megatron-LM integration.denpex.jax— JAX integration.denpex.tensorflow— TensorFlow integration.denpex.checkpoint— checkpoint integrity.denpex.nccl— NCCL timing.
CLI
denpex annotate
denpex incident list
denpex incident show <id>
denpex incident approve <id>
denpex checkpoint validate <path>
denpex rank map
Decorator
import denpex
@denpex.wrap(name="my-gpt-run", tenant="acme")
def main(cfg):
train(cfg)
Trace Backing
The wrapper is a context manager that:
- Spawns a daemon that re-execs
pythonwith PTY. - Captures stdout/stderr (last 10 MB truncated).
- Records per-step metrics.
- Emits a
TrainingEventat every Python error. - Emits a final
TrainingEvent::Doneon clean exit.
Configuration
| Env var | Default | Purpose |
|---|---|---|
DENPEX_TOKEN | (none) | Auth token |
DENPEX_TENANT | (none) | Tenant ID |
DENPEX_SAMPLE_EVERY_N_STEPS | 10 | Layer sampling |
DENPEX_SDC_EVERY_N_STEPS | 20 | SDC canary cadence |
DENPEX_PROFILE_TRACE | 0 | Set 1 to capture torch profiler |
API Stability
- All public modules follow SemVer.
denpex._internalis unsupported.
Tests
Each module ships unit tests:
denpex_sdk/tests/test_*.py
Integration tests run against a mock OTLP receiver.