acext User Guide (v1.6.1)

Updated at:
Copy as MD
Important

For reference purposes, internal network links in the source code are retained. External users cannot access these links. Contact your PDS account manager if you have any questions.

acext provides high-performance operator implementations for Processor for AI and HPC (PPU) using quantization algorithms. It is distributed as a Python wheel package. The acext source code is available to customers and partners. You can use these operators during PPU adaptation to accelerate your business workloads.

Open-source code repository:

https://code.alibaba-inc.com/ppu_open_source/acext

1. How to Use acext

1.1 Use acext with vLLM or SGLang

Starting with PPU_SDK version 1.6, acext is no longer released with PPU_SDK and is instead distributed as a Python wheel package. For frameworks that depend on acext, such as vLLM and SGLang, after you install the acext wheel package (pip install acext), you can use acext in one of the following two ways:

  • For SGLang ≥ 0.4.10 and vLLM ≥ 0.10.0: The framework loads acext automatically. No extra steps are required.

  • For SGLang < 0.4.10 or vLLM < 0.10.0: Set four environment variables to locate the dynamic libraries.

### Append shared library load path 
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$(python -c "import sysconfig; print(sysconfig.get_path('purelib'))")/lib"
### Config ACEXT LUT path
export ACEXT_GEMM_CONFIG_DIR="$(python -c "import sysconfig; print(sysconfig.get_path('purelib'))")/include/acext/lut/"
### For vLLM versions earlier than 0.10.0
export ACEXT_OP_PATH="$(python -c "import sysconfig; print(sysconfig.get_path('purelib'))")/lib/libacext_op.so"
### For SGLang versions earlier than 0.4.10
export ACEXT_THOP_LIB_PATH="$(python -c "import sysconfig; print(sysconfig.get_path('purelib'))")/lib/th_op/libth_op.so"

Note: For backward compatibility, current PTG images still include acext dynamic libraries and header files in PPU_SDK. Therefore, using acext with vLLM or SGLang works without issues in current PTG images. However, future releases may switch entirely to a wheel-based installation.

1.2 Supported APIs

acext provides quantization algorithm capabilities through header files and compiled libraries. The header file structure supports fpAintB mixed-precision quantization, w8a8 quantization, and MoE GEMM functionality. To use acext, include the interface header acext.h and link against libacext.so.

image

1.2.1 fpAintB GEMM

The fpA_intB_gemm.h header file implements mixed-precision quantization where matrix A is floating-point and matrix B is an integer. Three template parameters allow you to specify the exact types for A and B, and the quantization algorithm to use.

template <typename T, typename WeightType, cutlass::WeightOnlyQuantOp QuantOp>
class CutlassFpAIntBGemmRunner : public virtual CutlassFpAIntBGemmRunnerInterface
{
public:
    CutlassFpAIntBGemmRunner();
    ~CutlassFpAIntBGemmRunner();

    void gemm(const void* A, const void* B, const void* weight_scales, void* C, int m, int n, int k,
        tkc::CutlassGemmConfig gemmConfig, char* workspace_ptr, const size_t workspace_bytes,
        cudaStream_t stream) override;

    void gemm(const void* A, const void* B, const void* weight_scales, const void* weight_zero_points,
        const void* biases, void* C, int m, int n, int k, const int group_size, tkc::CutlassGemmConfig gemmConfig,
        char* workspace_ptr, const size_t workspace_bytes, cudaStream_t stream) override;

    // Returns desired workspace size in bytes.
    size_t getWorkspaceSize(const int m, const int n, const int k) override;

    tkc::CutlassGemmConfig getChosenConfig(const void*          A,
                                           const void* B,
                                           const void*          weight_scales,
                                           const void*          weight_zero_points,
                                           const void*          biases,
                                           void*                C,
                                           int               m,
                                           int               n,
                                           int               k,
                                           const int         group_size,
                                           char*             workspace_ptr,
                                           const size_t      workspace_bytes,
                                           cudaStream_t      stream) override;
};

template <typename ActType, WeightOnlyQuantType QType, cutlass::WeightOnlyQuantOp QuantOp>
std::shared_ptr<CutlassFpAIntBGemmRunnerInterface> createFpAIntBGemmRunner();

1.2.2 w8a8 GEMM

The int8_gemm.h header file implements quantization where both matrices A and B are integers. The template parameter T specifies the output data type.

template <typename T>
class CutlassInt8GemmRunner : public virtual CutlassInt8GemmRunnerInterface
{
public:
    CutlassInt8GemmRunner();
    ~CutlassInt8GemmRunner();

    void gemm(const void* A, const void* B, tk::QuantMode quantOption, const float* alphaCol, const float* alphaRow,
        void* C, int m, int n, int k, tkc::CutlassGemmConfig gemmConfig, char* workspacePtr,
        const size_t workspaceBytes, cudaStream_t stream) override;

    // Returns desired workspace size in bytes.
    size_t getWorkspaceSize(const int m, const int n, const int k) override;

    std::vector<tkc::CutlassGemmConfig> getConfigs() const override;

    tkc::CutlassGemmConfig getChosenConfig(const void* A, const void* B, tk::QuantMode quantOption,
        const float* alphaCol, const float* alphaRow, void* C, int m, int n, int k, char* workspacePtr,
        const size_t workspaceBytes, cudaStream_t stream);
};

1.2.3 MoE GEMM

The moe_kernel.h header file provides the APIs required to call MoE GEMM kernels.

template<typename T,          /*The type used for activations/scales/compute*/
         typename WeightType, /* The type for the MoE weights */
         cutlass::WeightOnlyQuantOp QuantOp,
         typename Enable = void>
class CutlassMoeFCRunner: public CutlassMoeFCRunnerInterface {
public:
    CutlassMoeFCRunner()           = default;
    ~CutlassMoeFCRunner() override = default;
    //for rtp-llm
    void runMoe(const void* input_activations_void, const float* gating_output, const float *gating_output_with_bias,
        const void* fc1_expert_weights_void, const void* fc1_scales_void, const void* fc1_zeros_void, const void* fc1_expert_biases_void,
        ActivationType fc1_activation_type, const void* fc2_expert_weights_void, const void* fc2_scales_void, const void* fc2_zeros_void,
        const void* fc2_expert_biases_void, const int num_rows, const int hidden_size, const int inter_size,
        const int num_experts, const int k, const int group_size, char* workspace_ptr, void* final_output_void, void* fc2_result_void,
        const bool* finished, const int active_rows, void* expert_scales_void,
        int* expanded_source_row_to_expanded_dest_row, int* expert_for_source_row, MOEParallelismConfig parallelism_config,
        MOEExpertScaleNormalizationMode normalization_mode, cudaStream_t stream) override;
    // for vLLM
    void fused_moe(const void* input_activations_void, const float* gating_output, const float* gating_output_with_bias,
                   const void* fc1_expert_weights_void, const void* fc1_scales_void, const void* fc1_zeros_void, const void* fc1_expert_biases_void,
                   void* a1_scale_void, ActivationType fc1_activation_type, const void* fc2_expert_weights_void, const void* fc2_scales_void,
                   const void* fc2_zeros_void, const void* fc2_expert_biases_void, void* a2_scale_void, const int num_tokens, const int hidden_size,
                   const int inter_size, const int num_experts, const int k, const int group_size, char* workspace_ptr, void* final_output_void,
                   void* fc2_result_void, const bool* finished, const int active_rows, const void* expert_scales_void,
                   int* expanded_source_row_to_expanded_dest_row, const int* expert_for_source_row, MOEParallelismConfig parallelism_config,
                   MOEExpertScaleNormalizationMode normalization_mode, cudaStream_t stream) override;

acext also provides MoE-related PyTorch operators:

