patrick-kidger / patrick-kidger/diffrax

Support Lineax operators for the vector field of ControlTerm

Open
#370 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Python
Stars
2.1k
Forks
189
Avg merge
3d 18h
Merged PRs (30d)
1

Description

By providing support for lineax.AbstractLinearOperators in the vector field of a ControlTerm it may be possible to reduce the need for WeaklyDiagonalControlTerm and/or any other such specialised control terms.

The following gives a MWE:

class ControlTerm(_ControlTerm):
    def prod(self, vf, control):
        if isinstance(vf, lx.AbstractLinearOperator):
            return jtu.tree_map(lambda _vf, _control: _vf.mv(_control), vf, control)
        return jtu.tree_map(_prod, vf, control)

# These two are now equivalent.
ControlTerm(lx.DiagonalLinearOperator(jnp.array([1,2,3])), ...)
WeaklyDiagonalControlTerm(jnp.array([1,2,3]), ...)

Not sure if this is something you want to support, but it occurred to me that the operator tags might also be useful for some of the diffrax solvers?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the ControlTerm vector field and its prod entry point, comparing the existing ControlTerm and WeaklyDiagonalControlTerm behavior shown in the MWE. Check how lineax.AbstractLinearOperators and their mv operation should interact with the control tree, then verify that the two example constructions are equivalent without regressing the existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.