Skip to content

complex blas reverse mode gemv/gemm - #3190

Open
ymardoukhi wants to merge 10 commits into
EnzymeAD:mainfrom
ymardoukhi:feat/complex-blas-reverse-mode
Open

ymardoukhi wants to merge 10 commits into
EnzymeAD:mainfrom
ymardoukhi:feat/complex-blas-reverse-mode

Conversation

@ymardoukhi

@ymardoukhi ymardoukhi commented Sep 7, 2026 •

Copy link
Copy Markdown

During JuliaCon, Billy told me that the infrastructure already exists for handling BLAS over complex numbers. So I gave it a shot with the help of Claude. This Intends to extend the support for AD over complex numbers.

lit tests are skipped because I don't have the knowledge. If someone could guide me on how to write them, I will take care of it.

cuBLAS and support for the transA=T case for Fortran fall outside the scope of this PR.

  • I relaxed the guard for c/z chars.
  • CBLAS uses values for real numbers; had to handle complex alpha/beta values via pointers
  • trans flag swaps are checked and addressed
  • Constant<> for complex values created 1.0 + i1.0. Have it fixed
  • checkMemoryTrace uses elem_size instead of sizeof(double)
  • zgemvTests and zgemmTests

ymardoukhi and others added 9 commits August 28, 2026 14:08
- removed the gurd for the `c` and `z` flags to enable reverse-mode for
  BLAS functions.
- `dot` and `ger` have no `{c,z}dot` or `{c,z}ger` equivalent.
  Admittable ones are `dot{u,c}` and `ger{u,c}`  for (un)conjugated
variants.
real CBLAS passes alpha/beta by value, but complex CBLAS treat thems as
pointers (const void*). The definition of byRefFloat didn't account for
this.
swapping CblasNoTrans<->CblasConjTrans (111<->113) for complex. Similar
to N<->C swap for the Fortran's case.
relax the check to receive complex values. Also use `dotc` instead of
`dot` for the Frobenius product of the matrices.
getRealValuedConstant(fpType, val) helper builds a proper {val, 0.0} vector
when fpType is complex. `Constant<val>` for complex produced wrong {val, val}
vector.
only the "active A, C" and "active A, B, C" cases; overwrite, namely
`ow` not covered here as they require lacpy/copy
added cblas_zgemm/cblas_zlascl mocks to blasinfra.h.
overwrite needs A/B caching via lacpy and is skipped.
@vchuravy

vchuravy commented Sep 7, 2026

Copy link
Copy Markdown
Member

Related #3181

This branch has not been deployed

No deployments
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