  • torch.ops.moe_unit_ops.gating_softmax

  • torch.ops.moe_unit_ops.grouped_gemm_bias

  • torch.ops.moe_unit_ops.run_moe_fc

For usage examples, see acext/tests/th_moe.py.

1.2.4 DeepGEMM

PyTorch operators:

  • torch.ops.moe_unit_ops.grouped_gemm_nt_contiguous

  • torch.ops.moe_unit_ops.grouped_gemm_nt_masked

For usage examples, see acext/tests/th_group_gemm.py.

For the C++ API, see the corresponding Python implementation.

1.3 Supported Quantization Algorithms

Quantization algorithms reduce memory usage and improve performance by compressing model weights (W) and activations (A) before matrix multiplication. Different kernel variants support different precision combinations for W and A. The following is a brief overview of each algorithm and its support status in acext.

All code examples assume a matrix multiplication of A (M×K) and W (K×N) that produces an M×N result.

1.3.1 Int8 Weight-only (W8A16)

Int8 weight-only is the simplest quantization method. It quantizes weights column-wise into int8 values, with one scale factor per column. If the original weights are fp16, this method reduces memory usage by half. Because less data is loaded from memory, performance improves in memory-bound scenarios compared to native fp16 computation.

Example code:

// Prepare data: act, weight, scales, and output
......

// Create FpAIntBGemmRunner with A=half, B=int8, and PER_COLUMN_SCALE_ONLY quantization
auto runner = createFpAIntBGemmRunner<half, WeightOnlyQuantType::Int8b, cutlass::WeightOnlyQuantOp::PER_COLUMN_SCALE_ONLY>();

// Preprocess weights for mixed-precision GEMM
preprocess_weights_for_mixed_gemm(preprocessed_quantized_weight, row_major_quantized_weight, {k, n}, QuantType::INT8_WEIGHT_ONLY);

// Allocate workspace
char* ws_ptr = nullptr;
const int ws_bytes = runner->getWorkspaceSize(m, n, k);
cudaMalloc(&ws_ptr, ws_bytes);

// Choose optimal kernel config
gemmConfig = runner->getChosenConfig(p_act, p_weight, p_scales, nullptr, nullptr,
                                    p_out, m, n, k, k, reinterpret_cast<char*>(ws_ptr),
                                    ws_bytes, stream);

// Run quantized kernel; result stored in out
runner->gemm(p_act, p_weight, p_scales, p_out, m, n, k, gemmConfig, ws_ptr, ws_bytes, stream);

1.3.2 Int4 Weight-only (W4A16)

Int4 weight-only uses the same principle as Int8 weight-only but stores weights in a 4-bit format. This further reduces memory usage to one-quarter of the fp16 memory usage and boosts performance, but at the cost of lower accuracy.

Example code:

// Prepare data: act, weight, scales, and output
......

// Create FpAIntBGemmRunner with A=half, B=int4, and PER_COLUMN_SCALE_ONLY quantization
auto runner = createFpAIntBGemmRunner<half, WeightOnlyQuantType::Int4b, cutlass::WeightOnlyQuantOp::PER_COLUMN_SCALE_ONLY>();

// Preprocess weights for mixed-precision GEMM
preprocess_weights_for_mixed_gemm(preprocessed_quantized_weight, row_major_quantized_weight, {k, n}, QuantType::PACKED_INT4_WEIGHT_ONLY);

// Allocate workspace
char* ws_ptr = nullptr;
const int ws_bytes = runner->getWorkspaceSize(m, n, k);
cudaMalloc(&ws_ptr, ws_bytes);

// Choose optimal kernel config
gemmConfig = runner->getChosenConfig(p_act, p_weight, p_scales, nullptr, nullptr,
                                    p_out, m, n, k, k, reinterpret_cast<char*>(ws_ptr),
                                    ws_bytes, stream);

// Run quantized kernel; result stored in out
runner->gemm(p_act, p_weight, p_scales, p_out, m, n, k, gemmConfig, ws_ptr, ws_bytes, stream);

1.3.3 Int4 Groupwise (W4A16)

While Int4 weight-only saves memory and speeds up computation, its low precision causes large quantization errors. Groupwise quantization solves this issue by dividing each column into groups (for example, a group size of 64 or 128) and assigning one scale factor per group instead of per column.

In practice (for example, with AWQ or GPTQ), models are fine-tuned on datasets to produce quantized int4 weights. Asymmetric quantization may also introduce zero-point offsets (zeros and bias).

Example code:

// Prepare data: act, weight, scales, and output
......

// Create FpAIntBGemmRunner with A=half, B=int8, and FINEGRAINED_SCALE_ONLY quantization
auto runner = createFpAIntBGemmRunner<half, WeightOnlyQuantType::Int8b, cutlass::WeightOnlyQuantOp::FINEGRAINED_SCALE_ONLY>();

// Preprocess weights for mixed-precision GEMM
preprocess_weights_for_mixed_gemm(preprocessed_quantized_weight, row_major_quantized_weight, {k, n}, QuantType::PACKED_INT4_WEIGHT_ONLY);

// Allocate workspace
char* ws_ptr = nullptr;
const int ws_bytes = runner->getWorkspaceSize(m, n, k);
cudaMalloc(&ws_ptr, ws_bytes);

// Choose optimal kernel config
gemmConfig = runner->getChosenConfig(p_act, p_weight, p_scales, p_zeros, p_bias,
                                    p_out, m, n, k, groupsize, reinterpret_cast<char*>(ws_ptr),
                                    ws_bytes, stream);

// Run quantized kernel; result stored in out
runner->gemm(p_act, p_weight, p_scales, p_zeros, p_bias, p_out, m, n, k, groupsize, gemmConfig, ws_ptr, ws_bytes, stream);

1.3.4 SmoothQuant (W8A8)

fpAintB uses mixed-precision quantization where weights are integers, but they are dequantized to float before computation and then passed to the TensorCore. In contrast, W8A8 keeps both weights and activations as integers, which enables full integer TensorCore execution and delivers better compute throughput.

SmoothQuant is the quantization algorithm that uses W8A8 kernels. For more information, see https://github.com/mit-han-lab/smoothquant.

W8A8 can be divided into four variants based on whether matrix A uses PerToken quantization (each row shares a set of quantization parameters) and matrix B uses PerChannel quantization (each column shares a set), as opposed to the default PerTensor method where the entire matrix shares one set of parameters. The four variants are PerTensorPerTensor, PerTensorPerChannel, PerTokenPerTensor, and PerTokenPerChannel.

image

acext implements all four W8A8 variants. You can use them as follows:

// Choose one of the four W8A8 variants:
QuantMode quant_mode = QuantMode::fromDescription(false, false, false, false);  // A_PerTensor_W_PerTensor
QuantMode quant_mode = QuantMode::fromDescription(false, false, false, true); // A_PerTensor_W_PerChannel
QuantMode quant_mode = QuantMode::fromDescription(false, false, true, false); // A_PerToken_W_PerTensor
QuantMode quant_mode = QuantMode::fromDescription(false, false, true, true); // A_PerToken_W_PerChannel

// Prepare data: act, weight, scales, and output
......

// Create W8A8 runner
auto runner = std::make_shared<acext::kernels::cutlass_kernels::CutlassInt8GemmRunner<half>>();

// Allocate workspace
int ws_bytes = runner->getWorkspaceSize(m, n, k);
char* ws_ptr = nullptr;
if (ws_bytes)
    cudaMalloc(&ws_ptr, ws_bytes);

// Choose kernel config
const auto gemmConfig = runner->getChosenConfig(p_act, p_weight, quant_mode,
                    reinterpret_cast<const float*>(p_scales_channels),
                    reinterpret_cast<const float*>(p_scales_tokens),
                    p_out, m, n, k, ws_ptr, ws_bytes, stream);

// Execute kernel; result stored in out
runner->gemm(p_act, p_weight, quant_mode,
                    reinterpret_cast<const float*>(p_scales_channels),
                    reinterpret_cast<const float*>(p_scales_tokens),
                    p_out, m, n, k, gemmConfig, ws_ptr, ws_bytes, stream);

1.4 Quantization Kernel Performance

We measured performance across 22 large language models using various N and K dimensions. We ran GEMM operations with different batch sizes (M) and computed the speedup relative to the cuBLAS fp16 baseline.

image

Performance notes:

FpAintB is a weight-only quantization method. It reduces weight memory bandwidth, which improves performance in memory-bound cases. However, it adds a dequantization step. Therefore, for large batch sizes where the workload becomes compute-bound, the quantized version may underperform the non-quantized version.

W8A8 uses int8 Tensor Cores. With large batch sizes, it fully leverages the higher compute throughput of int8 Tensor Cores.

2. acext Quantization Integration (vLLM)

We integrated acext into vLLM to support multiple quantization algorithms on PPU.

vLLM 0.4.2 source code:

https://code.alibaba-inc.com/ppu_open_source/vllm/tree/v0.4.2/

vLLM 0.3.3 source code:

https://code.alibaba-inc.com/ppu_open_source/vllm/tree/v0.3.3/

All performance and accuracy results provided below were obtained using vLLM 0.4.2 with large language models.

2.1 Add Int8 Weight-only Support

2.1.1 AutoWOQ

To apply quantization, you must convert the original fp16 or bf16 model weights to the int8 format.

We provide AutoWOQ for this conversion. Its components are shown below:

image

AutoWOQForCausalLM serves as a unified entry point for all large language models, similar to the Auto classes in Hugging Face. It accepts the model weight path and automatically detects the model type to instantiate the correct WOQForCausalLM subclass. All subclasses inherit from BaseWOQForCausalLM, which implements the core quantization logic, including symmetric quantization using acext.

You can use AutoWOQ as follows:

# Configure quantization: 8-bit or 4-bit
quantize_config = BaseQuantizeConfig(
    bits=8,  # Quantize model to 8-bit
)

# Load unquantized weights (Hugging Face format). By default, loads onto CPU.
model = AutoWOQForCausalLM.from_pretrained(model_path, quantize_config, trust_remote_code=args.trust_remote_code)
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)

