Repository navigation
[WIP] Propagate upstream gradients in the TensorFlow backend - #924
Draft
linjiaye929 wants to merge 1 commit into
Draft
linjiaye929 wants to merge 1 commit into
linjiaye929 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Types of changes
Motivation and context
TensorFlowBackend.set_gradients currently discards the upstream cotangent. Multiplying a loss by zero, a negative coefficient, or a positive coefficient therefore leaves its supplied gradients unchanged. For example, for x=[1,2] and a supplied gradient 2*x, multiplying the returned scalar by 7 gives [2,4] instead of [14,28].
Apply the upstream cotangent to each supplied gradient with tf.nest.map_structure. The forward value, public API, and other backends are unchanged.
Related: #923 explicitly documents this independent TensorFlow backend issue as outside its scope. This PR does not modify dmmot or the JAX work in #917.
Validation and limits
This is not a full current-source test-suite pass. Building master was blocked when the compiler was killed while compiling the unrelated BSP/Eigen extension, including lower-optimization attempts. Temporary build-option changes were restored and are not part of this PR. The wheel-backed integration checks use released native extensions, not current master native code. The full compatibility matrix, GPU behavior, and remote CI have not been verified.
Keeping this PR as a Draft while that validation remains outstanding.
PR checklist
The unchecked test box is intentional: targeted checks passed as described above, but the full source suite did not run. No documentation API change is needed; documentation artifacts were not built.
AI assistance
Prepared with AI assistance. The defect, minimal change, and regression checks were independently reviewed by a second assistant; this is not a claim of human or maintainer review.