Remove CUDA ERROR 9 of inputs of get_padding_offset kernel (#5440)

Co-authored-by: K11OntheBoat <“ruianmaidanglao@163.com”>
This commit is contained in:
K11OntheBoat
2025-12-09 14:17:30 +08:00
committed by GitHub
parent 76649b45c1
commit 8d99bac532
8 changed files with 97 additions and 167 deletions
+2 -6
View File
@@ -23,7 +23,7 @@ from fastdeploy.model_executor.ops.gpu import get_padding_offset
class TestGetPaddingOffset(unittest.TestCase):
def test_get_padding_offset(self):
seq_lens = np.array([4, 3, 6], "int32").reshape(-1, 1)
token_num = np.sum(seq_lens)
token_num_cpu = np.sum(seq_lens)
input_ids = np.array(
[[8, 7, 8, 2, 0, 0, 0, 0, 0, 0], [4, 5, 5, 0, 0, 0, 0, 0, 0, 0], [7, 6, 1, 7, 2, 6, 0, 0, 0, 0]], "int64"
)
@@ -32,11 +32,7 @@ class TestGetPaddingOffset(unittest.TestCase):
batch_id_per_token,
cu_seqlens_q,
cu_seqlens_k,
) = get_padding_offset(
paddle.to_tensor(input_ids),
paddle.to_tensor(token_num),
paddle.to_tensor(seq_lens),
)
) = get_padding_offset(paddle.to_tensor(input_ids), paddle.to_tensor(seq_lens), token_num_cpu)
ref_x_remove_padding = np.array([8, 7, 8, 2, 4, 5, 5, 7, 6, 1, 7, 2, 6], "int64")
ref_batch_id_per_token = np.array([0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2], "int32")
@@ -86,14 +86,13 @@ class TestSpeculateGetPaddingOffset(unittest.TestCase):
input_ids = np.random.randint(0, 1000, (test_case["bsz"], test_case["max_seq_len"]), dtype=np.int64)
draft_tokens = np.random.randint(0, 1000, (test_case["bsz"], max_draft_tokens), dtype=np.int64)
token_num = np.array([test_case["token_num_data"]], dtype=np.int64)
token_num_cpu = np.array([test_case["token_num_data"]], dtype=np.int64).item()
input_ids_tensor = paddle.to_tensor(input_ids)
draft_tokens_tensor = paddle.to_tensor(draft_tokens)
cum_offsets_tensor = paddle.to_tensor(test_case["cum_offsets"])
seq_lens_tensor = paddle.to_tensor(test_case["seq_lens"])
seq_lens_encoder_tensor = paddle.to_tensor(test_case["seq_lens_encoder"])
token_num_tensor = paddle.to_tensor(token_num)
(
x_remove_padding,
@@ -104,9 +103,9 @@ class TestSpeculateGetPaddingOffset(unittest.TestCase):
input_ids_tensor,
draft_tokens_tensor,
cum_offsets_tensor,
token_num_tensor,
seq_lens_tensor,
seq_lens_encoder_tensor,
token_num_cpu,
)
(