# Quantize model. Applies symmetric quantization to linear layers based on model type.
model.quantize()

# Save quantized model and tokenizer to specified location.
quant_path = args.output
model.save_quantized(quant_path)
tokenizer.save_pretrained(quant_path)

2.1.2 Enable WOQ Quantization

After you generate WOQ-quantized weights, you can add weight-only quantization support to vLLM. When you use WOQ weights, you must explicitly set `quantization="weightonly"` when you initialize the LLM object.

# Create an LLM.
llm = LLM(model=model_path, quantization="weightonly")

vLLM will then automatically create quantized tensor parameters for linear layers and invoke mixed-precision kernels at runtime.

As shown in the following figure, a Transformer block in vLLM contains green linear layers that use weight-only quantization.

image

These linear layers are initialized using WeightOnlyLinearMethod. This method loads quantized weights and invokes the acext quantization kernels at runtime. Because acext relies on CUTLASS for kernel acceleration, weights must be pre-reordered. Currently, this reordering happens once at system startup and accounts for the number of GPUs.

class WeightOnlyLinearMethod(LinearMethodBase):
    # Set quantization configuration
    def __init__(self, quant_config: WeightOnlyConfig):
        self.quant_config = quant_config

    # Initialize weights: create int8 weight tensors and load quantized weights from WOQ
    def create_weights(self, input_size_per_partition: int,
                       output_size_per_partition: int, input_size: int,
                       output_size: int,
                       params_dtype: torch.dtype) -> Dict[str, Any]:
        qweight = Parameter(
            torch.empty(
                input_size_per_partition,
                output_size_per_partition,
                device="cuda",
                dtype=torch.int8,
            ),
            requires_grad=False,
        )
        scales = Parameter(
            torch.empty(
                output_size_per_partition,
                device="cuda",
                dtype=params_dtype,
            ),
            requires_grad=False,
        )

        # Instantiate acext's WeightOnlyQuantMatmul class to call mixed-precision kernels later
        try:
            self.weightOnlyMatmul = ops.WeightOnlyQuantMatmul()
        except AttributeError as e:
            raise AttributeError(
                "WeightOnlyQuantMatmul kernels could not be imported. If you built vLLM "
                "from source, make sure BUILD_WEIGHTONLY_KERNELS=1 was set.") from e
        woq_state = WOQState.UNINITIALIZED
        ......

    # Apply weights at runtime using acext's quantization kernel
    def apply_weights(self,
                      weights: Dict[str, torch.Tensor],
                      x: torch.Tensor,
                      bias: Optional[torch.Tensor] = None) -> torch.Tensor:
        # Online weight preprocessing (done once at startup)
        if weights["woq_state"] == WOQState.UNINITIALIZED:
            qweight_cpu = weights["qweight"].cpu()
            qweight_cpu = preprocess_weights_for_mixed_gemm(qweight_cpu, torch.int8, False, False)
            weights["qweight"] = qweight_cpu.cuda()
            weights["woq_state"] = WOQState.READY
        qweight = weights["qweight"]
        scales = weights["scales"]
        return self.weightOnlyMatmul.weightonly_gemm(x, qweight, scales, bias)

