Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ if(VLLM_GPU_LANG STREQUAL "CUDA" OR VLLM_GPU_LANG STREQUAL "HIP")
# Keep building Marlin for 9.0 as there are some group sizes and shapes that
# are not supported by Machete yet.

# marlin arches for fp16 output
# marlin arches for fp16/bf16 output
# Family-conditional 12.0f (one cubin for SM12x family) requires CUDA >= 13.0;
# fall back to architecture-specific 12.0a;12.1a on CUDA < 13.0 (e.g. 12.8).
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER_EQUAL 13.0)
Expand All @@ -661,12 +661,6 @@ if(VLLM_GPU_LANG STREQUAL "CUDA" OR VLLM_GPU_LANG STREQUAL "HIP")
endif()
# marlin has limited support for turing
cuda_archs_loose_intersection(MARLIN_SM75_ARCHS "7.5" "${CUDA_ARCHS}")
# marlin arches for bf16 output (we need 9.0 for bf16 atomicAdd PTX)
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER_EQUAL 13.0)
cuda_archs_loose_intersection(MARLIN_BF16_ARCHS "8.0+PTX;9.0+PTX;12.0f" "${CUDA_ARCHS}")
else()
cuda_archs_loose_intersection(MARLIN_BF16_ARCHS "8.0+PTX;9.0+PTX;12.0a;12.1a" "${CUDA_ARCHS}")
endif()
# marlin arches for fp8 input
# - sm80 doesn't support fp8 computation
# - sm90 and sm100 don't support QMMA.16832.F32.E4M3.E4M3 SAAS instruction
Expand Down Expand Up @@ -721,7 +715,7 @@ if(VLLM_GPU_LANG STREQUAL "CUDA" OR VLLM_GPU_LANG STREQUAL "HIP")
endif()

if (MARLIN_ARCHS)
file(GLOB MARLIN_TEMPLATE_KERNEL_SRC "csrc/quantization/marlin/sm80_kernel_*_float16.cu")
file(GLOB MARLIN_TEMPLATE_KERNEL_SRC "csrc/quantization/marlin/sm80_kernel_*.cu")
set_gencode_flags_for_srcs(
SRCS "${MARLIN_TEMPLATE_KERNEL_SRC}"
CUDA_ARCHS "${MARLIN_ARCHS}")
Expand All @@ -730,16 +724,6 @@ if(VLLM_GPU_LANG STREQUAL "CUDA" OR VLLM_GPU_LANG STREQUAL "HIP")
PROPERTIES COMPILE_FLAGS "-static-global-template-stub=false")
endif()
list(APPEND VLLM_STABLE_EXT_SRC ${MARLIN_TEMPLATE_KERNEL_SRC})

file(GLOB MARLIN_TEMPLATE_BF16_KERNEL_SRC "csrc/quantization/marlin/sm80_kernel_*_bfloat16.cu")
set_gencode_flags_for_srcs(
SRCS "${MARLIN_TEMPLATE_BF16_KERNEL_SRC}"
CUDA_ARCHS "${MARLIN_BF16_ARCHS}")
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER_EQUAL 12.8)
set_source_files_properties(${MARLIN_TEMPLATE_BF16_KERNEL_SRC}
PROPERTIES COMPILE_FLAGS "-static-global-template-stub=false")
endif()
list(APPEND VLLM_STABLE_EXT_SRC ${MARLIN_TEMPLATE_BF16_KERNEL_SRC})
endif()

if (MARLIN_SM75_ARCHS)
Expand Down
7 changes: 2 additions & 5 deletions recipes/models/MiniMaxAI/MiniMax-M3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@ variants:
- "--max-model-len"
- "131072"
h200:
# Humming runs the dense MXFP8 linear layers; the atomic-add env var
# enables Marlin's atomic reduction on the MXFP8 MoE path. This image
# also supports the FP8 MSA indexer cache on H200.
# Humming runs the dense MXFP8 linear layers. This image also supports
# the FP8 MSA indexer cache on H200.
docker_image: "vllm/vllm-openai:nightly-1a001d584244bd21829a5e5bd4a376ea141c0ce3"
extra_args:
- "--attention-backend"
Expand All @@ -199,8 +198,6 @@ variants:
- "--gpu-memory-utilization"
- "0.95"
- "--enable-prefix-caching"
extra_env:
VLLM_MARLIN_USE_ATOMIC_ADD: "1"
mi300x:
docker_image: "vllm/vllm-openai-rocm:nightly"
extra_args:
Expand Down
11 changes: 11 additions & 0 deletions tests/config/test_config_generation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import logging

