Repository navigation
Support kron between any Diagonal and dense GPU arrays - #890
Open
albertomercurio wants to merge 1 commit into
Open
albertomercurio wants to merge 1 commit into
albertomercurio wants to merge 1 commit into
Conversation
The diagonal can now be any vector usable in a kernel, not only a GPU vector: e.g., ranges or the `Ones` of FillArrays' `Eye`. The dense argument can also be a vector, or a `Transpose`/`Adjoint` of a GPU array. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 tasks done
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.
kronbetween aDiagonaland a dense GPU array only had a GPU method when the diagonal was itself a GPU vector and the other argument a plain GPU matrix. Other combinations fell back to LinearAlgebra's generic method and hit scalar indexing, for example:This PR:
Diagonalwhose diagonal can be passed to a kernel. That is a GPU vector as before, but also an isbits lazy vector, such as a range or theOnesandFillof FillArrays.jl, without depending on FillArrays. ADiagonalof a CPUVectornow throws the back-end's "cannot use a CPU array in a kernel" error instead of scalar indexing.Transpose/Adjointwrappers, like the dense-dense methods already do.fldmod1, and adds a message to theDimensionMismatch.Tests: the Diagonal-dense tests now cover vectors,
transpose/adjoint, and a range diagonal, whichadaptkeeps on the host. They also check type stability with@inferred.Verified:
linalg/kronpasses forJLArrayandArray.linalg/krontest suite andFillArrays.Eyepass withCuArray.kronhas no method ambiguities.Motivation: QuantumToolbox.jl builds super-operators as
kron(Eye(n), A)andkron(transpose(A), Eye(n)), so dense GPU operators could not be used in its master equation solvers.🤖 Generated with Claude Code