2.1.3 Run WOQ Models

To enable weight-only quantization support, compile vLLM with BUILD_WEIGHTONLY_KERNELS=1.

# Compile vLLM
cd vllm
BUILD_WEIGHTONLY_KERNELS=1 python setup.py develop

# Run offline inference with a quantized model
python examples/offline_inference.py --model /path/to/Llama-2-7b-hf-woq/ -q weightonly --trust-remote-code

Output:

image

2.2 Add AWQ/GPTQ Quantization Support (Optimized)

2.2.1 Optimize AWQ/GPTQ Inference

AWQ and GPTQ are natively supported in vLLM and both use int4 quantization.

For more information, see https://docs.vllm.ai/en/latest/quantization/auto_awq.html.

However, the current AWQ/GPTQ implementation in vLLM only reduces the memory footprint and does not improve the inference speed compared to fp16.

image

We improved AWQ/GPTQ inference using the mixed-precision kernels of acext. These kernels deliver measurable speedups. Because acext requires specific weight layouts, original AWQ weights must be preprocessed before you can call acext.

By adding acext weightonly_groupwise_gemm support to vLLM, you can accelerate AWQ inference while retaining the original AWQ weights. The preprocessing runs once before the weights are first used.

image

The same flow also applies to GPTQ quantization.

Similar to WOQ, weight processing is currently performed online, which causes a long startup delay for vLLM. An offline processing method will be supported in a future release.

2.2.2 Fast AWQ/GPTQ Inference

This optimization is still under active development. It is disabled by default in vLLM. To enable it, set the `USE_FAST_AWQ=1` or `USE_FAST_GPTQ=1` environment variable.

You can use the following command line to invoke the FastAWQ flow, which accelerates AWQ quantization with acext.

USE_FAST_AWQ=1 python offline_inference.py --model /ppusw/share/LLM_Weights/Llama-2-7b-hf-awq -q awq --trust-remote-code

FastAWQ produces outputs that are identical to standard AWQ, but with faster performance.

image

2.3 acext Supports fused MoE

We added acext backend support to vLLM 0.8.3 and 0.8.5 to support bf16 and w8a8-int8-channel modes. For a code reference, see the following:

https://code.alibaba-inc.com/ppu_open_source/vllm/tree/v0.8.5_ppu_1v5.1_release

This integration includes three main changes:

2.3.1 Build acext Backend

In `acext_moe_func.cu`, we added the acext backend using the AcextFusedMoe class to call acext APIs. We then registered these as Python APIs using csrc/moe/moe_ops.h and csrc/torch_bindings.cpp.

API

Features

acext_fusedmoe_warpper

Call acext backend to execute fused MoE

get_acext_fusedmoe_status_wrapper

Check if current model config supports acext backend. Returns 0 if supported.

acext_get_version

Return acext library version (int). Current version: 1050100.

2.3.2 Modify fused MoE Layer

In the fused_moe.py file, you can add a call to `acext` within the implementation of `fused_experts_impl`. First, you can use ops.get_acext_fusedmoe_status() to check whether the current model configuration is suitable for the `acext` backend. If it is not suitable, the `triton` backend is called. If the return value is acext_fusedmoe_status = 0, you can use ops.acext_fusedmoe_wrapper() to call the `acext` implementation of `fused_moe`.

2.3.3 Add W8A8Int8MoEMethod (for w8a8-int8-channel)

In `compressed_tensors_moe.py`, we added the CompressedTensorsW8A8Int8MoEMethod class to load w8a8-int8-channel weights and run the corresponding MoE layer.

2.4 Supported Large Language Models

Model

WeightOnly

AWQ

GPTQ

N_K Shape

Llama-2-7b-hf

Y

Y

Y

12288 4096

4096 11008

22016 4096

4096 4096

Llama-2-13b-hf

Y

Y

Y

5120 5120

27648 5120

5120 13824

15360 5120

Llama-2-70b-hf (8GPUS)

Y

Y

Y

8192 3584

8192 1024

1280 8192

7168 8192

Meta-Llama-3-8B

Y

Y

Y

6144 4096

4096 14336

28672 4096

4096 4096

Meta-Llama-3-70B (8GPUS)

N

Y

N

8192 3584

8192 1024

1280 8192

7168 8192

Baichuan-7b

Y

Y

Y

12288 4096

4096 11008

22016 4096

4096 4096

Baichuan-13b

Y

Y

Y

5120 5120

5120 13696

27392 5120

15360 5120

Baichuan2-7b

Y

Y

Y

12288 4096

4096 11008

22016 4096

4096 4096

Baichuan2-13b

Y

Y

Y

5120 5120

5120 13696

27392 5120

15360 5120

Chatglm2-6b

Y

N

N

4608 4096

4096 13696

27392 4096

4096 4096

Chatglm3-6b

Y

N

N

4608 4096

4096 13696

27392 4096

4096 4096

Qwen-7b

Y

Y

Y

12288 4096

4096 11008

22016 4096

4096 4096

Qwen-14b

Y

Y

Y

5120 5120

5120 13696

27392 5120

15360 5120

Qwen-72b (8GPUS)

Y

Y

Y

6144 8192

8192 1024

8192 3072

3072 8192

Falcon-7b

Y

N

N

4544 4544

4672 4544

18176 4544

4544 18176

Falcon-40b (8GPUS)

Y

N

Y

8192 4096

8192 1024

1152 8192

4096 8192

Gemma-7b

Y

N

N

49152 3072

12288 3072

3072 24576

3072 4096

Mistral-7b

Y

Y

Y

6144 4096

4096 14336

28672 4096

4096 4096

Mpt-7B

Y

N

Y

12288 4096

4096 16384

4096 4096

16384 4096

Mixtral-8x7b (8GPUS)

Y

Y

N

4096 512

8 4096

768 4096

Mixtral-8x22b (8GPUS)

Y

Y

N

8 6144

1024 6144

6144 768

2.4.1 Known Issues

2.4.1.1 Weight Conversion Issues

WOQ model conversion issues:

Model

Comments

Chatglm2-6b