import pytest

from vllm.engine.arg_utils import EngineArgs
Expand Down Expand Up @@ -111,6 +113,15 @@ def test_unrecognized_env(monkeypatch):
engine_args.create_engine_config()


def test_deprecated_marlin_atomic_add_env_warns(monkeypatch, caplog_vllm):
monkeypatch.setenv("VLLM_MARLIN_USE_ATOMIC_ADD", "1")
with caplog_vllm.at_level(logging.WARNING, logger="vllm"):
EngineArgs().create_engine_config()
assert any(
"VLLM_MARLIN_USE_ATOMIC_ADD is deprecated" in m for m in caplog_vllm.messages
)


Comment on lines +116 to +124

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_deprecated_marlin_atomic_add_env_warns(monkeypatch, caplog_vllm):
monkeypatch.setenv("VLLM_MARLIN_USE_ATOMIC_ADD", "1")
with caplog_vllm.at_level(logging.WARNING, logger="vllm"):
EngineArgs().create_engine_config()
assert any(
"VLLM_MARLIN_USE_ATOMIC_ADD is deprecated" in m for m in caplog_vllm.messages
)

I don't think we need a specific unit test for this update

def test_get_diff_sampling_param_includes_penalties():
"""``--override-generation-config`` must apply presence_penalty and
frequency_penalty as server-side defaults, like the other sampling
Expand Down
5 changes: 5 additions & 0 deletions vllm/engine/arg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,11 @@ def create_engine_config(
device_config = DeviceConfig(device=cast(Device, current_platform.device_type))

current_platform.validate_environ(self.fail_on_environ_validation)
if envs.is_set("VLLM_MARLIN_USE_ATOMIC_ADD"):
logger.warning(
"VLLM_MARLIN_USE_ATOMIC_ADD is deprecated, has no effect, and "
"will be removed in v0.35.0."
)

# Check if the model is a speculator and override model/tokenizer/config
# BEFORE creating ModelConfig, so the config is created with the target model
Expand Down
2 changes: 1 addition & 1 deletion vllm/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ def _resolve_rust_cli_path() -> str | None:
"VLLM_MODEL_REDIRECT_PATH": lambda: os.environ.get(
"VLLM_MODEL_REDIRECT_PATH", None
),
# Whether to use atomicAdd reduce in gptq/awq marlin kernel.
# Deprecated and has no effect; will be removed in v0.35.0.
"VLLM_MARLIN_USE_ATOMIC_ADD": lambda: (
os.environ.get("VLLM_MARLIN_USE_ATOMIC_ADD", "0") == "1"
),
Expand Down
58 changes: 1 addition & 57 deletions vllm/model_executor/layers/quantization/utils/marlin_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,18 +635,6 @@ def moe_awq_to_marlin_zero_points(
return output


def maybe_warn_marlin_atomic_add(device, dtype):
if torch.compiler.is_dynamo_compiling():
return
device_capability = torch.cuda.get_device_capability(device)
if device_capability[0] < 9 and dtype == torch.bfloat16:
logger.info_once(
"You are running Marlin kernel with bf16 on GPUs before SM90. "
"You can consider change to fp16 to achieve better performance "
"if possible."
)


def moe_packed_to_marlin_zero_points(
q_zp_packed: torch.Tensor,
size_k: int,
Expand All @@ -671,42 +659,6 @@ def moe_packed_to_marlin_zero_points(
return output


def maybe_warn_marlin_atomic_add_env():
if torch.compiler.is_dynamo_compiling():
return
if envs.VLLM_MARLIN_USE_ATOMIC_ADD:
return
logger.info_once(
"Marlin kernel can achieve better performance for small size_n "
"with experimental use_atomic_add feature. "
"You can consider set environment variable "
"VLLM_MARLIN_USE_ATOMIC_ADD to 1 if possible."
)


def should_use_atomic_add_reduce(
m: int, n: int, k: int, device: torch.device, dtype: torch.dtype
) -> bool:
# the performance of atomicAdd is better than global reduce
# only when m*n is small and k is large
if n >= 2048 or k < 2048 or device.type != "cuda":
return False

# disable atomicAdd reduce by default,
# one can enable it with VLLM_MARLIN_USE_ATOMIC_ADD=1
if not envs.VLLM_MARLIN_USE_ATOMIC_ADD:
maybe_warn_marlin_atomic_add_env()
return False

# sm8x doesn't support atomicAdd + bfloat16 natively
device_capability = torch.cuda.get_device_capability(device)
if device_capability[0] < 9 and dtype == torch.bfloat16:
maybe_warn_marlin_atomic_add(device, dtype)
return False

return True


_quant_fp8_method: QuantFP8 | None = None


Expand Down Expand Up @@ -769,14 +721,6 @@ def apply_gptq_marlin_linear(
padded_n, padded_k = marlin_repacked_nk(weight, wtype.size_bits)
reshaped_x = marlin_pad_dim(reshaped_x, input_size_per_partition, padded_k)

use_atomic_add = should_use_atomic_add_reduce(
m=reshaped_x.size(0),
n=padded_n,
k=padded_k,
device=input.device,
dtype=input.dtype,
)

a_scales = None
if input_dtype == torch.int8:
assert wtype == scalar_types.uint4b8, (
Expand Down Expand Up @@ -804,7 +748,7 @@ def apply_gptq_marlin_linear(
size_m=reshaped_x.shape[0],
size_n=padded_n,
size_k=padded_k,
use_atomic_add=use_atomic_add,
use_atomic_add=False,
use_fp32_reduce=use_fp32_reduce,
is_zp_float=False,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
marlin_quant_input,
marlin_repacked_nk,
marlin_unpad_output,
should_use_atomic_add_reduce,
)
from vllm.model_executor.utils import replace_parameter
from vllm.platforms import current_platform
Expand Down Expand Up @@ -177,14 +176,6 @@ def apply_fp4_marlin_linear(
padded_n, padded_k = marlin_repacked_nk(weight, num_bits=4)
reshaped_x = marlin_pad_dim(reshaped_x, size_k, padded_k)

use_atomic_add = should_use_atomic_add_reduce(
m=reshaped_x.size(0),
n=padded_n,
k=padded_k,
device=input.device,
dtype=input.dtype,
)

inputs = reshaped_x
a_scales = None
is_nvfp4 = weight_global_scale is not None
Expand All @@ -209,7 +200,7 @@ def apply_fp4_marlin_linear(
size_m=reshaped_x.size(0),
size_n=padded_n,
size_k=padded_k,
use_atomic_add=use_atomic_add,
use_atomic_add=False,
use_fp32_reduce=use_fp32_reduce,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
marlin_permute_scales,
marlin_repacked_nk,
marlin_unpad_output,
should_use_atomic_add_reduce,
)
from vllm.model_executor.utils import replace_parameter
from vllm.platforms import current_platform
Expand Down Expand Up @@ -65,14 +64,6 @@ def apply_fp8_marlin_linear(
padded_n, padded_k = marlin_repacked_nk(weight, num_bits=8)
reshaped_x = marlin_pad_dim(reshaped_x, size_k, padded_k)

use_atomic_add = should_use_atomic_add_reduce(
m=reshaped_x.size(0),
n=padded_n,
k=padded_k,
device=input.device,
dtype=input.dtype,
)

inputs = reshaped_x
a_scales = None
if input_dtype is not None and input_dtype.itemsize == 1:
Expand All @@ -92,7 +83,7 @@ def apply_fp8_marlin_linear(
size_m=reshaped_x.size(0),
size_n=padded_n,
size_k=padded_k,
use_atomic_add=use_atomic_add,
use_atomic_add=False,
use_fp32_reduce=use_fp32_reduce,
)

Expand Down Expand Up @@ -388,14 +379,6 @@ def apply_mxfp8_marlin_linear(
padded_n, padded_k = marlin_repacked_nk(weight, num_bits=8)
reshaped_x = marlin_pad_dim(reshaped_x, size_k, padded_k)

use_atomic_add = should_use_atomic_add_reduce(
m=reshaped_x.size(0),
n=padded_n,
k=padded_k,
device=input.device,
dtype=input.dtype,
)

output = torch.ops.vllm.marlin_gemm(
a=reshaped_x,
b_q_weight=weight,
Expand All @@ -409,7 +392,7 @@ def apply_mxfp8_marlin_linear(
size_m=reshaped_x.size(0),
size_n=padded_n,
size_k=padded_k,
use_atomic_add=use_atomic_add,
use_atomic_add=False,
use_fp32_reduce=use_fp32_reduce,
)

Expand Down
Loading