Skip to content

fix(compile): validate joint graph replay contracts - #9

Open
yu-chen-code wants to merge 1 commit into
masterfrom
feat-graph-execution-contract
Open

yu-chen-code wants to merge 1 commit into
masterfrom
feat-graph-execution-contract

Conversation

@yu-chen-code

@yu-chen-code yu-chen-code commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

What type of PR is this?
/kind feature

What does this PR do / why do we need it:

Refreshed on 2026-11-09 against fork/upstream master a6be99d3. PR1421 is now merged upstream, so its duplicate prerequisite has been removed. Current head: d7d0c09e359a459ba9d6416e08d0bfb38a63a105; retained feature/dependency commits: d7d0c09e. Git range-diff confirms unchanged feature patches. Focused CPU regression on this exact head: 149 JUnit records, 0 failures, 0 errors. The isolated refresh environments now include master-required PEFT 0.21.2 and accelerate 1.13.0; pip check passes. All numerical runs and older source hashes below are pre-refresh evidence. NPU precision training and formal upstream CI were not rerun for this rebase.

Reject stale joint-graph replays before executing operators or collectives, and use the executable returned by the pass pipeline.

  • Extend the existing input guards to static graphs. Shape, stride, storage offset, dtype, device, layout, requires-grad, Python constants, pytree structure and tensor aliasing must match the captured contract. Symbolic graphs retain their existing ShapeEnv guards and selected dynamic dimensions.
  • Snapshot module identity/type/training mode and parameter/buffer roles, aliases and storage metadata. In-place parameter and buffer value updates remain valid; structural cases use a fresh model/compiler when prepared storage ownership changes. Refresh the storage signature after FSDP transforms so normal physical sharding is accepted. This is an explicit runtime contract, not a complete Dynamo guard set for arbitrary Python attributes.
  • Retain a terminal pass's returned executable and transfer missing joint-runtime metadata for gradient ordering, loss dictionaries, state inputs and FSDP layouts. Backend wrappers can replace the traced GraphModule without losing the training result contract.
  • Keep the existing shape/metadata helpers and joint executor. There is no new Trainer, automatic recapture loop or per-microbatch collective for guards. Distributed callers must change inputs/configuration coherently across participating ranks.

Validation on deploy32, Python3.12.13, Torch2.15.0.dev20261005+cpu and torch-npu2.15.0:

  • The affected compiler, tracer and dynamic-shape tests passed 63 tests and 43 subtests. They cover rejection before execution, live optimizer values, module/parameter-role changes, and replacement executables with loss dictionaries and exact gradients.
  • The final replay-contract source passed all three affected files: 63 tests and 43 subtests. Both public-CI Pylint configurations have no newly introduced finding. Each raw run retains one arguments-renamed warning in the unchanged KeywordModel helper; the exact prerequisite reproduces the same object/message in both configurations. No suppression or filter is added, and raw lint exit 0 is not claimed.
  • The full compile regression has two pre-existing strict CPU-Inductor equality failures. The unchanged prerequisite reproduces the identical values: 0.701689600944519 versus 0.7016897201538086 in full/regional modes. Assertions remain unchanged; an all-tests-passed claim is not made.
  • pip check, committed-source SHA verification and editable-import verification passed. This change adds no eager training mathematics; new eight-card or full DSV4.1 acceptance is not claimed.

Reproduction:

python -m pytest -q tests/ut/compile/test_compiler.py \
  tests/ut/compile/test_dynamic_shapes.py tests/ut/compile/test_tracer.py
python -m pytest -q tests/ut/compile
python -m pip check

Exact source manifests, commands, raw test logs and lint comparison are retained under T020 runs/20261106-graph-capability-spikes. Formal upstream CI is not requested by this fork PR.

Which issue(s) this PR fixes:

None.

Code review checklist [illustration]:

  • whether to verify the function's return value (It is forbidden to use void to mask the return values of security functions and self-developed functions. C++ STL functions can be masked if there is no problem)
  • Whether to comply with SOLID principle / Demeter's law
  • Whether there is UT test case && the test case is a valid (if there is no test case, please explain the reason)
  • Whether the API change is involved
  • Whether official document modification is involved

@yu-chen-code
yu-chen-code force-pushed the feat-graph-execution-contract branch from b93d031 to 94398ff Compare November 6, 2026 15:59
@yu-chen-code
yu-chen-code force-pushed the feat-graph-execution-contract branch from 94398ff to d7d0c09 Compare November 9, 2026 11:24
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