When AutoWOQ quantizes ChatGLM weights, the generated tokenizer_config.json must be replaced with the original file to avoid compatibility issues—a known community issue. Manually copy it after conversion.

https://github.com/THUDM/ChatGLM3/issues/152

https://github.com/bentoml/OpenLLM/issues/736

Chatglm3-6b

AWQ model conversion issues:

Model

Comments

Chatglm2-6b

TypeError: chatglm isn't supported yet.

Chatglm3-6b

TypeError: chatglm isn't supported yet.

Falcon-7b

TypeError: FalconDecoderLayer.forward() missing 1 required positional argument: 'alibi'

Falcon-40b

TypeError: FalconDecoderLayer.forward() missing 1 required positional argument: 'alibi'

Mpt-7B

AttributeError: 'NoneType' object has no attribute 'bool'

GPTQ model conversion issues:

Model

Comments

Chatglm2-6b

TypeError: chatglm isn't supported yet.

Chatglm3-6b

TypeError: chatglm isn't supported yet.

Falcon-7b

AssertionError

assert infeatures % self.group_size == 0

Meta-Llama-3-70B

torch._C._LinAlgError: linalg.cholesky: The factorization could not be completed because the input is not positive-definite (the leading minor of order 27024 is not positive-definite).

Mixtral-8x7b

ZeroDivisionError: float division by zero

Mixtral-8x22b

ZeroDivisionError: float division by zero

2.4.1.2 Runtime Issues

Results for Meta-Llama-3-70B-woq show anomalies.

image

Gemma-7b-awq fails at runtime.

image.png

Some models experience a significant loss in accuracy on MMLU with AWQ/GPTQ quantization. For example, LLaMA2-7B:

image

Validation on A100 GPUs confirms that the poor performance of these models is caused by the AWQ/GPTQ quantization algorithms, a finding that is also reflected in the MMLU scores measured on A100 GPUs. For example, the MMLU scores obtained by running Llama-2-7b with AWQ and GPTQ on an A100 are consistent with the PPU scores.

image

image

2.5 Model Quantization Performance

Various methods and metrics are used to measure the inference performance of Large Language Models (LLMs).

We tested generation-phase throughput under fixed conditions: batch sizes (1, 2, 4, and 8), input lengths (32, 512, 1024, and 2048), and an output length of 128. This test reflects real-world benefits, such as reduced latency in online inference.

The following table shows the throughput speedups for each quantization method compared to the fp16 baseline.

image

2.5.1 Detailed Performance Data

Detailed model performance data

Model

Batch Size

Input Len

Output Len

Fp16

WOQ

AWQ

Fast_AWQ

GPTQ

Fast_GPTQ

Llama-2-7b-hf

1

32

128

112

162

114

170

125

169

1

512

128

105

147

107

153

117

154

1

1024

128

104

146

106

151

117

151

1

2048

128

104

144

104

148

115

149

2

32

128

221

284

223

330

205

332

2

512

128

206

259

207

297

192

298

2

1024

128

203

256

204

290

189

291

2

2048

128

197

245

196

274

185

276

4

32

128

432

581

435

643

313

648

4

512

128

399

522

398

568

295

571

4

1024

128

386

501

384

539

287

540

4

2048

128

306

324

300

283

238

284

8

32

128

834

1105

836

1216

452

1221

8

512

128

751

965

743

1031

425

1034

8

1024

128

601

636

587

555

370

555

8

2048

128

426

376

413

288

293

288

Llama-2-13b-hf

1

32

128

66

97

75

125

81

125

1

512

128

63

91

71

114

76

114

1

1024

128

62

90

70

112

75

112

1

2048

128

62

88

69

110

74

110

2

32

128

128

171

148

244

127

245

2

512

128

122

160

139

221

120

221

2

1024

128

120

157

137

216

119

216

2

2048

128

116

151

131

204

115

204

4

32

128

253

320

290

476

197

475

4

512

128

238

297

269

424

188

424

4

1024

128

230

285

257

399

182

400

4

2048

128

176

182

189

168

146

168

8

32

128

492

647

561

909

285

908

8

512

128

445

569

494

758

268

759

8

1024

128

348

370

372

334

228

334

8

2048

128

243

222

253

160

178

160

Llama-2-70b-hf

1

32

128

53

64

43

63

48

63

1

512

128

50

60

41

60

45

60

1

1024

128

50

60

41

60

45

60

1

2048

128

49

59

41

60

45

60

2

32

128

100

118

84

125

80

125

2

512

128

94

110

80

118

76

119

2

1024

128

94

110

79

118

76

120

2

2048

128

94

109

79

118

76

119

4

32

128

197

231

165

244

125

246

4

512

128

184

213

155

230

120

230

4

1024

128

184

213

155

228

119

231

4

2048

128

156

141

134

148

107

148

8

32

128

383

455

324

482

187

481

8

512

128

359

421

307

453

181

456

8

1024

128

308

280

266

294

167

295

8

2048

128

236

167

210

172

143

172

Meta-Llama-3-8B

1

32

128

100

147

95

170

107

169

1

512

128

94

136

90

155

101

155

1

1024

128

93

135

89

154

101

154

1

2048

128

93

134

89

152

100

152

2

32

128

201

234

186

332

177

332

2

512

128

188

219

176

302

169

302

2

1024

128

188

217

175

299

168

299

2

2048

128

186

215

173

293

166

292

4

32

128

394

461

364

644

277

643

4

512

128

367

429

341

564

265

554

4

1024

128

364

423

338

570

263

569

4

2048

128

349

402

325

533

255

533

8

32

128

757

881

682

1208

396

1206

8

512

128

691

798

654

1089

387

1089

8

1024

128

679

780

629

1022

377

1021

8

2048

128

484

276

457

379

309

379

Meta-Llama-3-70B

1

32

128

47

63

43

64

0

0

1

512

128

44

59

41

60

0

0

1

1024

128

44

59

41

60

0

0

1

2048

128

44

59

41

60

0

0

2

32

128

99

117

83

126

0

0

2

512

128

92

109

79

118

0

0

2

1024

128

92

109

79

118

0

0

2

2048

128

91

109

78

118

0

0

4

32

128

194

228

162

243

0

0

4

512

128

180

211

153

227

0

0

4

1024

128

179

211

153

227

0

0

4

2048

128

178

210

152

224

0

0

8

32

128

376

447

319

484

0

0

8

512

128

348

413

302

442

0

0

8

1024

128

347

409

300

441

0

0

8

2048

128

268

210

236

201

0

0

Baichuan-7b

1

32

128

109

156

111

162

121

162

1

512

128

102

143

104

148

113

148

1

1024

128

102

141

103

146

112

146

1

2048

128

101

139

101

143

111

143

2

32

128

214

274

217

316

199

316

2

512

128

200

251

201

286

186

286

2

1024

128

198

