|
ember.cpp 0.1.0
C++ inference engine for Llama-family and paperkiln models (CPU, CUDA, WebAssembly)
|
CUDA kernel implementations for TinyLlama GPU operations. More...
#include "cuda_kernels.h"#include "determinism.h"#include "logger.h"#include "model_macros.h"#include <stdint.h>#include <stdio.h>#include <algorithm>#include <cmath>#include <iostream>#include <cfloat>#include <cstdlib>#include <string>
Go to the source code of this file.
CUDA kernel implementations for TinyLlama GPU operations.
This file contains the actual CUDA kernel implementations for the GPU-accelerated operations declared in cuda_kernels.h. The implementations are optimized for NVIDIA GPUs and use CUDA-specific features for maximum performance.
Key implementation details:
Definition in file cuda_kernels.cu.
| void add_residual_batch_cuda | ( | float * | d_output_batch, |
| const float * | d_input_a_batch, | ||
| const float * | d_input_b_batch, | ||
| int | num_tokens, | ||
| int | hidden_size, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 1274 of file cuda_kernels.cu.
References Logger::info(), j, and kernel_debug_copies().
| __global__ void add_residual_batch_cuda_kernel | ( | float * | d_output_batch, |
| const float * | d_input_a_batch, | ||
| const float * | d_input_b_batch, | ||
| int | num_tokens, | ||
| int | hidden_size | ||
| ) |
Definition at line 1250 of file cuda_kernels.cu.
References j.
| void add_residual_cuda | ( | const float * | matvec_out_dev, |
| const float * | residual_dev, | ||
| float * | result_dev, | ||
| int | n, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 1239 of file cuda_kernels.cu.
| void add_vectors_cuda | ( | const float * | a_dev, |
| const float * | b_dev, | ||
| float * | result_dev, | ||
| int | n, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 1220 of file cuda_kernels.cu.
| __device__ float atomicAddFloat | ( | float * | address, |
| float | val | ||
| ) |
Definition at line 81 of file cuda_kernels.cu.
References j.
Referenced by attention_optimized_kernel(), and softmax_optimized_kernel().
| __device__ float atomicMaxFloat | ( | float * | address, |
| float | val | ||
| ) |
Definition at line 70 of file cuda_kernels.cu.
References j.
Referenced by attention_optimized_kernel(), and softmax_optimized_kernel().
| void attention_cuda | ( | const float * | Q_current_dev, |
| const float * | K_layer_cache_base, | ||
| const float * | V_layer_cache_base, | ||
| float * | out_dev, | ||
| int | num_heads, | ||
| int | current_seq_len, | ||
| int | head_dim, | ||
| float | scale, | ||
| int | cache_max_seq_len, | ||
| int | cache_num_kv_heads, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 1093 of file cuda_kernels.cu.
| void attention_cuda_optimized | ( | const float * | Q_current_dev, |
| const float * | K_layer_cache_base, | ||
| const float * | V_layer_cache_base, | ||
| float * | out_dev, | ||
| int | num_heads, | ||
| int | current_seq_len, | ||
| int | head_dim, | ||
| float | scale, | ||
| int | cache_max_seq_len, | ||
| int | cache_num_kv_heads, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3319 of file cuda_kernels.cu.
References ember::deterministic(), j, and scale.
Referenced by attention_decode_at_cuda().
| void attention_cuda_selective_dequant | ( | const float * | Q_current_dev, |
| const int8_t * | K_quantized_cache_base, | ||
| const int8_t * | V_quantized_cache_base, | ||
| const float * | K_scales_cache_base, | ||
| const float * | V_scales_cache_base, | ||
| float * | selective_k_dequant_buffer, | ||
| float * | selective_v_dequant_buffer, | ||
| float * | out_dev, | ||
| int | num_heads, | ||
| int | current_seq_len, | ||
| int | head_dim, | ||
| float | scale, | ||
| int | cache_max_seq_len, | ||
| int | cache_num_kv_heads, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 1178 of file cuda_kernels.cu.
References j, scale, and Logger::warning().
| void attention_decode_at_cuda | ( | const float * | Q_current_dev, |
| const float * | K_layer_cache_base, | ||
| const float * | V_layer_cache_base, | ||
| float * | out_dev, | ||
| int | num_heads, | ||
| int | seq_len, | ||
| int | head_dim, | ||
| float | scale, | ||
| int | cache_max_seq_len, | ||
| int | cache_num_kv_heads, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3600 of file cuda_kernels.cu.
References attention_cuda_optimized(), j, and scale.
| void attention_devpos_cuda | ( | const float * | Q_current_dev, |
| const float * | K_layer_cache_base, | ||
| const float * | V_layer_cache_base, | ||
| float * | out_dev, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| float | scale, | ||
| int | cache_max_seq_len, | ||
| int | cache_num_kv_heads, | ||
| const int * | step_dev, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3610 of file cuda_kernels.cu.
References ember::deterministic(), j, and scale.
| __global__ void attention_kernel | ( | const float * | Q_current, |
| const float * | K_layer_cache_base, | ||
| const float * | V_layer_cache_base, | ||
| float * | out, | ||
| int | current_seq_len, | ||
| int | head_dim, | ||
| float | scale, | ||
| int | cache_num_kv_heads, | ||
| int | num_q_heads | ||
| ) |
Definition at line 981 of file cuda_kernels.cu.
| __global__ void attention_optimized_det_kernel | ( | const float *__restrict__ | Q_current, |
| const float *__restrict__ | K_layer_cache_base, | ||
| const float *__restrict__ | V_layer_cache_base, | ||
| float *__restrict__ | out, | ||
| int | current_seq_len, | ||
| int | head_dim, | ||
| float | scale, | ||
| int | cache_num_kv_heads, | ||
| int | num_q_heads, | ||
| const int * | step_dev | ||
| ) |
Definition at line 2987 of file cuda_kernels.cu.
| __global__ void attention_optimized_kernel | ( | const float *__restrict__ | Q_current, |
| const float *__restrict__ | K_layer_cache_base, | ||
| const float *__restrict__ | V_layer_cache_base, | ||
| float *__restrict__ | out, | ||
| int | current_seq_len, | ||
| int | head_dim, | ||
| float | scale, | ||
| int | cache_num_kv_heads, | ||
| int | num_q_heads, | ||
| const int * | step_dev | ||
| ) |
Corrected and optimized attention kernel.
Uses shared memory for scores and performs a full softmax operation correctly. Each block computes attention for one head.
Definition at line 2839 of file cuda_kernels.cu.
References atomicAddFloat(), atomicMaxFloat(), j, out, and scale.
| __global__ void attention_selective_dequant_kernel | ( | const float *__restrict__ | Q_current_dev, |
| const int8_t *__restrict__ | K_quantized_cache_base, | ||
| const int8_t *__restrict__ | V_quantized_cache_base, | ||
| const float *__restrict__ | K_scales_cache_base, | ||
| const float *__restrict__ | V_scales_cache_base, | ||
| float *__restrict__ | selective_k_dequant_buffer, | ||
| float *__restrict__ | selective_v_dequant_buffer, | ||
| float *__restrict__ | out_dev, | ||
| int | num_heads, | ||
| int | current_seq_len, | ||
| int | head_dim, | ||
| float | scale, | ||
| int | cache_max_seq_len, | ||
| int | cache_num_kv_heads | ||
| ) |
Definition at line 1112 of file cuda_kernels.cu.
|
inline |
Converts BF16 to FP32 on the device.
This device function converts Brain Floating Point (BF16) values to FP32. It uses CUDA's native BF16 support on architectures >= 800, and falls back to a manual conversion on older architectures.
| bf16_raw | Raw BF16 value as uint16_t |
Definition at line 102 of file cuda_kernels.cu.
References j.
Referenced by convert_bf16_to_fp32_kernel(), and lookup_embedding_kernel().
| void convert_bf16_to_fp32_cuda | ( | const uint16_t * | bf16_in_dev, |
| float * | fp32_out_dev, | ||
| size_t | n_elements, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3515 of file cuda_kernels.cu.
References j.
Referenced by gemm_f32_to_bf16_f32_cuda().
| __global__ void convert_bf16_to_fp32_kernel | ( | const uint16_t *__restrict__ | bf16_in, |
| float *__restrict__ | fp32_out, | ||
| size_t | n_elements | ||
| ) |
Definition at line 1498 of file cuda_kernels.cu.
References bf16_to_float32_device(), and j.
| void convert_fp32_to_bf16_cuda | ( | const float * | fp32_in_dev, |
| uint16_t * | bf16_out_dev, | ||
| size_t | n_elements, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3357 of file cuda_kernels.cu.
References j.
Referenced by gemm_f32_to_bf16_f32_cuda().
| __global__ void convert_fp32_to_bf16_kernel | ( | const float *__restrict__ | fp32_in, |
| uint16_t *__restrict__ | bf16_out, | ||
| size_t | n_elements | ||
| ) |
Definition at line 3347 of file cuda_kernels.cu.
References float32_to_bf16_device(), and j.
| int decode_attention_kind | ( | ) |
Definition at line 3297 of file cuda_kernels.cu.
Definition at line 3306 of file cuda_kernels.cu.
References a, j, ember_tiled::kTiledMaxChunks, and ember_tiled::kTiledMinChunk.
| void decode_embed_cuda | ( | const float * | table_dev, |
| float * | out_dev, | ||
| const int * | step_dev, | ||
| int | hidden_size, | ||
| int | vocab_size, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3541 of file cuda_kernels.cu.
References decode_embed_kernel(), and j.
| __global__ void decode_embed_kernel | ( | const float *__restrict__ | table, |
| float *__restrict__ | out, | ||
| const int *__restrict__ | step_dev, | ||
| int | hidden_size, | ||
| int | vocab_size | ||
| ) |
|
inline |
Definition at line 118 of file cuda_kernels.cu.
References j.
Referenced by convert_fp32_to_bf16_kernel().
| void gemm_bf16_bf16_cuda | ( | cublasHandle_t | handle, |
| bool | transa_user, | ||
| bool | transb_user, | ||
| int | m_user, | ||
| int | n_user, | ||
| int | k_user, | ||
| const float * | alpha_user, | ||
| const uint16_t * | A_bf16_user, | ||
| int | lda_user, | ||
| const uint16_t * | B_bf16_user, | ||
| int | ldb_user, | ||
| const float * | beta_user, | ||
| uint16_t * | C_bf16_user, | ||
| int | ldc_user, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3369 of file cuda_kernels.cu.
References Logger::error(), Logger::info(), and j.
| void gemm_f32_to_bf16_f32_cuda | ( | cublasHandle_t | handle, |
| bool | transa_user, | ||
| bool | transb_user, | ||
| int | m_user, | ||
| int | n_user, | ||
| int | k_user, | ||
| const float * | alpha_user, | ||
| const float * | A_f32_user, | ||
| int | lda_user, | ||
| const uint16_t * | B_bf16_user, | ||
| int | ldb_user, | ||
| const float * | beta_user, | ||
| float * | C_f32_user, | ||
| int | ldc_user, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3446 of file cuda_kernels.cu.
References convert_bf16_to_fp32_cuda(), convert_fp32_to_bf16_cuda(), Logger::error(), and j.
| void gemm_rm_f32_cuda | ( | cublasHandle_t | handle, |
| const float * | X, | ||
| const float * | W, | ||
| float * | Y, | ||
| int | T, | ||
| int | O, | ||
| int | I, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3759 of file cuda_kernels.cu.
References j.
Definition at line 64 of file cuda_kernels.cu.
References j.
Referenced by add_residual_batch_cuda(), rope_batch_cuda(), and swiglu_batch_cuda().
| void kv_write_devpos_cuda | ( | float * | k_cache_dev, |
| float * | v_cache_dev, | ||
| const float * | k_dev, | ||
| const float * | v_dev, | ||
| const int * | step_dev, | ||
| int | row, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3593 of file cuda_kernels.cu.
References j, and kv_write_devpos_kernel().
| __global__ void kv_write_devpos_kernel | ( | float * | k_cache, |
| float * | v_cache, | ||
| const float *__restrict__ | k, | ||
| const float *__restrict__ | v, | ||
| const int * | step_dev, | ||
| int | row | ||
| ) |
| void lookup_embedding_cuda | ( | const void * | table_dev, |
| float * | output_dev, | ||
| int | token_id, | ||
| int | hidden_size, | ||
| int | vocab_size, | ||
| bool | is_bf16, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 1474 of file cuda_kernels.cu.
References Logger::error(), and j.
| __global__ void lookup_embedding_kernel | ( | const void *__restrict__ | table_dev, |
| float *__restrict__ | output_dev, | ||
| int | token_id, | ||
| int | hidden_size, | ||
| int | vocab_size, | ||
| bool | is_bf16 | ||
| ) |
Definition at line 1445 of file cuda_kernels.cu.
References bf16_to_float32_device(), and j.
| void matvec_bf16_f32_cuda | ( | cublasHandle_t | handle, |
| const uint16_t * | mat_bf16_dev, | ||
| const float * | vec_f32_dev, | ||
| float * | out_f32_dev, | ||
| int | rows, | ||
| int | cols, | ||
| bool | use_tensor_cores, | ||
| cudaStream_t | stream | ||
| ) |
Matrix-vector multiplication with BF16 matrix and FP32 vector/output on GPU.
This function performs matrix-vector multiplication (mat * vec = out) where the matrix is in BF16 format, and the vector and output are in FP32 format. It can use BF16 Tensor Cores via cublasGemmEx if supported and enabled. Otherwise, it falls back to converting the BF16 matrix to FP32 and then using cublasSgemm.
Matrix 'mat_bf16_dev' is assumed to be in row-major format with 'rows' rows and 'cols' columns. Vector 'vec_f32_dev' is assumed to have 'cols' elements. Output 'out_f32_dev' will have 'rows' elements.
| handle | cuBLAS handle |
| mat_bf16_dev | BF16 matrix (device pointer, row-major, rows x cols) |
| vec_f32_dev | FP32 vector (device pointer, cols elements) |
| out_f32_dev | FP32 output vector (device pointer, rows elements) |
| rows | Number of matrix rows |
| cols | Number of matrix columns |
| use_tensor_cores | Whether to attempt using BF16 Tensor Cores with cublasGemmEx |
| stream | CUDA stream (optional) |
Definition at line 353 of file cuda_kernels.cu.
References Logger::info(), j, and Logger::warning().
| void matvec_f32_f32_cuda | ( | cublasHandle_t | handle, |
| const float * | mat_f32_dev, | ||
| const float * | vec_f32_dev, | ||
| float * | out_f32_dev, | ||
| int | rows, | ||
| int | cols, | ||
| cudaStream_t | stream | ||
| ) |
Implementation of matrix-vector multiplication with FP32.
This function performs matrix-vector multiplication using cuBLAS, optimized for FP32 precision. It handles the cuBLAS setup and error checking.
| handle | cuBLAS handle |
| mat_f32_dev | Matrix in row-major format (device pointer) |
| vec_f32_dev | Vector to multiply (device pointer) |
| out_f32_dev | Output vector (device pointer) |
| rows | Number of matrix rows |
| cols | Number of matrix columns |
| stream | CUDA stream for asynchronous execution |
Definition at line 306 of file cuda_kernels.cu.
References j.
Referenced by matvec_f32_f32_cuda().
| void matvec_f32_f32_cuda | ( | cublasHandle_t | handle, |
| const std::vector< float > & | mat_f32_host, | ||
| const std::vector< float > & | vec_f32_host, | ||
| std::vector< float > & | out_f32_host, | ||
| int | rows, | ||
| int | cols | ||
| ) |
Definition at line 470 of file cuda_kernels.cu.
References j, and matvec_f32_f32_cuda().
| void moe_ffn_cuda | ( | cublasHandle_t | handle, |
| const float * | x, | ||
| int | T, | ||
| int | d, | ||
| int | d_ff, | ||
| int | E, | ||
| int | k, | ||
| bool | renorm, | ||
| const float * | router, | ||
| const float * | gate_exps, | ||
| const float * | up_exps, | ||
| const float * | down_exps, | ||
| float * | scratch, | ||
| float * | out, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3770 of file cuda_kernels.cu.
| __global__ void reduce_partial_sums_kernel | ( | const float * | partial_sums, |
| float * | total_sum_sq_out, | ||
| int | num_partial_sums | ||
| ) |
Definition at line 185 of file cuda_kernels.cu.
References j.
Referenced by rmsnorm_vector_cuda().
| __global__ void rmsnorm_apply_kernel | ( | const float * | x, |
| const float * | weight, | ||
| float * | out, | ||
| int | n, | ||
| float | inv_norm_factor | ||
| ) |
Kernel for applying RMS normalization.
This kernel applies the normalization weights and scaling factor to the input tensor. It's the second step in RMS normalization.
| x | Input tensor |
| weight | Normalization weights |
| out | Output tensor |
| n | Size of tensors |
| inv_norm_factor | Inverse of the normalization factor |
Definition at line 177 of file cuda_kernels.cu.
| __global__ void rmsnorm_optimized_det_kernel | ( | const float *__restrict__ | x, |
| const float *__restrict__ | weight, | ||
| float *__restrict__ | out, | ||
| int | n, | ||
| float | eps | ||
| ) |
Definition at line 2945 of file cuda_kernels.cu.
| __global__ void rmsnorm_optimized_kernel | ( | const float *__restrict__ | x, |
| const float *__restrict__ | weight, | ||
| float *__restrict__ | out, | ||
| int | n, | ||
| float | eps | ||
| ) |
Optimized RMS normalization using simple warp primitives and shared memory.
This kernel uses warp-level reductions and a shared memory variable for block-wide sum.
Definition at line 2738 of file cuda_kernels.cu.
Referenced by rmsnorm_vector_cuda_optimized().
Kernel for computing sum of squares in RMS normalization.
This kernel computes the sum of squares of input elements using parallel reduction with shared memory. It's the first step in RMS normalization.
| x | Input tensor |
| partial_sums | Output array for partial sums |
| n | Size of input tensor |
Definition at line 143 of file cuda_kernels.cu.
Referenced by rmsnorm_vector_cuda().
| void rmsnorm_vector_cuda | ( | const float * | x_dev, |
| const float * | weight_dev, | ||
| float * | out_dev, | ||
| int | n, | ||
| float | eps, | ||
| cudaStream_t | stream | ||
| ) |
Implementation of RMS normalization with device pointers.
This function implements the complete RMS normalization process:
| x_dev | Input tensor (device pointer) |
| weight_dev | Normalization weights (device pointer) |
| out_dev | Output tensor (device pointer) |
| n | Size of tensors |
| eps | Epsilon for numerical stability |
| stream | CUDA stream for asynchronous execution |
Definition at line 224 of file cuda_kernels.cu.
References j, n, reduce_partial_sums_kernel(), rmsnorm_sum_squares_kernel(), and SAFE_SQRT.
Referenced by rmsnorm_vector_cuda().
| void rmsnorm_vector_cuda | ( | const std::vector< float > & | x_in_host, |
| const std::vector< float > & | weight_host, | ||
| std::vector< float > & | out_host, | ||
| int | n, | ||
| float | eps | ||
| ) |
Definition at line 270 of file cuda_kernels.cu.
References j, n, and rmsnorm_vector_cuda().
| void rmsnorm_vector_cuda_optimized | ( | const float * | x_dev, |
| const float * | weight_dev, | ||
| float * | out_dev, | ||
| int | n, | ||
| float | eps, | ||
| cudaStream_t | stream | ||
| ) |
Optimized wrappers using the new high-performance kernels.
Definition at line 3082 of file cuda_kernels.cu.
References ember::deterministic(), j, n, and rmsnorm_optimized_kernel().
| void rope_and_update_kv_cache_cuda | ( | float * | cache_base_ptr, |
| const float * | kv_vector_head, | ||
| const float * | all_freqs_cis_base, | ||
| int | pos, | ||
| int | kv_head_idx, | ||
| int | max_seq_len, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 1412 of file cuda_kernels.cu.
References Logger::error(), j, and pos.
| __global__ void rope_and_update_kv_cache_kernel | ( | float * | cache_base_ptr, |
| const float * | kv_vector_head, | ||
| const float * | all_freqs_cis_base, | ||
| int | pos, | ||
| int | kv_head_idx, | ||
| int | max_seq_len, | ||
| int | num_kv_heads, | ||
| int | head_dim | ||
| ) |
Definition at line 1376 of file cuda_kernels.cu.
| void rope_batch_cuda | ( | float * | d_q_batch, |
| float * | d_k_batch, | ||
| const float * | d_all_freqs_cis_base, | ||
| int | num_tokens, | ||
| int | num_q_heads, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| int | start_pos_in_kv_cache, | ||
| bool | use_adjacent_pairing, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 872 of file cuda_kernels.cu.
References Logger::error(), Logger::info(), j, kernel_debug_copies(), and Logger::warning().
| __global__ void rope_batch_kernel_cuda | ( | float * | x_batch_tensor, |
| int | num_tokens, | ||
| int | num_heads_in_tensor, | ||
| int | head_dim, | ||
| const float * | d_all_freqs_cis_base, | ||
| int | start_pos_offset, | ||
| bool | use_adjacent_pairing | ||
| ) |
Definition at line 812 of file cuda_kernels.cu.
References j.
| void rope_cuda | ( | float * | x_dev, |
| int | num_heads, | ||
| int | head_dim, | ||
| const float * | all_freqs_cis_dev_base, | ||
| int | pos, | ||
| bool | use_adjacent_pairing, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 800 of file cuda_kernels.cu.
| void rope_devpos_cuda | ( | float * | x_dev, |
| int | num_heads, | ||
| int | head_dim, | ||
| const float * | all_freqs_cis_dev_base, | ||
| const int * | step_dev, | ||
| bool | use_adjacent_pairing, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3573 of file cuda_kernels.cu.
References j, and rope_devpos_kernel().
| __global__ void rope_devpos_kernel | ( | float * | x, |
| int | num_heads, | ||
| int | head_dim, | ||
| const float * | all_freqs_cis_base, | ||
| const int * | step_dev, | ||
| bool | use_adjacent_pairing | ||
| ) |
Definition at line 3548 of file cuda_kernels.cu.
Referenced by rope_devpos_cuda().
| __global__ void rope_kernel | ( | float * | x, |
| int | num_heads, | ||
| int | head_dim, | ||
| const float * | all_freqs_cis_base, | ||
| int | pos, | ||
| bool | use_adjacent_pairing | ||
| ) |
Definition at line 767 of file cuda_kernels.cu.
| void silu_cuda | ( | const std::vector< float > & | x_host, |
| std::vector< float > & | out_host, | ||
| int | n | ||
| ) |
Definition at line 521 of file cuda_kernels.cu.
| __global__ void softmax_exp_sum_kernel | ( | const float * | x, |
| float * | partial_sums, | ||
| int | n, | ||
| float | max_val | ||
| ) |
Definition at line 570 of file cuda_kernels.cu.
Definition at line 549 of file cuda_kernels.cu.
| __global__ void softmax_optimized_kernel | ( | const float *__restrict__ | x, |
| float *__restrict__ | out, | ||
| int | n | ||
| ) |
Optimized softmax using shared memory and warp primitives.
Correctly finds max and sum of exponentials at block level for accurate softmax.
Definition at line 2782 of file cuda_kernels.cu.
References atomicAddFloat(), atomicMaxFloat(), j, n, and out.
Referenced by softmax_vector_cuda_optimized().
| void softmax_vector_cuda | ( | const std::vector< float > & | x_host, |
| std::vector< float > & | out_host, | ||
| int | n | ||
| ) |
Definition at line 599 of file cuda_kernels.cu.
| void softmax_vector_cuda_optimized | ( | const float * | x_dev, |
| float * | out_dev, | ||
| int | n, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 3099 of file cuda_kernels.cu.
References j, n, and softmax_optimized_kernel().
| void swiglu_batch_cuda | ( | float * | d_out_batch, |
| const float * | d_gate_act_batch, | ||
| const float * | d_up_act_batch, | ||
| int | num_tokens, | ||
| int | intermediate_size, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 717 of file cuda_kernels.cu.
References Logger::info(), j, and kernel_debug_copies().
| __global__ void swiglu_batch_cuda_kernel | ( | float * | d_out_batch, |
| const float * | d_gate_act_batch, | ||
| const float * | d_up_act_batch, | ||
| int | num_tokens, | ||
| int | intermediate_size | ||
| ) |
Definition at line 690 of file cuda_kernels.cu.
References j.
| void swiglu_cuda | ( | const float * | gate_dev, |
| const float * | up_dev, | ||
| float * | out_dev, | ||
| int | n, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 680 of file cuda_kernels.cu.
| void update_kv_cache_cuda | ( | float * | cache_base_ptr, |
| const float * | current_kv_head_vector, | ||
| int | pos, | ||
| int | kv_head_idx, | ||
| int | max_seq_len, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| cudaStream_t | stream | ||
| ) |
Definition at line 1344 of file cuda_kernels.cu.
References Logger::error(), j, and pos.