repo_name stringlengths 1 62 | dataset stringclasses 1
value | lang stringclasses 11
values | pr_id int64 1 20.1k | owner stringlengths 2 34 | reviewer stringlengths 2 39 | diff_hunk stringlengths 15 262k | code_review_comment stringlengths 1 99.6k |
|---|---|---|---|---|---|---|---|
xFasterTransformer | github_2023 | cpp | 157 | intel | changqi1 | @@ -56,8 +56,12 @@ class Attention {
}
// The inerface is for PyTorch, thus the weights are already transposed
- void setWeights(DecoderContext *ctx, const float *queryWeight, const float *queryBias, const float *keyWeight,
- const float *keyBias, const float *valueWeight, const float *valueBi... | SrcT means WeiT? |
xFasterTransformer | github_2023 | cpp | 157 | intel | changqi1 | @@ -22,13 +22,13 @@ class ChatGLM2MLP : public LlamaMLP<WeiT> {
ChatGLM2MLP(DecoderContext *ctx) : LlamaMLP<WeiT>(ctx) {}
// The inerface is for PyTorch, thus the weights are already transposed
- void setWeights(DecoderContext *ctx, std::vector<float *> ¶ms, bool trans = true) {
+ void setWeights(... | The type could use xft:data_type |
xFasterTransformer | github_2023 | cpp | 157 | intel | changqi1 | @@ -41,16 +41,41 @@ class LlamaMLP : public SingletonBase<LlamaMLP<WeiT>> {
LlamaMLP(DecoderContext *ctx) {}
// The inerface is for PyTorch, thus the weights are already transposed
- void setWeights(DecoderContext *ctx, std::vector<float *> ¶ms, bool trans = true) {
+ void setWeights(DecoderContex... | The type could use xft:data_type |
xFasterTransformer | github_2023 | cpp | 157 | intel | changqi1 | @@ -41,16 +41,41 @@ class LlamaMLP : public SingletonBase<LlamaMLP<WeiT>> {
LlamaMLP(DecoderContext *ctx) {}
// The inerface is for PyTorch, thus the weights are already transposed
- void setWeights(DecoderContext *ctx, std::vector<float *> ¶ms, bool trans = true) {
+ void setWeights(DecoderContex... | SrcT means WeiT? |
xFasterTransformer | github_2023 | cpp | 157 | intel | changqi1 | @@ -464,7 +470,7 @@ class CommonDecoder : public AbstractDecoder {
return this->context.get();
}
- void setDecoderWeights(DECODER *pdecoder, const std::string &modelPath, int layerIdx) {
+ void setDecoderWeights(DECODER *pdecoder, const std::string &modelPath, int layerIdx, bool quant) { | For param: bool quant, how to support fp32, bf16, fp16, int8 and int4 weights? |
xFasterTransformer | github_2023 | cpp | 194 | intel | changqi1 | @@ -0,0 +1,162 @@
+#pragma once | Add License. |
xFasterTransformer | github_2023 | cpp | 194 | intel | changqi1 | @@ -1,161 +1,12 @@
-#include <cstdio>
-#include <omp.h>
-#include "amx_sgemm_bf16bf16bf16.h"
-#include "bfloat16.h"
-#include "copy_util.h"
+#include "attention_kernels.h" | Add License. |
xFasterTransformer | github_2023 | cpp | 194 | intel | changqi1 | @@ -0,0 +1,67 @@
+#pragma once | Add License. |
xFasterTransformer | github_2023 | cpp | 194 | intel | changqi1 | @@ -7,13 +7,15 @@ struct TypeSelector {
using InType = float; | Add License. |
xFasterTransformer | github_2023 | cpp | 194 | intel | changqi1 | @@ -3,43 +3,29 @@
#include <cstdio> | Add License. |
xFasterTransformer | github_2023 | others | 202 | intel | changqi1 | @@ -12,4 +12,7 @@ A web demo based on [Gradio](https://www.gradio.app/) is provided in repo.
Support list:
- ChatGLM
- ChatGLM2
-- Llama2-chat
\ No newline at end of file
+- ChatGLM3
+- Llama2-chat | Llama2 ? |
xFasterTransformer | github_2023 | python | 200 | intel | changqi1 | @@ -0,0 +1,18 @@
+import os | Add License |
xFasterTransformer | github_2023 | cpp | 179 | intel | a3213105 | @@ -35,16 +37,23 @@ class LlamaRotaryEmbedding {
public:
LlamaRotaryEmbedding(const int dim, const int max_position_embeddings = 2048, const float base = 10000);
- ~LlamaRotaryEmbedding() {}
+ ~LlamaRotaryEmbedding();
- void forward(float *query, float *key, int qStride, int kStride, const int *qkSha... | 1. qk_shape already have seq_len, maybe we can add max_seq_length in the qk_shape to avoid upgrading every rotaryEmbedding implementation.
2. The NTK function is only for QWEN, maybe we can create a new implementation for QWEN instead of modifying the original LLAMA implementation.. |
xFasterTransformer | github_2023 | cpp | 178 | intel | pujiang2018 | @@ -155,13 +163,27 @@ void crossAttention(bfloat16_t *output, bfloat16_t *query, bfloat16_t *key, bflo
int maxCtxSize = 0;
int blkOffsets[batchSize]; // offset in blockTables
int curOff = 0;
+
+ if (unlikely(threadNum == 0)) {
+#pragma omp parallel
+ {
+ int tid = omp_get_thread_num(... | Could you pls make the name in camelCase? to align with the overall style.
@aurora327 |
xFasterTransformer | github_2023 | others | 22 | intel | changqi1 | @@ -0,0 +1,45 @@
+#!/bin/bash
+set -e -x
+
+# todo(marvin): move oneccl deps into cmake.
+pushd 3rdparty/
+sh prepare_oneccl.sh
+source ./oneCCL/build/_install/env/setvars.sh
+popd
+
+# Define functions for build, UT, and model
+BUILD() {
+ echo "Running build function with arguments: $@"
+ rm -rf build && mkdir ... | "--input_len=32 --output_len=32" replace with "--input_len=16 --output_len=32 --no_stream" |
xFasterTransformer | github_2023 | others | 26 | intel | changqi1 | @@ -21,15 +21,18 @@ ut() {
model() {
numactl -H
+ core_count=$(lscpu | grep "Core(s) per socket" | awk '{print $NF}')
+
echo "Running model function with arguments: $@"
# DATASETS_LIST=( 'Llama-2-7b' 'chatglm-6b' 'chatglm2-6b' 'llama-13b' 'llama-7b' 'opt-1.3b' 'opt-13b' 'opt-30b' )
DATASETS_LI... | numactl -N 0 -m 0 ? |
xFasterTransformer | github_2023 | cpp | 172 | intel | pujiang2018 | @@ -51,6 +74,9 @@ struct DecoderContext {
// norm epsilon
float epsilon;
+ // rope scaling parameters
+ RopeParams ropeParams; | Is it a must to put RopeParams here? As DecoderContext is used again and again, keep it small may have the potential performance benefit.
If really needed in DecoderContext, suggest to make it as a pointer. so that we could make sure less impact to the models not using this param. |
xFasterTransformer | github_2023 | python | 172 | intel | Duyi-Wang | @@ -0,0 +1,276 @@
+""" | CopyRight |
xFasterTransformer | github_2023 | cpp | 172 | intel | changqi1 | @@ -0,0 +1,120 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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 require... | KV cache need float? |
xFasterTransformer | github_2023 | python | 172 | intel | changqi1 | @@ -121,7 +121,7 @@ def split_and_convert(self, input_dir, output_dir, dtype, processes):
config["llama"]["inter_size"] = str(hf_config["intermediate_size"])
config["llama"]["max_pos_seq_len"] = str(hf_config["max_position_embeddings"])
config["llama"]["num_layer"] = str(hf_config... | llama is layernorm_eps or rms_norm_eps? |
xFasterTransformer | github_2023 | cpp | 158 | intel | pujiang2018 | @@ -492,11 +492,15 @@ class MMHelper {
// W8A8
else if constexpr (std::is_same_v<WeiT, w8a8_t>) {
- weight.Resize(K, N);
auto tag = trans ? dnnl::memory::format_tag::ba : dnnl::memory::format_tag::ab;
dnnl::memory B_mem({{K, N}, dnnl::memory::data_type::s8, tag},... | @xiangzez pls add a todo here (better to add some reserve like function in Matrix, as current 2 times Resize has risks in cases ...) |
xFasterTransformer | github_2023 | cpp | 156 | intel | changqi1 | @@ -187,6 +188,7 @@ void Model::unsetPrefix() {
AutoModel::AutoModel(std::string modelPath, xft::DataType datatype) : Model() {
std::string configPath = modelPath + "/config.ini";
INIReader reader = INIReader(configPath);
+ TimeLine::init(); | Could move `TimeLine::init();` after line 52. |
xFasterTransformer | github_2023 | cpp | 156 | intel | changqi1 | @@ -171,23 +174,77 @@ class TimeLine {
close(lockFileDescriptor);
}
+ inline void startTimeLineEvent(const std::string &name){
+ tag_name = name;
+ pid = getpid();
+ pid = pthread_self();
+ trace_event["ph"] = "X";
+ trace_event["cat"] = "cat";
+ trace_event[... | Sorry, I don't know why to use std::unordered_map structure. vector? |
xFasterTransformer | github_2023 | cpp | 160 | intel | Duyi-Wang | @@ -369,40 +370,47 @@ int main(int argc, char **argv) {
if (prefixLen > 0) { model.setPrefix(perfixSeq); }
for (int i = 0; i < loop; ++i) {
+ secondIdCount = 0;
model.config(/*maxLen*/ maxLen, /*numBeams*/ numBeams, /*numBeamHypsToKeep*/ 1, /*lenPenalty*/ 1.0,
/*doEarlyStopp... | If output_len = 1, secondID Count will be 0. |
xFasterTransformer | github_2023 | others | 132 | intel | pujiang2018 | @@ -96,7 +96,7 @@ else()
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/oneccl/build/_install/lib/prov)
endif()
-set(3RDPART_LIB_LIST ${MPI_LIBS} "ccl" "dnnl" "numa")
+set(3RDPART_LIB_LIST "rt" "dl" "dnnl" "numa") | libdl is for dlopen like functions. so, what is librt for? |
xFasterTransformer | github_2023 | others | 132 | intel | pujiang2018 | @@ -0,0 +1,20 @@
+# Copyright (c) 2023 Intel Corporation
+#
+# 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 appli... | formatted? 2 blanks here. |
xFasterTransformer | github_2023 | cpp | 132 | intel | pujiang2018 | @@ -0,0 +1,88 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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... | Do we need to export pcomm? If not, suggest add static keyword. |
xFasterTransformer | github_2023 | cpp | 141 | intel | abenmao | @@ -59,13 +59,21 @@ EvalAutoDecoder::EvalAutoDecoder(std::string modelPath, std::string dtype) {
pdecoder = new LlamaLLM<uint4x2_t>(modelPath);
} else if (dtype == "bf16") {
pdecoder = new LlamaLLM<bfloat16_t>(modelPath);
+ } else if (dtype == "nf4") {
+ pdecoder = n... | missing a space on the left of else |
xFasterTransformer | github_2023 | cpp | 129 | intel | pujiang2018 | @@ -176,6 +177,38 @@ class OptTokenizer : public TokenizerBase {
const char **vocab_list = vocab_opt;
};
+class QwenTokenizer : public TokenizerBase {
+public:
+ QwenTokenizer(std::string &tokenPath) { vocabSize = 151851; }
+
+ std::vector<int> encode(std::string &input) override {
+ return std::ve... | Here why return a fixed vector? |
xFasterTransformer | github_2023 | cpp | 129 | intel | pujiang2018 | @@ -176,6 +177,38 @@ class OptTokenizer : public TokenizerBase {
const char **vocab_list = vocab_opt;
};
+class QwenTokenizer : public TokenizerBase {
+public:
+ QwenTokenizer(std::string &tokenPath) { vocabSize = 151851; }
+
+ std::vector<int> encode(std::string &input) override {
+ return std::ve... | We could consider reserving the capacity, like:
class YourDecoder : public SomeBaseClass {
public:
std::string decode(const std::vector<int>& ids) override {
if (ids.size() == 1) {
return decode(ids[0]);
}
std::string text;
text.reserve(ids.size() * averageStr... |
xFasterTransformer | github_2023 | cpp | 129 | intel | pujiang2018 | @@ -0,0 +1,40 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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... | Is KV cache FP32 a MUST? can we use FP16? |
xFasterTransformer | github_2023 | python | 129 | intel | a3213105 | @@ -0,0 +1,266 @@
+"""
+Convert huggingface ChatGLM model. Use https://huggingface.co/Qwen | maybe using Qwen is better than ChatGLM |
xFasterTransformer | github_2023 | cpp | 137 | intel | changqi1 | @@ -39,7 +39,7 @@ class ChatGLM2MLP : public LlamaMLP<WeiT> {
int colSplit = range.second - range.first;
setMLPOPTConfig();
- if (!enableCATMLP) {
+ if (!enableCATMLP or std::is_same_v<WeiT, uint4x2_t>) { | nf4x2_t? |
xFasterTransformer | github_2023 | cpp | 135 | intel | pujiang2018 | @@ -0,0 +1,223 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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 require... | looks like no reorder here, can we directly copy? |
xFasterTransformer | github_2023 | python | 135 | intel | pujiang2018 | @@ -0,0 +1,144 @@
+# Copyright (c) 2023 Intel Corporation
+#
+# 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 appl... | shall we remove all "import pdb"? |
xFasterTransformer | github_2023 | cpp | 123 | intel | changqi1 | @@ -1541,11 +1626,230 @@ class MMHelper {
get_dnnl_stream().wait();
}
-private:
+ static void onednn_gemm_s8s8s32(bool transA, int M, int N, int K, float alpha, const int8_t *A, int lda,
+ const int8_t *B, float beta, int32_t *C, int ldc) {
+ TimeLine t("onednn_gemm_s8s8s32");
+ ... | could use unique_ptr to reduce free func.
#define ALLOC(DATATYPE, VALUE, SIZE) std::unique_ptr<DATATYPE, decltype(&free)> VALUE(static_cast<DATATYPE*>(aligned_alloc(64, SIZE * sizeof(DATATYPE))), &free) |
xFasterTransformer | github_2023 | cpp | 123 | intel | changqi1 | @@ -1541,11 +1626,230 @@ class MMHelper {
get_dnnl_stream().wait();
}
-private:
+ static void onednn_gemm_s8s8s32(bool transA, int M, int N, int K, float alpha, const int8_t *A, int lda,
+ const int8_t *B, float beta, int32_t *C, int ldc) {
+ TimeLine t("onednn_gemm_s8s8s32");
+ ... | N 需要是 16的倍数? |
xFasterTransformer | github_2023 | cpp | 123 | intel | changqi1 | @@ -1541,11 +1626,230 @@ class MMHelper {
get_dnnl_stream().wait();
}
-private:
+ static void onednn_gemm_s8s8s32(bool transA, int M, int N, int K, float alpha, const int8_t *A, int lda,
+ const int8_t *B, float beta, int32_t *C, int ldc) {
+ TimeLine t("onednn_gemm_s8s8s32");
+ ... | maybe use fma to replace div+sub? |
xFasterTransformer | github_2023 | cpp | 123 | intel | changqi1 | @@ -1541,11 +1626,230 @@ class MMHelper {
get_dnnl_stream().wait();
}
-private:
+ static void onednn_gemm_s8s8s32(bool transA, int M, int N, int K, float alpha, const int8_t *A, int lda,
+ const int8_t *B, float beta, int32_t *C, int ldc) {
+ TimeLine t("onednn_gemm_s8s8s32");
+ ... | For better, need some formula annotations to explain those logic. |
xFasterTransformer | github_2023 | cpp | 123 | intel | changqi1 | @@ -1541,11 +1626,230 @@ class MMHelper {
get_dnnl_stream().wait();
}
-private:
+ static void onednn_gemm_s8s8s32(bool transA, int M, int N, int K, float alpha, const int8_t *A, int lda,
+ const int8_t *B, float beta, int32_t *C, int ldc) {
+ TimeLine t("onednn_gemm_s8s8s32");
+ ... | For better, need some formula annotations to explain those logic. |
xFasterTransformer | github_2023 | cpp | 123 | intel | changqi1 | @@ -1541,11 +1626,230 @@ class MMHelper {
get_dnnl_stream().wait();
}
-private:
+ static void onednn_gemm_s8s8s32(bool transA, int M, int N, int K, float alpha, const int8_t *A, int lda,
+ const int8_t *B, float beta, int32_t *C, int ldc) {
+ TimeLine t("onednn_gemm_s8s8s32");
+ ... | #pragma omp parallel for collapse(2) |
xFasterTransformer | github_2023 | cpp | 123 | intel | changqi1 | @@ -1541,11 +1626,230 @@ class MMHelper {
get_dnnl_stream().wait();
}
-private:
+ static void onednn_gemm_s8s8s32(bool transA, int M, int N, int K, float alpha, const int8_t *A, int lda,
+ const int8_t *B, float beta, int32_t *C, int ldc) {
+ TimeLine t("onednn_gemm_s8s8s32");
+ ... | rename: onednn_amx_gemm_f32s8f32_compute |
xFasterTransformer | github_2023 | cpp | 123 | intel | changqi1 | @@ -1541,11 +1626,230 @@ class MMHelper {
get_dnnl_stream().wait();
}
-private:
+ static void onednn_gemm_s8s8s32(bool transA, int M, int N, int K, float alpha, const int8_t *A, int lda, | rename: onednn_amx_gemm_s8s8s32_compute |
xFasterTransformer | github_2023 | others | 123 | intel | changqi1 | @@ -112,6 +112,7 @@ add_definitions(-DAVX512_FP16_WEIGHT_ONLY_FP16=true)
add_definitions(-DAVX512_BF16_WEIGHT_ONLY_BF16=true)
# add_definitions(-DAVX512_FP32_WEIGHT_ONLY_INT8=true)
add_definitions(-DAVX512_FP16_WEIGHT_ONLY_INT8=true)
+# add_definitions(-DAMX_INT8=true) | // # add_definitions(-DAMX_INT8_W8A8=true) |
xFasterTransformer | github_2023 | cpp | 123 | intel | changqi1 | @@ -1541,11 +1626,230 @@ class MMHelper {
get_dnnl_stream().wait();
}
-private:
+ static void onednn_gemm_s8s8s32(bool transA, int M, int N, int K, float alpha, const int8_t *A, int lda,
+ const int8_t *B, float beta, int32_t *C, int ldc) {
+ TimeLine t("onednn_gemm_s8s8s32");
+ ... | could use template to improve perf, not use switch case. |
xFasterTransformer | github_2023 | cpp | 123 | intel | changqi1 | @@ -194,6 +194,7 @@ AutoModel::AutoModel(std::string modelPath, xft::DataType datatype) : Model() {
case xft::DataType::fp16: setDecoder(new OptDecoder<float16_t>(modelPath)); break;
case xft::DataType::bf16: setDecoder(new OptDecoder<bfloat16_t>(modelPath)); break;
case xft::Data... | need to add more config after case xft::DataType::bf16_int8:
case xft::DataType::bf16_w8a8:
setDecoder(new HybridModel<OptDecoder, bfloat16_t, w8a8_t>(modelPath));
break;
need to add more config after case xft::DataType::bf16_nf4:
case xft::DataType::w8a8_int8:
setDecoder(new HybridM... |
xFasterTransformer | github_2023 | cpp | 103 | intel | changqi1 | @@ -235,31 +236,61 @@ class Matrix {
this->rows = rows;
this->cols = cols;
this->stride = m.stride;
+ if (xft_get_verbose() == 2) { | when real allocation |
xFasterTransformer | github_2023 | cpp | 103 | intel | changqi1 | @@ -340,18 +341,51 @@ class MMHelper {
const float *scaleB, const float *zeroB, float beta, OutT *C, int ldc) {
// FP32
if constexpr (std::is_same_v<WeiT, float>) {
- TimeLine t("xdnn_sgemm_compute");
- xdnn_sgemm_compute(transA, M, N, K, alpha, A, lda, packedB, beta... | Use Macro to define the logical. |
xFasterTransformer | github_2023 | cpp | 103 | intel | changqi1 | @@ -340,18 +341,51 @@ class MMHelper {
const float *scaleB, const float *zeroB, float beta, OutT *C, int ldc) {
// FP32
if constexpr (std::is_same_v<WeiT, float>) {
- TimeLine t("xdnn_sgemm_compute");
- xdnn_sgemm_compute(transA, M, N, K, alpha, A, lda, packedB, beta... | Need to format it |
xFasterTransformer | github_2023 | cpp | 103 | intel | changqi1 | @@ -0,0 +1,27 @@
+#pragma once
+#ifndef VERBOSE_HPP
+#define VERBOSE_HPP
+
+#include <cinttypes>
+#include <mutex>
+#include <stdio.h>
+#include <sys/time.h>
+
+static double get_msec() {
+ struct timeval time;
+ gettimeofday(&time, nullptr);
+ return 1e+3 * static_cast<double>(time.tv_sec)
+ + 1e-3... | need to use class to get verbose value |
xFasterTransformer | github_2023 | cpp | 103 | intel | changqi1 | @@ -0,0 +1,27 @@
+#pragma once
+#ifndef VERBOSE_HPP
+#define VERBOSE_HPP
+
+#include <cinttypes>
+#include <mutex>
+#include <stdio.h>
+#include <sys/time.h>
+
+static double get_msec() {
+ struct timeval time;
+ gettimeofday(&time, nullptr); | #include <chrono>
auto tag_0 = std::chrono::high_resolution_clock::now();
decltype(tag_0) tag_1;
static std::chrono::duration<double> diff_0_1 = tag_0 - tag_0;
...
tag_1 = std::chrono::high_resolution_clock::now();
diff_0_1 += tag_1 - tag_0; |
xFasterTransformer | github_2023 | cpp | 103 | intel | changqi1 | @@ -0,0 +1,89 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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... | #include \<iostream> |
xFasterTransformer | github_2023 | cpp | 103 | intel | changqi1 | @@ -480,6 +480,7 @@ class MMHelper {
template <typename InT, typename WeiT, typename OutT>
static void compute(bool transA, int M, int N, int K, float alpha, const InT *A, int lda, const WeiT *packedB,
const float *scaleB, const float *zeroB, float beta, OutT *C, int ldc) {
+ Env::xft_set_... | Could call it once at the beginning of the application. |
xFasterTransformer | github_2023 | cpp | 103 | intel | changqi1 | @@ -300,6 +304,9 @@ class Matrix {
this->cols = cols;
this->stride = stride;
this->data.Resize(rows, cols, stride);
+
+ Env::xft_set_verbose(); | the MatrixVerbose(rows, cols, stride, T) func could in Resize() |
xFasterTransformer | github_2023 | others | 118 | intel | Duyi-Wang | @@ -0,0 +1,87 @@
+#!/bin/bash
+# Copyright (c) 2023 Intel Corporation
+#
+# 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 requ... | Expose the model name and data type as parameters, which should make it more convenient to use. |
xFasterTransformer | github_2023 | others | 118 | intel | Duyi-Wang | @@ -0,0 +1,87 @@
+#!/bin/bash
+# Copyright (c) 2023 Intel Corporation
+#
+# 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 requ... | How to distinguish between 1S and 2S case? If I want to test Llama7B with 1S and Llama13B with 2S in SPR-HBM |
xFasterTransformer | github_2023 | python | 118 | intel | Duyi-Wang | @@ -115,8 +119,6 @@ def build_inputs_baichuan(tokenizer, query: List[str], padding, history: List[Tu
if args.batch_size > 1:
print("[INFO] chat mode only support batchsize=1")
input_ids = build_inputs_chatglm(tokenizer, input_prompts, args.padding)
- elif "baichuan" in ... | Why remove this? |
xFasterTransformer | github_2023 | others | 124 | intel | Duyi-Wang | @@ -21,9 +21,6 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
endif()
find_package (Python COMPONENTS Interpreter Development)
-execute_process(COMMAND ${Python_EXECUTABLE} -m pip install --prefix=${CMAKE_SOURCE_DIR}/3rdparty/mkl mkl mkl-include
- RESULT_VARIABLE EXIT_CODE
- OU... | Please specify the version |
xFasterTransformer | github_2023 | python | 122 | intel | marvin-Yu | @@ -0,0 +1,66 @@
+# Copyright (c) 2023 Intel Corporation
+#
+# 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 appli... | We can add the bf16_int4 data type. |
xFasterTransformer | github_2023 | cpp | 106 | intel | pujiang2018 | @@ -500,98 +502,123 @@ class DecoderUtil {
}
}
- // batchs x seqlen x 3 x head x heads -> 3 x batchs x head x seqlen x heads (2
- // 0 3 1 4)
- template <typename T, typename Tt>
- static void transposeQKV(const T *qkvBuffer, Tt *qkvTransBuffer, int batchSize, int seqLen, int headQNum,
- ... | shall we check if T is float? |
xFasterTransformer | github_2023 | cpp | 106 | intel | pujiang2018 | @@ -500,98 +502,123 @@ class DecoderUtil {
}
}
- // batchs x seqlen x 3 x head x heads -> 3 x batchs x head x seqlen x heads (2
- // 0 3 1 4)
- template <typename T, typename Tt>
- static void transposeQKV(const T *qkvBuffer, Tt *qkvTransBuffer, int batchSize, int seqLen, int headQNum,
- ... | Is it for vector version of exp? if so, there is already one in some place named vexp. |
xFasterTransformer | github_2023 | cpp | 106 | intel | pujiang2018 | @@ -878,7 +914,8 @@ class Attention {
}
virtual const float *getMask(const float *attnMask, int bId, int hId, int srcLen, int tgtLen) {
- return attnMask + bId * srcLen * tgtLen;
+ return attnMask; | why different with origin? |
xFasterTransformer | github_2023 | cpp | 106 | intel | pujiang2018 | @@ -755,60 +771,74 @@ class Attention {
}
}
}
- free(transQKV);
}
// scaled dot-product attention: bmm1 + softmax + bmm2
- void scaledDpAttention(const float *query, const float *key, const float *value, const float *attnMask, float scale,
- int ba... | any design principle here? if any, would you make some comment? |
xFasterTransformer | github_2023 | cpp | 106 | intel | pujiang2018 | @@ -755,60 +771,74 @@ class Attention {
}
}
}
- free(transQKV);
}
// scaled dot-product attention: bmm1 + softmax + bmm2
- void scaledDpAttention(const float *query, const float *key, const float *value, const float *attnMask, float scale,
- int ba... | Does it better to use SimpleMemPool to get the buffer? (SimpleMemPool will maintain the buffer, so next layer directly use) |
xFasterTransformer | github_2023 | cpp | 106 | intel | pujiang2018 | @@ -37,37 +37,68 @@ class ChatGLM2MLP : public LlamaMLP<WeiT> {
auto range = SplitUtil::getTaskRange(intermediateSize, ctx->numSplit, ctx->splitIdx);
int colSplit = range.second - range.first;
- float *gateW = (float *)malloc(hiddenSize * colSplit * sizeof(float));
- float *upW = (floa... | why we provide the option to disable this? |
xFasterTransformer | github_2023 | cpp | 106 | intel | pujiang2018 | @@ -114,25 +130,41 @@ class LlamaMLP : public SingletonBase<LlamaMLP<WeiT>> {
dbg.dumpMatrix(normBuffer);
#endif
- gateProj(doLnBefore ? normBuffer : inBuffer, imBuffer);
+ int enable = (getenv("ENABLE_CAT_MLP") ? atoi(getenv("ENABLE_CAT_MLP")) : 1);
+ if (enable == 0) {
+ au... | need to format? |
xFasterTransformer | github_2023 | python | 110 | intel | Duyi-Wang | @@ -23,13 +23,13 @@
_import_structure = {
"automodel": ["AutoModel"],
- "tools": ["LlamaConvert", "ChatGLMConvert", "ChatGLM2Convert", "OPTConvert", "BaichuanConvert"],
+ "tools": ["LlamaConvert", "ChatGLMConvert", "ChatGLM23Convert", "OPTConvert", "BaichuanConvert"], | I think providing three API `ChatGLM2Convert`, `ChatGLM3Convert`,`ChatGLM23Convert` is more friendly for user and forward compatible, even they are one thing. |
xFasterTransformer | github_2023 | cpp | 115 | intel | pujiang2018 | @@ -0,0 +1,75 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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... | please use English. |
xFasterTransformer | github_2023 | others | 51 | intel | changqi1 | @@ -81,11 +82,7 @@ docker pull intel/xfastertransformer:latest
pip install torch --index-url https://download.pytorch.org/whl/cpu
```
-##### Docker(Recommended)
-- Pull docker image from dockerhub
- ```bash
- docker pull intel/xfastertransformer:dev-ubuntu22.04 | Why delete it? |
xFasterTransformer | github_2023 | cpp | 53 | intel | pujiang2018 | @@ -24,27 +24,41 @@ class KVCacheManager {
this->layers = layers;
this->cachedKeys = new KVCacheTensor<KVCacheT>[layers];
this->cachedValues = new KVCacheTensor<KVCacheT>[layers];
+ this->cachedPrefixKeys = new KVCacheTensor<KVCacheT>[layers]; | If prefix_sharing=false, do not need to allocate it (although small memory).
Suggest allocating it when really needed. |
xFasterTransformer | github_2023 | cpp | 53 | intel | pujiang2018 | @@ -143,31 +152,54 @@ class CommonDecoder : public AbstractDecoder {
// Reset initial and accumulated sequence length at the first step
this->initSeqLen = seqLen;
this->accSeqLen = 0;
+ if (this->prefixSharing) {
+ pastSeqLen = this->prefixSeqLen;
+ ... | any chance to free the ID in future since it is dynamically allocated? |
xFasterTransformer | github_2023 | cpp | 53 | intel | pujiang2018 | @@ -143,31 +152,54 @@ class CommonDecoder : public AbstractDecoder {
// Reset initial and accumulated sequence length at the first step
this->initSeqLen = seqLen;
this->accSeqLen = 0;
+ if (this->prefixSharing) {
+ pastSeqLen = this->prefixSeqLen;
+ ... | Do we really need to call getPositionIds? |
xFasterTransformer | github_2023 | cpp | 53 | intel | pujiang2018 | @@ -437,16 +441,31 @@ class Attention {
const int queryLen = ctx->inputSeqLen;
const int keyLen = pastSeqLen + ctx->inputSeqLen;
- small_gemm_transb(
- getMask(attnMask, b, i, queryLen, keyLen) + startSeq * keyLen, A, B, C, m, n, ... | if not need, pls remove such commented code. |
xFasterTransformer | github_2023 | cpp | 53 | intel | pujiang2018 | @@ -143,31 +152,54 @@ class CommonDecoder : public AbstractDecoder {
// Reset initial and accumulated sequence length at the first step
this->initSeqLen = seqLen;
this->accSeqLen = 0;
+ if (this->prefixSharing) {
+ pastSeqLen = this->prefixSeqLen;
+ ... | The purpose of this step is? |
xFasterTransformer | github_2023 | python | 77 | intel | changqi1 | @@ -174,6 +178,10 @@ def build_inputs_baichuan(tokenizer, query: List[str], padding, history: List[Tu
print("=" * 50 + args.model_name + " Final Performance" + "=" * 50)
print(f"Inference Latency:\t{inference_latency:.2f} s")
print(f"First token Latency:\t{first_token_latency:.2f} ms") | print(f"First token Avg Latency:\t{first_token_latency:.2f} ms") |
xFasterTransformer | github_2023 | python | 77 | intel | changqi1 | @@ -163,7 +164,10 @@ def build_inputs_baichuan(tokenizer, query: List[str], padding, history: List[Tu
output_token_nums = int(torch.numel(generated_ids) / args.batch_size) - input_token_nums
# Sort the execution times in ascending order
remained_token_times.sort()
- # Get the 90th elem... | next_token_latency_max
next_token_latency_min
next_token_latency_max
next_token_latency_90 |
xFasterTransformer | github_2023 | cpp | 64 | intel | pujiang2018 | @@ -0,0 +1,62 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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... | Why we need a lock here? to protect the unordered_map access?
If so, suggest narrowing down the scope. |
xFasterTransformer | github_2023 | cpp | 64 | intel | pujiang2018 | @@ -0,0 +1,62 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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... | I think the address is enough, do we really need to add the size info in the key? |
xFasterTransformer | github_2023 | cpp | 64 | intel | pujiang2018 | @@ -0,0 +1,62 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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... | how do we reuse the context? to make sure better performance, we need to reuse the context for every layers. |
xFasterTransformer | github_2023 | cpp | 64 | intel | pujiang2018 | @@ -0,0 +1,63 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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... | since now we are using a static variable: "static DecoderContext *ctx;"
If multi-threads calls into invokeMLPLLaMA, then potentially they together modify the value of 'ctx', or use the same intermediate buffer at the same time, thus make problem.
So, this time, I think we need to expand the lock scope, :) |
xFasterTransformer | github_2023 | cpp | 45 | intel | changqi1 | @@ -33,6 +33,8 @@ class Model {
bool doEarlyStopping_ = false, int eosTokenId_ = -1, int padTokenId_ = -1, bool doSample_ = false,
float temperature_ = 1.0, int topK_ = 50, float topP_ = 1.0);
+ void config(SearcherConfig &config_); | When you have added the config api, but you didn't use it? |
xFasterTransformer | github_2023 | cpp | 15 | intel | Duyi-Wang | @@ -0,0 +1,19 @@
+#pragma once
+#include "compile_util.h"
+#include "dtype.h"
+#include <cmath>
+#include <cstring>
+#include <iostream>
+
+namespace xft {
+void xftRotaryEmbeddingKernel(DataType dt, | Why not just name `RotaryEmbeddingKernel` and used as `xft::RotaryEmbeddingKernel`? |
xFasterTransformer | github_2023 | cpp | 24 | intel | Duyi-Wang | @@ -0,0 +1,28 @@
+#pragma once
+#include <iostream>
+
+class AlibiEmbedding {
+public:
+ AlibiEmbedding(const int headNum, const int seqLen);
+
+ ~AlibiEmbedding() {
+ maxLen = 0;
+ maxHeadNums = 0;
+ free(posMatrix);
+ free(slopeM);
+ }
+
+ void alibiGetRelativePos(const int seq... | What's the meaning of this bool var? Nothing will be shared between objects. |
xFasterTransformer | github_2023 | cpp | 41 | intel | pujiang2018 | @@ -75,8 +76,8 @@ struct DecoderContext {
public:
DecoderContext(int _layers, int _hiddenSize, int _attHeadNum, int _kvHeadNum, int _imSize, const std::string &act,
- float epsilon, int _vocabSize, int _embeddingSize, int _maxPositions, int _splitIdx, int _splits,
- int numThreads = 0)
+ ... | shall we reuse maxPositions as maxPosEmbed? so that we can make no change for DecoderContext. |
xFasterTransformer | github_2023 | cpp | 41 | intel | pujiang2018 | @@ -0,0 +1,67 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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... | delete[] alibiSlopes; |
xFasterTransformer | github_2023 | cpp | 41 | intel | pujiang2018 | @@ -561,24 +561,23 @@ class DecoderUtil {
// need to do for res.
static void softmaxTile(float *AB, float *sum, float *max, float *preSum, float *preMax, float refac,
const float *attnMask, int m, int k, int attnMskStride) {
- float max_val = std::numeric_limits<float>::lowest();
+ ... | I think the naming of maxVal is better than minVal, as it represents the maximum elements in that channel. |
xFasterTransformer | github_2023 | cpp | 21 | intel | pujiang2018 | @@ -0,0 +1,208 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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 require... | suggest firstly compute temperature reciprocal, and then use multiply instead of divide. |
xFasterTransformer | github_2023 | cpp | 21 | intel | pujiang2018 | @@ -0,0 +1,208 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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 require... | What's the typical size of topK? if topK is big, could consider using vExp in BertUtil |
xFasterTransformer | github_2023 | cpp | 21 | intel | pujiang2018 | @@ -0,0 +1,208 @@
+// Copyright (c) 2023 Intel Corporation
+//
+// 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 require... | similarly, we could avoid divide by using multiply. |
xFasterTransformer | github_2023 | cpp | 19 | intel | Duyi-Wang | @@ -50,6 +65,12 @@ void Model::config(int maxLen_, int numBeams_, int numBeamHypsToKeep_, float len
Messenger &messenger = decoder->getMessenger();
messenger.broadcast((int *)&configuration, sizeof(SearcherConfig) / sizeof(int));
+ // Slaves get exit flags and exit directly
+ if (decoder->getRank() > ... | I think numBeams == 0 is enough. |
xFasterTransformer | github_2023 | cpp | 19 | intel | Duyi-Wang | @@ -14,10 +14,25 @@
namespace xft {
Model::~Model() {
+ exitSlaves();
if (decoder != nullptr) { delete decoder; }
if (searcher != nullptr) { delete searcher; }
}
+void Model::exitSlaves() {
+ if (decoder->getRank() == 0) {
+ configuration.maxLen = 0;
+ configuration.numBeams = 0;
+ ... | Just set numBeams == 0 is ok. Some other settings will be added and it will redundant if set all of attributes. |
xFasterTransformer | github_2023 | python | 19 | intel | Duyi-Wang | @@ -19,7 +19,7 @@ def rank(self):
def finalize(self):
return self.model.finalize()
-
+ | an extra tab |
xFasterTransformer | github_2023 | cpp | 16 | intel | pujiang2018 | @@ -177,6 +177,18 @@ class Attention {
auto &resultBuffer1 = imBuffer;
auto &resultBuffer2 = ctx->tmpBuf;
+ //init group_qkvBuffer
+ int attHeadSize = ctx->attHeadSize;
+ int qkvRows = ctx->batchSize * inputSeqLen;
+ // group attention
+ int q_cols = (this->endQHea... | Let's unify the naming format, 'qCols' |
xFasterTransformer | github_2023 | cpp | 16 | intel | pujiang2018 | @@ -177,6 +177,18 @@ class Attention {
auto &resultBuffer1 = imBuffer;
auto &resultBuffer2 = ctx->tmpBuf;
+ //init group_qkvBuffer | Let's align the comment format, "// Init ..." |
openvino-ai-plugins-gimp | github_2023 | others | 156 | intel | gblong1 | @@ -49,7 +49,7 @@ deactivate
echo "Installing plugin in $HOME/.config/GIMP/2.99/plug-ins"
for d in openvino_utils semseg_ov stable_diffusion_ov superresolution_ov; do
mkdir -p "$HOME/.config/GIMP/2.99/plug-ins/$d"
- rsync -a gimpenv3/lib/python*/site-packages/gimpopenvino/plugins/"$d" "$HOME/.config/GIMP/2.99... | The issue with this line is that it will miss the gimp_openvino_config.json file copy to the default config_dir_path in the case that an Environment variable is not used.
The goal here is to copy from the $script_dir because of the executable permissions change needed? |
openvino-ai-plugins-gimp | github_2023 | python | 145 | intel | RyanMetcalfeInt8 | @@ -174,8 +174,11 @@ def load_model(self, model, model_name, device):
if "NPU" in device:
with open(os.path.join(model, f"{model_name}.blob"), "rb") as f:
return self.core.import_model(f.read(), device)
- return self.core.compile_model(os.path.join(model, f"{model_name}.xml... | Is ```GPU_QUEUE_THROTTLE``` guaranteed to be a valid property for any GPU device (integrated, discrete, previous gen, etc.)? |
openvino-ai-plugins-gimp | github_2023 | others | 123 | intel | gblong1 | @@ -1,19 +1,26 @@
-numpy
-future
-scipy
-typing
+# Core dependencies
+diffusers
+ftfy>=6.1.1,<6.2.0
gdown
-requests
+numpy>=1.19.0
opencv-python<=4.3
+openvino
+psutil
+requests
+scipy
scikit-image
+streamlit>=1.30.0,<1.31.0 | Why less than 1.31 for streamlit? |
openvino-ai-plugins-gimp | github_2023 | others | 123 | intel | gblong1 | @@ -1,19 +1,26 @@
-numpy
-future
-scipy
-typing
+# Core dependencies
+diffusers
+ftfy>=6.1.1,<6.2.0
gdown
-requests
+numpy>=1.19.0
opencv-python<=4.3
+openvino
+psutil
+requests
+scipy
scikit-image
+streamlit>=1.30.0,<1.31.0
timm==0.4.5
-diffusers
-openvino
-transformers
-tqdm==4.66.3
-huggingface_hub
-streamlit==1... | why this range for tqdm? |
openvino-ai-plugins-gimp | github_2023 | others | 123 | intel | gblong1 | @@ -1,19 +1,26 @@
-numpy
-future
-scipy
-typing
+# Core dependencies
+diffusers
+ftfy>=6.1.1,<6.2.0 | What is the reason for <6.2.0? |
openvino-ai-plugins-gimp | github_2023 | python | 91 | intel | gblong1 | @@ -113,89 +124,106 @@ def run(model_name,device_name):
log.info('Initializing Inference Engine...')
log.info('Model Path: %s',model_path )
- log.info('device_name: %s',device_name)
+ log.info('supported device_name: %s',device_name) | device name is no longer an array, so let's remove this. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.