247

198

279

184

279

2

2048

128

192

237

191

265

178

265

4

32

128

416

551

420

611

305

610

4

512

128

385

498

385

542

287

542

4

1024

128

373

479

371

515

280

516

4

2048

128

297

314

293

277

233

277

8

32

128

790

1027

790

1127

438

1126

8

512

128

715

906

706

967

412

966

8

1024

128

577

609

564

535

361

536

8

2048

128

413

365

401

282

287

282

Baichuan-13b

1

32

128

58

97

76

113

81

113

1

512

128

55

90

71

104

76

104

1

1024

128

55

89

71

102

75

102

1

2048

128

54

88

70

100

74

100

2

32

128

127

170

148

221

127

221

2

512

128

120

158

139

201

120

201

2

1024

128

119

156

136

197

118

197

2

2048

128

116

149

130

186

115

187

4

32

128

250

315

287

428

196

428

4

512

128

234

292

266

384

185

384

4

1024

128

228

280

255

363

181

364

4

2048

128

168

191

180

167

140

168

8

32

128

481

626

549

803

280

803

8

512

128

434

551

484

680

261

680

8

1024

128

336

393

359

335

222

335

8

2048

128

229

243

234

165

168

165

Baichuan2-7b

1

32

128

104

148

107

154

116

153

1

512

128

97

136

100

141

109

140

1

1024

128

96

135

99

139

108

139

1

2048

128

95

133

98

137

107

136

2

32

128

204

261

208

299

191

298

2

512

128

190

240

194

272

180

271

2

1024

128

188

237

191

267

178

266

2

2048

128

183

227

184

253

172

253

4

32

128

395

523

403

576

295

574

4

512

128

364

475

370

515

278

514

4

1024

128

355

457

358

493

271

492

4

2048

128

285

305

284

269

227

269

8

32

128

748

969

757

1063

428

1057

8

512

128

679

860

680

919

402

916

8

1024

128

552

588

547

520

353

520

8

2048

128

401

358

392

277

281

277

Baichuan2-13b

1

32

128

57

94

73

108

78

108

1

512

128

54

87

69

100

74

100

1

1024

128

54

87

69

99

73

99

1

2048

128

53

85

68

96

72

97

2

32

128

124

164

143

212

123

211

2

512

128

118

153

135

193

117

193

2

1024

128

116

151

132

190

116

189

2

2048

128

113

144

127

179

112

179

4

32

128

243

305

278

408

189

409

4

512

128

227

283

257

365

181

367

4

1024

128

221

272

248

349

176

350

4

2048

128

164

187

177

164

137

164

8

32

128

467

605

533

768

274

766

8

512

128

419

529

467

647

257

650

8

1024

128

328

384

352

329

219

329

8

2048

128

224

240

231

163

164

163

Chatglm2-6b

1

32

128

124

177

0

0

0

0

1

512

128

118

163

0

0

0

0

1

1024

128

117

163

0

0

0

0

1

2048

128

117

162

0

0

0

0

2

32

128

246

274

0

0

0

0

2

512

128

232

257

0

0

0

0

2

1024

128

231

255

0

0

0

0

2

2048

128

229

253

0

0

0

0

4

32

128

483

540

0

0

0

0

4

512

128

454

504

0

0

0

0

4

1024

128

449

498

0

0

0

0

4

2048

128

432

477

0

0

0

0

8

32

128

923

1026

0

0

0

0

8

512

128

868

956

0

0

0

0

8

1024

128

836

918

0

0

0

0

8

2048

128

765

833

0

0

0

0

Chatglm3-6b

1

32

128

124

176

0

0

0

0

1

512

128

118

163

0

0

0

0

1

1024

128

117

162

0

0

0

0

1

2048

128

117

161

0

0

0

0

2

32

128

245

274

0

0

0

0

2

512

128

232

257

0

0

0

0

2

1024

128

231

255

0

0

0

0

2

2048

128

228

252

0

0

0

0

4

32

128

482

539

0

0

0

0

4

512

128

453

503

0

0

0

0

4

1024

128

448

497

0

0

0

0

4

2048

128

432

475

0

0

0

0

8

32

128

923

1028

0

0

0

0

8

512

128

866

957

0

0

0

0

8

1024

128

835

920

0

0

0

0

8

2048

128

765

834

0

0

0

0

Qwen-7b

1

32

128

105

145

106

151

115

150

1

512

128

99

133

99

138

108

138

1

1024

128

98

132

98

137

107

137

2

32

128

206

254

205

292

190

291

2

512

128

193

234

192

266

179

266

2

1024

128

191

231

189

260

176

260

4

32

128

403

515

399

568

293

566

4

512

128

374

468

368

507

276

507

4

1024

128

339

410

329

386

255

385

8

32

128

778

977

766

1077

432

1075

8

512

128

662

791

639

745

389

745

8

1024

128

547

618

519

498

343

498

Qwen-14b

1

32

128

61

90

71

104

76

104

1

512

128

59

84

68

96

72

96

1

1024

128

58

84

67

95

71

95

2

32

128

123

157

138

202

122

201

2

512

128

117

147

130

185

116

184

2

1024

128

116

146

128

181

114

181

4

32

128

242

295

271

391

190

391

4

512

128

228

275

252

354

180

354

4

1024

128

205

242

219

224

164

223

8

32

128

472

593

524

751

276

748

8

512

128

397

481

422

434

247

433

8

1024

128

318

371

327

246

212

246

Qwen-72b

1

32

128

51

61

42

62

47

61

1

512

128

47

56

40

58

44

59

1

1024

128

47

56

40

58

44

58

1

2048

128

47

56

39

57

44

58

2

32

128

96

112

82

122

78

122

2

512

128

90

104

77

113

74

114

2

1024

128

90

103

76

112

73

112

2

2048

128

89

101

75

109

73

110

4

32

128

190

218

160

237

123

236

4

512

128

177

200

149

216

117

216

4

1024

128

176

198

147

212

116

213

4

2048

128

175

194

146

208

115

210

8

32

128

372

424

314

465

186

467

8

512

128

345

387

290

419

178

421

8

1024

128

341

377

288

411

176

414

8

2048

128

262

169

227

185

152

185

Falcon-7b

1

32

128

96

157

0

0

0

0

1

512

128

92

150

0

0

0

0

1

1024

128

92

150

0

0

0

0

2

32

128

206

254

0

0

0

0

2

512

128

197

244

0

0

0

0

2

1024

128

197

242

0

0

0

0

4

32

128

405

495

0

0

0

0

4

512

128

386

474

0

0

0

0

4

1024

128

352

422

0

0

0

0

8

32

128

793

965

0

0

0

0

8

512

128

689

830

0

0

0

0

8

1024

128

568

669

0

0

0

0

Falcon-40b

1

32

128

