Add provider-agnostic training observability with optional W&B backend - #52
Add provider-agnostic training observability with optional W&B backend#52iamdarshg wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 452941bc79
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "train/step_time_sec": float(step_time), | ||
| "train/epoch": float(self.current_epoch), | ||
| } | ||
| metrics_payload.update(collect_gpu_stats()) |
There was a problem hiding this comment.
Remove per-step
nvidia-smi subprocess in hot path
train() now calls collect_gpu_stats() on every optimization step, and that helper shells out to nvidia-smi each time with a 1s timeout. On GPU runs this adds a process spawn in the tight training loop (and can stall for the timeout when nvidia-smi is slow/unavailable), which can materially reduce training throughput and distort step-time metrics; this should be sampled less frequently or collected asynchronously/cached.
Useful? React with 👍 / 👎.
Motivation
Description
better_ai/monitoring/observability.pyimplementingBaseObservabilityBackend,NoOpObservabilityBackend,WandBObservabilityBackend,ObservabilityConfig,ObservabilityAdapter, and acollect_gpu_stats()helper.EnhancedMoETrainerby callingObservabilityAdapter.from_config(config)in initialization, invokingstart_run()at training start, logging per-step metrics (loss, aux loss,lr,grad_norm,tokens_per_sec,step_time_sec, epoch) augmented withcollect_gpu_stats(), and callingfinish_run()on interrupted/failed/completed flows; also emiteval/train_lossfrom the HTSR monitor step.better_ai.monitoringand added README documentation with environment variable and config examples forBETTER_AI_OBSERVABILITY_BACKEND,BETTER_AI_RUN_NAME,WANDB_PROJECT,WANDB_ENTITY, andWANDB_MODE.Testing
better_ai/tests/test_observability.pywhich verifies that the adapter defaults to the no-op backend when disabled and thatcollect_gpu_stats()contains the expected keys.python -m pytest better_ai/tests/test_observability.py -qand the test suite passed (3 passed).Codex Task