Skip to content

feat(engine): add Datum-based forward, backward, and optimizer APIs - #3614

Draft
HuiyingLi wants to merge 22 commits into
mainfrom
huiyingl/feat/datum-forward-backward
Draft

feat(engine): add Datum-based forward, backward, and optimizer APIs#3614
HuiyingLi wants to merge 22 commits into
mainfrom
huiyingl/feat/datum-forward-backward

Conversation

@HuiyingLi

Copy link
Copy Markdown
Contributor

What does this PR do ?

Introduce a Datum-first Engine boundary for forward, forward-backward, distributed batch routing, and optimizer updates so LLM/VLM recipes no longer own PP/CP/FSDP execution details.

Changelog

  • Add Datum collation metadata with explicit per-token, per-Datum, and replicated loss-input layouts.
  • Add structured Engine.forward and Engine.forward_backward results, including exact loss numerator and denominator statistics.
  • Route padded and packed THD batches through PP/CP while preserving Datum order and restoring typed per-token outputs.
  • Move gradient finalization, clipping, optimizer updates, MoE maintenance, LR scheduling, and FP8 FSDP scale refresh into Engine.optim_step.
  • Add planned multi-call accumulation with whole-window normalization and lifecycle validation.
  • Migrate LLM and VLM finetuning recipes to the Engine boundary and remove duplicated parallelism/update logic.
  • Add unit, distributed, recipe-integration, and packed PP/CP functional coverage.

Validation

  • 328 passed, 12 skipped across Engine, FP8, LLM recipe, and VLM recipe unit suites.
  • Real H100 PP2 and PP2xCP2 packed raw/final THD validation, including Datum/layout routing and output restoration.
  • Real 4xH100 PP2xDP2 FP8 run for two optimizer steps; every rank refreshed all 7 eligible local FP8 DTensor scales and the second step consumed the refreshed scales successfully.
  • Ruff checks and git diff --check pass.

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?

This is intentionally opened as a Draft while full CI and final reviewer feedback are pending.

Additional Information

  • Related issue: N/A
  • Multi-axis mRoPE with packed Transformer Engine THD context parallelism remains intentionally unsupported.

Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
…orward-backward

# Conflicts:
#	nemo_automodel/recipes/llm/train_ft.py
#	nemo_automodel/recipes/vlm/finetune.py
#	tests/unit_tests/recipes/test_finetune_vlm_helpers.py
#	tests/unit_tests/recipes/test_train_ft.py

Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

…orward-backward

Signed-off-by: HuiyingLi <willwin.lee@gmail.com>

# Conflicts:
#	nemo_automodel/components/distributed/pipelining/autopipeline.py
#	nemo_automodel/recipes/llm/train_ft.py
#	nemo_automodel/recipes/vlm/finetune.py
@HuiyingLi
HuiyingLi force-pushed the huiyingl/feat/datum-forward-backward branch from a238fa5 to 645e5ae Compare August 21, 2026 18:54
@HuiyingLi HuiyingLi changed the title feat(engine): unify Datum execution and optimizer lifecycle feat(engine): add Datum-based forward, backward, and optimizer APIs Aug 21, 2026
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
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