71

85

0

0

61

81

1

512

128

69

84

0

0

60

79

1

1024

128

68

83

0

0

60

78

2

32

128

142

155

0

0

107

160

2

512

128

134

149

0

0

104

156

2

1024

128

134

147

0

0

103

156

4

32

128

278

302

0

0

170

315

4

512

128

262

289

0

0

167

307

4

1024

128

244

265

0

0

159

263

8

32

128

540

588

0

0

263

620

8

512

128

476

521

0

0

248

524

8

1024

128

418

446

0

0

230

410

Gemma-7b

1

32

128

76

102

74

0

72

0

1

512

128

56

62

51

0

49

0

1

1024

128

56

62

51

0

49

0

1

2048

128

55

61

50

0

49

0

2

32

128

148

193

145

0

122

0

2

512

128

109

120

100

0

88

0

2

1024

128

107

118

99

0

87

0

2

2048

128

97

103

87

0

78

0

4

32

128

288

368

280

0

201

0

4

512

128

208

230

192

0

151

0

4

1024

128

190

204

170

0

137

0

4

2048

128

174

182

154

0

127

0

8

32

128

537

663

514

0

314

0

8

512

128

371

389

329

0

234

0

8

1024

128

338

350

298

0

218

0

8

2048

128

265

214

234

0

182

0

Mistral-7b

1

32

128

105

161

100

188

114

187

1

512

128

99

147

95

169

107

170

1

1024

128

98

146

94

168

106

168

1

2048

128

98

145

94

166

106

166

2

32

128

213

251

196

366

186

364

2

512

128

199

233

185

330

177

329

2

1024

128

198

231

184

325

176

325

2

2048

128

195

228

182

318

174

318

4

32

128

419

493

383

710

288

708

4

512

128

390

456

359

635

275

635

4

1024

128

385

450

353

619

273

620

4

2048

128

369

426

339

575

264

575

8

32

128

808

944

736

1339

412

1338

8

512

128

732

845

689

1188

398

1190

8

1024

128

719

828

660

1107

388

1110

8

2048

128

644

737

600

952

366

953

Mpt-7B

1

32

128

107

151

0

0

99

176

1

512

128

100

139

0

0

93

159

1

1024

128

99

137

0

0

92

157

2

32

128

213

264

0

0

168

346

2

512

128

197

242

0

0

159

310

2

1024

128

195

239

0

0

157

302

4

32

128

418

522

0

0

260

674

4

512

128

383

473

0

0

246

589

4

1024

128

341

362

0

0

226

422

8

32

128

806

1000

0

0

391

1282

8

512

128

669

711

0

0

353

829

8

1024

128

529

473

0

0

307

520

Mixtral-8x7b

1

32

128

102

90

70

88

0

0

1

512

128

100

89

68

88

0

0

1

1024

128

99

89

68

87

0

0

1

2048

128

100

89

68

87

0

0

2

32

128

189

165

136

174

0

0

2

512

128

179

159

131

171

0

0

2

1024

128

178

158

132

170

0

0

2

2048

128

176

158

131

172

0

0

4

32

128

322

324

264

340

0

0

4

512

128

307

308

257

330

0

0

4

1024

128

312

309

255

336

0

0

4

2048

128

307

306

254

334

0

0

8

32

128

557

624

519

676

0

0

8

512

128

542

602

495

666

0

0

8

1024

128

546

598

496

654

0

0

8

2048

128

523

587

490

653

0

0

Mixtral-8x22b

1

32

128

67

49

36

49

0

0

1

512

128

63

47

35

47

0

0

1

1024

128

63

47

35

47

0

0

1

2048

128

63

46

35

46

0

0

2

32

128

100

87

70

94

0

0

2

512

128

96

83

68

90

0

0

2

1024

128

96

84

68

90

0

0

2

2048

128

97

83

67

90

0

0

4

32

128

153

171

138

185

0

0

4

512

128

153

164

134

177

0

0

4

1024

128

153

163

133

177

0

0

4

2048

128

152

163

132

176

0

0

8

32

128

245

339

271

368

0

0

8

512

128

245

325

262

351

0

0

8

1024

128

241

323

261

351

0

0

8

2048

128

247

321

259

347

0

0

2.6 Model Quantization Accuracy (MMLU)

We use the lm-evaluation-harness framework to run large language model inference and test the scores on the MMLU dataset to evaluate the accuracy of our quantized models.

https://github.com/EleutherAI/lm-evaluation-harness

2.6.1 Running steps

# If your setuptools version is too low, upgrade it first.
# pip3 install --upgrade pip setuptools
# For the following reason, we need to restrict setuptools to version 69.5.1:
# https://github.com/vllm-project/vllm/issues/4961

git clone https://github.com/EleutherAI/lm-evaluation-harness
# If you encounter issues running the MMLU test, it might be version-related. Try switching to this commit we have tested:
# git reset --hard e5e5ee0cb629c9c88165292d1b4bf34623392d33
cd lm-evaluation-harness
pip install -e .

# Use the Hugging Face proxy.
export HF_ENDPOINT=https://hf-mirror.com

# Use lm_eval for MMLU inference.
lm_eval --model vllm --model_args pretrained=/ppusw/datasets/huggingface/Llama-2-7b-hf --tasks mmlu --batch_size auto --num_fewshot 5

# If you still have issues downloading the dataset after using the proxy, it is because the following file hardcodes the Hugging Face download URL:
# /root/.cache/huggingface/modules/datasets_modules/datasets/hails--mmlu_no_train/b7d5f7f21003c21be079f11495ee011332b980bd1cd7e70cc740e8c079e5bda2/mmlu_no_train.py
# Modify the URL in this file to point to hf-mirror.

2.6.2 Inference results

You can set `num-fewshot` to control the few-shot parameter. A higher value increases the runtime but may yield a higher score.

Without `num_fewshot`, the test runs quickly (in minutes) and scores 41.3.

image

With `num_fewshot=5`, the test runs slowly (in hours) but scores higher at 45.9.

image

This matches the result shown on the website.

image

2.6.3 MMLU accuracy for different quantization methods

We use the MMLU score from fp16 inference as the baseline. By applying different quantization methods during inference, we can obtain post-quantization MMLU scores and compare them to the baseline to calculate the MMLU loss.

The following table shows the MMLU scores (few-shot 0) and MMLU loss relative to fp16 for different models and quantization methods.

Gray cells indicate methods that are not supported in the current version (PPU Release 1.3). Red cells indicate methods with inference bugs.

MMLU Quantization Scores

Model

Quantization methods

MMLU baseline (FP16)

MMLU post-quantization

MMLU loss

Llama-2-7b-hf

WOQ

41.3

41.13

-0.43%

AWQ

39.05

-5.45%

Fast_AWQ

39.04

-5.48%

