-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,963 additions
and
84 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
.buildkite/lm-eval-harness/configs/Meta-Llama-3-8B-QQQ.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# bash .buildkite/lm-eval-harness/run-lm-eval-gsm-vllm-baseline.sh -m HandH1998/QQQ-Llama-3-8b-g128 -b 32 -l 250 -f 5 -t 1 | ||
model_name: "HandH1998/QQQ-Llama-3-8b-g128" | ||
tasks: | ||
- name: "gsm8k" | ||
metrics: | ||
- name: "exact_match,strict-match" | ||
value: 0.484 | ||
- name: "exact_match,flexible-extract" | ||
value: 0.492 | ||
limit: 250 | ||
num_fewshot: 5 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Modified by HandH1998 | ||
* Modified by Neural Magic | ||
* Copyright (C) Marlin.2024 Elias Frantar | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
constexpr int ceildiv(int a, int b) { return (a + b - 1) / b; } | ||
|
||
// Instances of `Vec` are used to organize groups of >>registers<<, as needed | ||
// for instance as inputs to tensor core operations. Consequently, all | ||
// corresponding index accesses must be compile-time constants, which is why we | ||
// extensively use `#pragma unroll` throughout the kernel code to guarantee | ||
// this. | ||
template <typename T, int n> | ||
struct Vec { | ||
T elems[n]; | ||
__device__ T& operator[](int i) { return elems[i]; } | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Modified by HandH1998 | ||
* Modified by Neural Magic | ||
* Copyright (C) Marlin.2024 Elias Frantar | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
// Predicated asynchronous global->shared copy; used for inputs A where we apply | ||
// predication to handle batchsizes that are not multiples of 16. | ||
__device__ inline void cp_async4_pred(void* smem_ptr, const void* glob_ptr, | ||
bool pred = true) { | ||
const int BYTES = 16; | ||
uint32_t smem = static_cast<uint32_t>(__cvta_generic_to_shared(smem_ptr)); | ||
asm volatile( | ||
"{\n" | ||
" .reg .pred p;\n" | ||
" setp.ne.b32 p, %0, 0;\n" | ||
" @p cp.async.cg.shared.global [%1], [%2], %3;\n" | ||
"}\n" ::"r"((int)pred), | ||
"r"(smem), "l"(glob_ptr), "n"(BYTES)); | ||
} | ||
|
||
// Asynchronous global->shared copy | ||
__device__ inline void cp_async4(void* smem_ptr, const void* glob_ptr) { | ||
const int BYTES = 16; | ||
uint32_t smem = static_cast<uint32_t>(__cvta_generic_to_shared(smem_ptr)); | ||
asm volatile( | ||
"{\n" | ||
" cp.async.cg.shared.global [%0], [%1], %2;\n" | ||
"}\n" ::"r"(smem), | ||
"l"(glob_ptr), "n"(BYTES)); | ||
} | ||
|
||
// Async copy fence. | ||
__device__ inline void cp_async_fence() { | ||
asm volatile("cp.async.commit_group;\n" ::); | ||
} | ||
|
||
// Wait until at most `n` async copy stages are still pending. | ||
template <int n> | ||
__device__ inline void cp_async_wait() { | ||
asm volatile("cp.async.wait_group %0;\n" ::"n"(n)); | ||
} | ||
|
||
// Wait until barrier reaches `count`, then lock for current threadblock. | ||
__device__ inline void barrier_acquire(int* lock, int count) { | ||
if (threadIdx.x == 0) { | ||
int state = -1; | ||
do | ||
// Guarantee that subsequent writes by this threadblock will be visible | ||
// globally. | ||
asm volatile("ld.global.acquire.gpu.b32 %0, [%1];\n" | ||
: "=r"(state) | ||
: "l"(lock)); | ||
while (state != count); | ||
} | ||
__syncthreads(); | ||
} | ||
|
||
// Release barrier and increment visitation count. | ||
__device__ inline void barrier_release(int* lock, bool reset = false) { | ||
__syncthreads(); | ||
if (threadIdx.x == 0) { | ||
if (reset) { | ||
lock[0] = 0; | ||
return; | ||
} | ||
int val = 1; | ||
// Make sure that all writes since acquiring this barrier are visible | ||
// globally, while releasing the barrier. | ||
asm volatile("fence.acq_rel.gpu;\n"); | ||
asm volatile("red.relaxed.gpu.global.add.s32 [%0], %1;\n" | ||
: | ||
: "l"(lock), "r"(val)); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.