# Optimization on Stiefel manifold with auto-differentiation

**URL:** <https://discourse.julialang.org/t/optimization-on-stiefel-manifold-with-auto-differentiation/132072>\
**Category:** Optimization (Mathematical)\
**Tags:** question, package\
**Created:** [September 3, 2025, 11:30am UTC](https://discourse.julialang.org/t/optimization-on-stiefel-manifold-with-auto-differentiation/132072 "2025-09-03T11:30:29Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 5, 2025, 1:07pm UTC](https://discourse.julialang.org/t/optimization-on-stiefel-manifold-with-auto-differentiation/132072/6 "2025-09-05T13:07:21Z")

</div>

> [@Yue-Zhengyuan](#):
>
> Does this mean that I need to define an rrule for the sparse matrices I created?

Not quite, as explained here: [Zygote.jl: How to get the gradient of sparse matrix - #6 by stevengj](https://discourse.julialang.org/t/zygote-jl-how-to-get-the-gradient-of-sparse-matrix/59067/6) — if you are going to write an `rrule`, it typically has to be for the function that includes both the sparse-matrix construction and how you _use_ the sparse matrix. (This isn’t usually so hard, though.)

Where are the sparse matrices in your [problem description above](https://discourse.julialang.org/t/optimization-on-stiefel-manifold-with-auto-differentiation/132072)?

(You might also try Enzyme.jl.)

---

_[View the full topic](https://discourse.julialang.org/t/optimization-on-stiefel-manifold-with-auto-differentiation/132072)._
