Skip to content

contract engine slower than cp.einsum #632

@John-zzh

Description

@John-zzh

Not sure when this behavior started, maybe just happened recently?

or maybe it is just warming up?

from gpu4pyscf.lib.cupy_helper import contract

import cupy as cp

from gpu4pyscf.lib import logger

logger.TIMER_LEVEL = 1
log = logger.new_logger(verbose=3)


eri3c = cp.random.rand(1234, 1234, 23).astype(cp.float32)
C_p = cp.random.rand(1234, 98).astype(cp.float32)

cpu1 = log.init_timer()
Ppq = cp.einsum('uvP,up->pvP', eri3c, C_p)
log.timer('cp.einsum', *cpu1)

cpu0 = log.init_timer()
Ppq = contract('uvP,up->pvP', eri3c, C_p)
log.timer('contract', *cpu0)

with the mkl-numpy environment from default channel 
CPU time for cp.einsum                                               0.08 sec, wall time      0.09 sec, GPU time     91.97 ms
CPU time for contract                                                0.24 sec, wall time      0.24 sec, GPU time    243.23 ms

[default_chanel.yml](https://github.com/user-attachments/files/24969977/default_chanel.yml)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions