Skip to content

Fix assemble(slate.Tensor, diagonal=True) #4378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: pbrubeck/fix/slate-cofunction
Choose a base branch
from

Conversation

pbrubeck
Copy link
Contributor

Description

@pbrubeck pbrubeck force-pushed the pbrubeck/fix/diagonal-slate branch from 42a6e27 to 05fa39b Compare June 16, 2025 11:42
@@ -1745,7 +1745,7 @@ def _as_global_kernel_arg_output(_, self):
if rank == 0:
return op2.GlobalKernelArg((1,))
elif rank == 1 or rank == 2 and self._diagonal:
V, = Vs
V = Vs[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have V, here to assert a singleton. Why is that now violated? What are the contents of V[1:]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With slate we get the two copies of the same space in Vs. For some reason diagonal=True will cause len(indices) == 1 only for ufl.Form, but not for slate.Tensor. On both cases len(form.arguments()) == 2.

return tuple(a.ufl_function_space()[i] for i, a in zip(indices, form.arguments()))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this is where we get the indices from

self._indices, self._kinfo = local_knl

Which means that we should trim the lenght of indices somewhere in slate/slac/compiler.py, but it gets hard to track down because diagonal is not mentioned at all in that script.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use V = pytools.single_valued(Vs) then?

@pbrubeck
Copy link
Contributor Author

As I was adding tests, I saw that there is support for assemble(Tensor(form, diagonal=True)), which assembles directly the diagonal. But this PR aims to enable assemble(Tensor(form), diagonal=True) to assemble the diagonal from the Matrix entries. Unfortunately the latter gives incorrect results.

In general we cannot rely on Tensor(form, diagonal=True), as we would like to support diagonals of more complicate SLATE expressions (e.g. Schur complements). So this PR would require more work.

@dham dham marked this pull request as draft July 16, 2025 15:35
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.

2 participants