Skip to content

Improve efficiency and fix bugs (device and dtype) for Gaussian backend#43

Merged
sansiro77 merged 8 commits intoTuringQ:mainfrom
Jooyuza:hotfix
Sep 29, 2024
Merged

Improve efficiency and fix bugs (device and dtype) for Gaussian backend#43
sansiro77 merged 8 commits intoTuringQ:mainfrom
Jooyuza:hotfix

Conversation

@Jooyuza
Copy link
Collaborator

@Jooyuza Jooyuza commented Sep 28, 2024

No description provided.

@sansiro77
Copy link
Contributor

sansiro77 commented Sep 29, 2024

It seems to be a bug related to vmap + slice assignment + cuda.

For example,

x = torch.randn(2, 4, 4, device='cuda:0')
def f(x):
    x[0:2, 0:2] = 1
    return x
torch.vmap(f)(x)

is OK.

However,

x = torch.randn(2, 4, 4, device='cuda:0')
def f(x):
    x[[0,1], [0,1]] = 1
    return x
torch.vmap(f)(x)

reports error.

Try something like:

mat = torch.randn(3, 3, device='cuda:0')
x = mat.new_ones(1)
torch.block_diag(*([x] * 3))

@sansiro77 sansiro77 self-requested a review September 29, 2024 05:21
@sansiro77 sansiro77 self-assigned this Sep 29, 2024
@sansiro77 sansiro77 added the bugfix Fix bugs label Sep 29, 2024
@sansiro77
Copy link
Contributor

Try

mat = torch.randn(3, 3, device='cuda:0')
x = mat.new_ones(3)
torch.diag(x)

to improve efficiency.

@Jooyuza
Copy link
Collaborator Author

Jooyuza commented Sep 29, 2024

image

Copy link
Contributor

@sansiro77 sansiro77 left a comment

Choose a reason for hiding this comment

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

Good job!

@sansiro77 sansiro77 added the enhancement New feature or request label Sep 29, 2024
@sansiro77 sansiro77 changed the title Fix bugs for cuda compatibility of gaussian backend Improve efficiency and fix bugs (device and dtype) for Gaussian backend Sep 29, 2024
@sansiro77 sansiro77 merged commit 7b27313 into TuringQ:main Sep 29, 2024
@Jooyuza Jooyuza deleted the hotfix branch September 30, 2024 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fix bugs enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants