Preserve the copy rule boundary in the trtrs! pullback - #1247
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
sunxd3
marked this pull request as ready for review
July 10, 2026 11:08
yebai
reviewed
Jul 10, 2026
yebai
reviewed
Jul 10, 2026
yebai
approved these changes
Jul 10, 2026
yebai
left a comment
Member
There was a problem hiding this comment.
Two minor comments, good catches!
Collaborator
Author
|
thanks! |
yebai
added a commit
that referenced
this pull request
Jul 10, 2026
Resolved conflicts: - Project.toml: keep branch version 0.6.0 (breaking redesign); Graphs.jl drop from main kept. - src/tangents/dual.jl: keep deletion (two-field Dual removed in the redesign). - src/rules/blas.jl (7) + src/rules/lapack.jl (7): keep the branch's chunked Lifted forward frules; main's old Dual-based forward rules discarded; main's reverse fixes (incl. #1247 trtrs! pullback copy-boundary) preserved via auto-merge; branch-deleted _getrf_fwd stays deleted. - src/interface.jl: keep branch's cache-threaded _copy_output signature, incorporating main's #1243 OpaqueClosure/MistyClosure StackOverflow fix adapted to the cache-threaded form; Lifted (not Dual) in the value_and_derivative!! docstring. - src/test_utils.jl: keep `lift(...)` (main's `dual_type(P)(...)` two-field API is removed). - src/rules/iddict.jl: union of both sides' new `get`-default registry cases. - ext/MooncakeCUDAExt: adopt main #1225 GPU vcat/hcat/cat/permutedims REVERSE rules (+ helpers), but the FORWARD frules — Dual-based on main, and needing a careful GPU-tested Lifted/NDualArray port that risks silent wrong gradients if rushed — are deferred to clear `Lifted` "not yet implemented (reverse supported)" throws. Forward-Lifted GPU concat/permutedims port is a tracked loop follow-up. - docs forwards_mode_design.md: keep branch wording, BBCode -> CFGBlock (main's rename). Verified: Mooncake core loads (0.6.0); CUDA ext parses. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SRMQzvS6gE7QGen3U7wURH
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.
Closes #1246.
Forward-over-reverse through a triangular solve failed because pre-forward optimisation inlined the
copy(B)snapshot in thetrtrs!reverse rule throughunsafe_copyto!to rawmemmove. At that point the element type and copy count needed for differentiation have been erased, so Mooncake intentionally has no rule for the foreign call.Mark this snapshot call
Base.@noinlineso the typedcopyprimitive remains visible to forward mode, and add a focused Hessian regression. This remains necessary with #1215: its width-genericLifted/NDualArraycopy rule handles every tangent lane once the call boundary survives, while the earlier inlining phase and unsupported rawmemmoveboundary are unchanged.Validated with the
rules/high_order_derivative_patchesandrules/lapacktest groups, plus the focused reproducer on Julia 1.10–1.12.Prepared with Codex.
CI Summary — GitHub Actions
Documentation Preview
Mooncake.jl documentation for PR #1247 is available at:
https://chalk-lab.github.io/Mooncake.jl/previews/PR1247/
Performance
Performance Ratio:
Ratio of time to compute gradient and time to compute function.
Warning: results are very approximate! See here for more context.