mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2026-04-23 00:17:25 +08:00
93fcf7e4ec
* w4afp8 支持per group * code style * 精度完成 * revert append attn utils * ffn1 动态量化 * ffn2 支持动态量化 * code style * code style * 修改单测 * 修改单测 * fix bug * Implement conditional parameter creation for layers Add parameter creation for up_gate_proj_in_scale when ep_size > 1. * code style * fix conflict * code style * code style * 修复w4aint8 精度 * fix ci --------- Co-authored-by: yuanxiaolan <yuanxiaolan01@baidu.com>
48 lines
1.9 KiB
C++
48 lines
1.9 KiB
C++
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
|
//
|
|
// 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
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include "helper.h"
|
|
|
|
std::vector<paddle::Tensor> W4AFp8Gemm(
|
|
const paddle::Tensor& input,
|
|
const paddle::Tensor& weight,
|
|
const paddle::Tensor&
|
|
tokens, // If tokenpadding=0, this tensor represents the prefix sum of
|
|
// tensors, otherwise it represents the number of tokens in
|
|
// each group
|
|
const paddle::Tensor& weight_scale,
|
|
const paddle::optional<paddle::Tensor>& input_dequant_scale,
|
|
const int64_t token_padding_size,
|
|
const int64_t max_tokens,
|
|
const bool is_bfloat16);
|
|
|
|
template <typename InputType, typename OutputType>
|
|
void DisPatchW4AFp8GemmWrapper(const InputType* input,
|
|
const InputType* weight,
|
|
const int64_t* tokens,
|
|
const float* input_dequant_scale,
|
|
const float* weight_scale,
|
|
OutputType* out,
|
|
const int64_t token_padding_size,
|
|
const int64_t max_tokens,
|
|
const int num_experts,
|
|
const int64_t M,
|
|
const int64_t K,
|
|
const int WeightScaleGroup,
|
|
cudaStream_t stream);
|