GPTQ

33.21

-19.60%

Fast_GPTQ

33.21

-19.60%

Llama-2-13b-hf

WOQ

50.51

50.42

-0.18%

AWQ

50.1

-0.82%

Fast_AWQ

50.11

-0.80%

GPTQ

47.73

-5.51%

Fast_GPTQ

47.71

-5.55%

Llama-2-70b-hf

(8 GPUs)

WOQ

65.18

65.03

-0.24%

AWQ

64.8

-0.59%

Fast_AWQ

64.87

-0.48%

GPTQ

63.77

-2.16%

Fast_GPTQ

63.79

-2.14%

Meta-Llama-3-8B

WOQ

61.95

62.09

0.22%

AWQ

60.2

-2.83%

Fast_AWQ

60.27

-2.71%

GPTQ

59.13

-4.55%

Fast_GPTQ

59.09

-4.61%

Meta-Llama-3-70B

(8 GPUs)

WOQ

75.3

25.17

-66.58%

AWQ

75.05

-0.34%

Fast_AWQ

75.03

-0.36%

GPTQ

-

-

Fast_GPTQ

-

-

Baichuan-7b

WOQ

38.25

38.36

0.30%

AWQ

38.95

1.84%

Fast_AWQ

39.03

2.03%

GPTQ

38.29

0.11%

Fast_GPTQ

38.31

0.15%

Baichuan-13b

WOQ

52.07

52.68

1.18%

AWQ

52.17

0.21%

Fast_AWQ

52.2

0.26%

GPTQ

51.8

-0.51%

Fast_GPTQ

51.79

-0.52%

Baichuan2-7b

WOQ

50.73

50.79

0.11%

AWQ

49.29

-2.85%

Fast_AWQ

49.26

-2.91%

GPTQ

46.51

-8.32%

Fast_GPTQ

46.55

-8.24%

Baichuan2-13b

WOQ

55.95

55.8

-0.28%

AWQ

54.87

-1.93%

Fast_AWQ

54.84

-2.00%

GPTQ

54.85

-1.97%

Fast_GPTQ

54.84

-2.00%

Chatglm2-6b

WOQ

24.29

24.41

0.50%

AWQ

-

-

Fast_AWQ

-

-

GPTQ

-

-

Fast_GPTQ

-

-

Chatglm3-6b

WOQ

56.78

56.72

-0.11%

AWQ

-

-

Fast_AWQ

-

-

GPTQ

-

-

Fast_GPTQ

-

-

Qwen-7b

WOQ

54.22

54.32

0.17%

AWQ

53.63

-1.09%

Fast_AWQ

53.67

-1.02%

GPTQ

52.71

-2.78%

Fast_GPTQ

52.69

-2.82%

Qwen-14b

WOQ

64.02

64.18

0.24%

AWQ

63.54

-0.76%

Fast_AWQ

63.5

-0.81%

GPTQ

62.36

-2.59%

Fast_GPTQ

62.38

-2.57%

Qwen-72b

(8 GPUs)

WOQ

74.65

74.58

-0.10%

AWQ

73.71

-1.27%

Fast_AWQ

73.69

-1.30%

GPTQ

72.98

-2.24%

Fast_GPTQ

73.01

-2.20%

Falcon-7b

WOQ

25.56

25.87

1.20%

AWQ

-

-

Fast_AWQ

-

-

GPTQ

-

-

Fast_GPTQ

-

-

Falcon-40b

(8 GPUs)

WOQ

53.44

53.15

-0.55%

AWQ

-

-

Fast_AWQ

-

-

GPTQ

52.28

-2.17%

Fast_GPTQ

52.27

-2.19%

Gemma-7b

WOQ

61.34

61.78

0.72%

AWQ

60.11

-2.00%

Fast_AWQ

-

-

GPTQ

52.26

-14.79%

Fast_GPTQ

-

-

Mistral-7b

WOQ

58.65

58.66

0.02%

AWQ

57.5

-1.96%

Fast_AWQ

57.46

-2.02%

GPTQ

57.11

-2.61%

Fast_GPTQ

57.12

-2.60%

Mpt-7B

WOQ

28.76

29.51

2.60%

AWQ

-

-

Fast_AWQ

-

-

GPTQ

28.34

-1.49%

Fast_GPTQ

28.31

-1.58%

Mixtral-8x7b

(8 GPUs)

WOQ

67.01

67.28

0.40%

AWQ

65.47

-2.31%

Fast_AWQ

65.51

-2.24%

GPTQ

-

-

Fast_GPTQ

-

-

Mixtral-8x22b

(8 GPUs)

WOQ

74.07

74.06

-0.02%

AWQ

72.31

-2.37%

Fast_AWQ

72.33

-2.35%

GPTQ

-

-

Fast_GPTQ

-

-

3. Compile and Run from Source

3.1 Compilation

acext depends on the PPU version of CUTLASS. First, download acext, and then download the PPU version of CUTLASS.

# Fetch code from ppu_open_source
git clone -b sail_v1.6.1 https://code.alibaba-inc.com/ppu_open_source/acext
cd acext
git clone -b sail_v1.6.1 https://code.alibaba-inc.com/ppu_open_source/cutlass

You can compile and install acext in one of two ways.

  1. Compile and install acext separately.

    # Compile & install: in acext
    rm -rf build && mkdir build && cd build
    cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_PYT=ON
    cmake --build . -- -j${nproc}
    cmake --build . --target install -j${nproc}
  2. Compile and install the acext wheel package.

    python -m build --wheel --no-isolation -v
    pip install dist/*.whl

If you choose the wheel package installation, after you install the wheel, you must run the following commands to copy the acext dynamic library and header files to the PPU_SDK directory. This ensures that vLLM/SGLang cmake can find them:

cp $(python -c "import sysconfig; print(sysconfig.get_path('purelib'))")/lib/libacext.so $PPU_SDK/lib/
cp -r $(python -c "import sysconfig; print(sysconfig.get_path('purelib'))")/include/acext $PPU_SDK/include/

3.2 Running

3.2.1 Run unit tests

cd build

# Unit test for a16w8/a16w4 quant gemm
python ../tests/test_woq_gemm.py

# Unit test for a8w8 quant gemm
python ../tests/th_int8_gemm.py

# Unit test for MoE
python ../tests/th_moe.py

3.2.2 Run performance tests

cd build
# Run FpAintB benchmark. Default M, N, K is (1, 5120, 5120). You can specify M, N, K as command-line arguments.
./benchmark/benchmark_fpAintB

# Run w8a8 benchmark. Default M, N, K is (1, 5120, 5120). You can specify M, N, K as command-line arguments.
./benchmark/benchmark_w8a8

# Iterate through all M, N, K values to run the benchmark and generate a unified CSV report.
cd benchmark
python run_benchmark.py