Skip to content

Comments

make permutation path in cutensor optional, fix cmake, fix setting us…#39

Merged
SpaceyLake merged 4 commits intoTAPPorg:cutensor_bindingsfrom
jurajHasik:feat_skip_permute
Feb 12, 2026
Merged

make permutation path in cutensor optional, fix cmake, fix setting us…#39
SpaceyLake merged 4 commits intoTAPPorg:cutensor_bindingsfrom
jurajHasik:feat_skip_permute

Conversation

@jurajHasik
Copy link

@jurajHasik jurajHasik commented Feb 10, 2026

  • fix CMake build: expose CUTENSOR_INCLUDE_DIR to the rest of CMake (i.e. cutensor dependent targets in top-level CMakeLists)

  • fix TAPP_attr_get/set and its use in demo-dynamic, test-dynamic to set use_device_memory.
    This fixes demo-dynamic. The test-dynamic fails for other reasons [see comment below]

  • Makes permutation path in cutensor_bindings TAPP_execute_product optional: If op_D == TAPP_IDENTITY, permutation path is skipped, which saves on unnecessary allocation/deallocation of the intermediate

  • memory in TAPP_execute_product is managed via Async de/allocation wrt. to supplied stream (TAPP_executor). This avoids the need for stream synchronization

…e_device_memory and demo-dynamic, test-dynamic
@jurajHasik
Copy link
Author

Regarding tapp-reference-test-dynamic:

After adding use_device_memory flag. The test fails on

$ ./tapp-reference-test-dynamic
Starting seed for random numbers = 0
Hadamard Product: true
Contraction: true
Commutativity: true
Permutations: true
Equal Extents: true
Outer Product: true
Full Contraction: true
Zero Dim Tensor Contraction: true
One Dim Tensor Contraction: true
Subtensor Same Index: true
tapp-reference-test-dynamic: /home/urza/Projects/scratch/tapp-torch/third_party/tapp/cutensor_bindings/src/product.cu:220: 
TAPP_error TAPP_execute_product(TAPP_tensor_product, TAPP_executor, TAPP_status*, const void*, const void*, const void*, const void*, const void*, void*): 
Assertion `uintptr_t(A_d) % 128 == 0' failed.


TAPP_EXPORT TAPP_error TAPP_attr_set(TAPP_attr attr, TAPP_key key, void* value);

TAPP_EXPORT TAPP_error TAPP_attr_get(TAPP_attr attr, TAPP_key key, void** value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this should still be a void** because we want to return by value a void*

return 0;
}

TAPP_error TAPP_attr_get(TAPP_attr attr, TAPP_key key, void** value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as for the header file

@@ -1,4 +1,5 @@
#include "../include/product.h"
#include "../include/attributes.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather put it in the header file in my opinion

struct handle* handle_struct = (struct handle*) ((struct product_plan*) plan)->handle;
bool use_device_memory = *(bool*)((handle_struct->attributes)[0]);
bool use_device_memory;
TAPP_attr_get((TAPP_handle)handle_struct, ATTR_KEY_USE_DEVICE_MEMORY, (void*)&use_device_memory);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't want to call functions from the TAPP interface internally. It works for now but will cause problems for multi-TAPP. I do call functions from the TAPP interface internally in the reference implementation but I am fixing it in other branches.

{
void* handle;
TAPP_error (*TAPP_attr_set)(TAPP_attr attr, TAPP_key key, void* value);
TAPP_error (*TAPP_attr_get)(TAPP_attr attr, TAPP_key key, void** value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as the previous comments about this

Copy link
Collaborator

@SpaceyLake SpaceyLake left a comment

Choose a reason for hiding this comment

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

Aside from the comments I made, I think it looks good! If you'd like, I could fix them myself

@jurajHasik
Copy link
Author

@SpaceyLake thank you ! Don't worry, I should be able to update the PR according to your comments fast.

@jurajHasik
Copy link
Author

Btw:
test-dynamic now progresses further, then it crashes in test_subtensor_lower_idx

$ gdb ./tapp-reference-test-dynamic 
[...]
Reading symbols from ./tapp-reference-test-dynamic...
(gdb) r
Starting program: [...]/tapp-torch/third_party/tapp/build/tapp-reference-test-dynamic
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Starting seed for random numbers = 0
[New Thread 0x7fffb9fff640 (LWP 33085)]
[New Thread 0x7fffb93ff640 (LWP 33088)]
[Thread 0x7fffb93ff640 (LWP 33088) exited]
[New Thread 0x7fffb93ff640 (LWP 33089)]
[New Thread 0x7fffaca20640 (LWP 33091)]
Hadamard Product: true
Contraction: true
Commutativity: true
Permutations: true
Equal Extents: true
Outer Product: true
Full Contraction: true
Zero Dim Tensor Contraction: true
One Dim Tensor Contraction: true
Subtensor Same Index: true
tapp-reference-test-dynamic: [...]/tapp-torch/third_party/tapp/cutensor_bindings/src/product.cu:222: TAPP_error TAPP_execute_product(TAPP_tensor_product, TAPP_executor, TAPP_status*, const void*, const void*, const void*, const void*, const void*, void*): Assertion `uintptr_t(A_d) % 128 == 0' failed.

Thread 1 "tapp-reference-" received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350686528) at ./nptl/pthread_kill.c:44
44      ./nptl/pthread_kill.c: No such file or directory.

Copy link
Collaborator

@SpaceyLake SpaceyLake left a comment

Choose a reason for hiding this comment

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

I am happy with the changes. The problems with test-dynamic seem to exist on the original branch as well. I'll merge this and fix it on the branch

@SpaceyLake SpaceyLake merged commit 5144807 into TAPPorg:cutensor_bindings Feb 12, 2026
6 checks passed
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