(cmake) use bisheng#83
Draft
zouzias wants to merge 27 commits into
Draft
Conversation
Collaborator
Author
|
This also segfaults import os
import ctypes
import torch
lib_path="libno_workspace_kernel.so"
lib_path = os.path.abspath(lib_path)
lib = ctypes.CDLL(lib_path)
lib.vabs_fp16.restype = None
lib.vabs_fp16.argtypes = [
ctypes.c_uint32, # blockDim
ctypes.c_void_p, # stream
ctypes.c_void_p, # y
ctypes.c_void_p, # x
ctypes.c_int, # N
]
stream_ptr = torch.npu.current_stream()._as_parameter_ # noqa
def torch_to_ctypes(tensor):
return ctypes.c_void_p(tensor.data_ptr())
block_num = 4
length = [block_num, 64]
x = torch.rand(length, device="cpu", dtype=torch.float16).npu()
z = torch.empty_like(x)
lib.vabs_fp16(block_num, stream_ptr, torch_to_ctypes(x), torch_to_ctypes(z), x.numel()) |
Collaborator
Author
|
This works! import os
import ctypes
import torch
lib_path="libno_workspace_kernel.so"
lib_path = os.path.abspath(lib_path)
lib = ctypes.CDLL(lib_path)
lib.call_vabs_fp16.restype = None
lib.call_vabs_fp16.argtypes = [
ctypes.c_uint32, # blockDim
ctypes.c_void_p, # stream
ctypes.c_void_p, # y
ctypes.c_void_p, # x
ctypes.c_int, # N
]
stream_ptr = torch.npu.current_stream()._as_parameter_ # noqa
def torch_to_ctypes(tensor):
return ctypes.c_void_p(tensor.data_ptr())
block_num = 4
length = [block_num, 64]
x = torch.randn(length, device="cpu", dtype=torch.float16).npu()
z = torch.empty_like(x)
lib.call_vabs_fp16(block_num, stream_ptr, torch_to_ctypes(x), torch_to_ctypes(z), x.numel()) |
Collaborator
Author
|
Tests pass now, i.e., @learning-chip let me know if you can reproduce. If so, we can quickly merge and release the manylinux wheels to pypi. |
Collaborator
|
An alternative to this approach would be to use pytorch to do compilation, kind of like how it is done in #156 for CPU. you can set |
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.
This MR removes all AscendC dependencies and makes the
pto-kernelswheel friendly for manylinux support.Changelog
torch_tri_invtotorch_tri_inv_col_sweepStatus
and
TODO
TL;DR the vector kernels deadlock on the new setup.
Tests (x mean passing tests)
Test vabs in isolation