Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] fixed shm reduceAdd & rope error when batch size is large #457

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/kernels/rotary_embedding_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static inline void chatglm2ApplyRotaryPosEmbeding(T *query, T *key, int qStride,
for (int head = 0; head < head_num; ++head) {
for (int bs = 0; bs < batch_size; ++bs) {
for (int seq = 0; seq < seq_len; ++seq) {
T *pF = query + seq * qStride + head * dim;
T *pF = query + bs * seq_len * qStride + seq * qStride + head * dim;

int pos = position_ids[seq];
float *pcos = emb_cos + pos * dim;
Expand Down
3 changes: 2 additions & 1 deletion src/utils/shm_reduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ void ShmReduction::ShmResize(int rank, size_t size) {
// shm_unlink(shmCtx_.name);

// alloc and map new shm
total_size = total_size - shmCtx_.nbytes + size;
shmCtx_.nbytes = size;
shmCtx_.nblocks = (size + SHM_BLOCK_SIZE - 1) / SHM_BLOCK_SIZE;
total_size = sizeof(int) * shmCtx_.nstates + shmCtx_.nbytes + shmCtx_.nblocks * shmCtx_.nstates;
// Truncate the shared memory to the desired size
if (rank == 0 && ftruncate(shmCtx_.fp, total_size) == -1) {
perror("shm ftruncate failed.");
Expand Down