Skip to content

feat(automodel): MLflow run tracking for the diffusion recipe, off by default - #1546

Draft
eshaw2 wants to merge 1 commit into
mainfrom
feat/automodel/mlflow-run-tracking
Draft

eshaw2 wants to merge 1 commit into
mainfrom
feat/automodel/mlflow-run-tracking

Conversation

@eshaw2

@eshaw2 eshaw2 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Summary

AutoModel's diffusion recipe has no run tracking. It logs to wandb only, while upstream's MLflow utilities (nemo_automodel/components/loggers/mlflow_utils.py) are wired into the LLM and VLM recipes and never called by the diffusion one. This adds a Primus patch that connects them, so a diffusion run's resolved config, environment, logs, traces and performance summary are recorded against the run that produced them.

Off by default, and that is the main thing to check in review. primus_mlflow.enable defaults to false; run_patches evaluates the patch's condition at call time, so a disabled patch imports nothing, contacts no server and costs nothing. Existing runs, CI and MAD are unaffected by this PR landing.

No new dependency — mlflow==3.11.1 and pyrsmi are already in requirements.txt.

Written as a registered before_train patch rather than a trainer edit, following the backend package's own guidance that Primus-side behaviour is added as patches. Discovery is automatic, so neither patches/__init__.py nor automodel_pretrain_trainer.py changes. Teardown runs in a finally, the same shape torch_profiler_patches.py already uses — after_train is not dispatched by this backend, so a teardown patch registered there would silently never fire.

Changes

  • primus/backends/automodel/patches/mlflow_patches.py (new, 1408 lines)
    • Inputs, once before step 1: resolved config including feature-gate settings, command line, filtered environment, RCCL version, node list, and the provenance record tools/auto_benchmark already defines (image digest, commits and submodule pins, ROCm and framework versions, GPU) — reused rather than redefined.
    • Outputs, after the loop and outside the timed region: logs from all ranks; profiler traces and TraceLens reports when profiling is on, with rank selection and a size cap; a perf/* summary (median step time, samples/s/GPU, peak memory) parsed from the recipe's own [TRAIN] lines — the same source auto_benchmark reads, so the two cannot disagree, and it adds no per-step cost.
    • Real terminal status: FINISHED / FAILED / KILLED plus a termination reason, covering the blind spots in upstream's sys.excepthook (exceptions caught by a caller, KeyboardInterrupt as a BaseException, worker-thread exceptions via threading.excepthook). A failed upload warns and never fails the run, and tracking errors never mask the original exception.
    • Secret filtering by name and value. Name side is an allow-list rather than a deny-list: a deny-list fails open on every variable nobody anticipated. Value side screens the values, because a credential can sit in a variable whose name is on the allow-list.
  • Config surface — mlflow: (AutoModel-native, deliberately not a primus_ section so it reaches the typed config) and primus_mlflow: (Primus-only, stripped by strip_primus_keys) added to pre_trainer.yaml, flux_synth_pre_trainer.yaml and wan_synthetic_pre_trainer.yaml. Every key is declared, so a typo surfaces as a trainer warning rather than silently doing nothing. Flag semantics mirror the Megatron path's disable_mlflow / mlflow_upload_*.
  • Wan configs — wan2_1_t2v_{1_3b,14b}.yaml model configs, plus wan2_1_t2v_{1_3b,14b}-mock21f.yaml and a 14B FP8 variant as synthetic examples.
  • Flux — flux_1_schnell-synthetic-fp8.yaml.
  • Tests — tests/unit_tests/backends/automodel/test_mlflow_patches.py, 77 tests, mirroring the existing Megatron MLflow test files.
  • One unrelated line — .pre-commit-config.yaml: the thirdparty-lock hook invoked python, which does not exist in the dev image, so the hook failed on an unmodified tree. Changed to python3. Happy to split this into its own PR if preferred.

Testing

Unit — 77 tests, run without torch or mlflow present. They cover: disabled-by-default does nothing (no import, no server contact, no overhead); inputs captured exactly once; a failed upload warns rather than raising; and the secret filter holds against a fixture environment carrying credential-shaped variables under both allowed and disallowed names.

End to end against a live tracking server — Flux-schnell and Wan 2.1 1.3B, BF16 and FP8, one node, 8× MI355X. Each run recorded its inputs, artifacts and perf/* summary, terminated FINISHED, and the logged parameters were read back and checked for anything credential-shaped. Profiler traces and TraceLens reports were separately exercised end to end.

Overhead — Summary logging is parsed from the log after the loop returns, so it is outside the timed region by construction.

Known gaps, deliberately left:

  • No TFLOP/s in the summary. The recipe logs none, and the field is absent rather than estimated. Tracked separately.
  • per_step defaults off pending that A/B being repeated on a second model — Flux is the worst case for step time, a video model is the worst case for artifact volume.
  • upload_tracelens_report requires TraceLens in the image. Unlike the Megatron path this never pip-installs at run time: a job that reaches for the network during teardown is a job that hangs during teardown.

Reviewers

  • Primary maintainers: wenxie-amd, Xiaoming-AMD. Reach out to them with any questions about this PR.
  • Outside China Standard Time (UTC+8) working hours, for urgent issues: vidushi8, lorri-rao, GeneDer, amd-fuyuajin, JohnQin-llm

@github-actions

Copy link
Copy Markdown

Primary maintainers: @wenxie-amd @Xiaoming-AMD

Reach out to the primary maintainers with any questions about this PR.

Outside China Standard Time (UTC+8) working hours, for urgent issues you can also reach out to: vidushi8, lorri-rao, GeneDer, amd-fuyuajin, JohnQin-llm.

import tempfile

path = _os.path.join(tempfile.mkdtemp(), "info.log")
open(path, "w").write(line + "\n")
#
# So: capture host-side values at the log window, hand them to a queue, and let
# a daemon thread do the network. Nothing in the training loop ever waits.
_PER_STEP_INSTALLED = "_primus_mlflow_per_step_installed"
def test_patch_is_registered_for_before_train(self):
"""`after_train` is never dispatched by AutoModelPretrainTrainer, so a
teardown patch registered there would silently never fire."""
import primus.backends.automodel.patches # noqa: F401
@eshaw2
eshaw2 requested review from jasainio and olehtika November 25, 2026 13:40

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant