From 2dfe464e5adb6c7b528c872369c0617b4464c308 Mon Sep 17 00:00:00 2001 From: Dnoob Date: Thu, 3 Sep 2026 17:57:55 +0800 Subject: [PATCH] style: apply black line-length 100 and pin it in pyproject.toml Signed-off-by: Dnoob --- pyproject.toml | 109 ++++++++++-------- rl_engine/integrations/vllm_runtime.py | 6 +- .../kernels/ops/cuda/attention/flash_attn.py | 10 +- 3 files changed, 61 insertions(+), 64 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ca3b0c5d..216eec05 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,55 +1,62 @@ -[build-system] -requires = ["setuptools>=64", "wheel"] -build-backend = "setuptools.build_meta" - -[project] -name = "RL-Kernel" -version = "0.1.0" -description = "High-performance RL training engine focused on kernel fusion and memory efficiency." -readme = "README.md" -requires-python = ">=3.10" -license = {text = "Apache-2.0"} -authors = [ - {name = "RL-Kernel Contributors"} -] -dependencies = [ - "torch>=2.4.1", - "tabulate", - "numpy", - "accelerate", - "transformers==5.13.1", -] - -[project.entry-points."vllm.general_plugins"] -rl_kernel = "rl_engine.integrations.vllm_runtime:register_vllm_plugin" - -[project.optional-dependencies] -cuda = ["flashinfer-python>=0.1.6", "nvidia-ml-py"] +[build-system] +requires = ["setuptools>=64", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "RL-Kernel" +version = "0.1.0" +description = "High-performance RL training engine focused on kernel fusion and memory efficiency." +readme = "README.md" +requires-python = ">=3.10" +license = {text = "Apache-2.0"} +authors = [ + {name = "RL-Kernel Contributors"} +] +dependencies = [ + "torch>=2.4.1", + "tabulate", + "numpy", + "accelerate", + "transformers==5.13.1", +] + +[project.entry-points."vllm.general_plugins"] +rl_kernel = "rl_engine.integrations.vllm_runtime:register_vllm_plugin" + +[project.optional-dependencies] +cuda = ["flashinfer-python>=0.1.6", "nvidia-ml-py"] rocm = ["aiter"] vllm = ["vllm>=0.6.0"] drift-viewer = ["Pillow>=10", "PySide6>=6.6"] dev = ["pytest", "black", "isort", "ruff", "mypy", "pre-commit"] - -[tool.setuptools.packages.find] -where = ["."] -include = ["rl_engine*"] - -[tool.ruff] -line-length = 100 - -[tool.ruff.lint] -select = ["E", "F", "B"] -ignore = [] - -[tool.ruff.lint.per-file-ignores] -"__init__.py" = ["F401"] - -[tool.mypy] -ignore_missing_imports = true -follow_imports = "silent" - -[tool.pytest.ini_options] -markers = [ - "smoke_operator: temporary smoke-only operator plumbing tests", - "unit: CPU-safe unit tests", -] + +[tool.setuptools.packages.find] +where = ["."] +include = ["rl_engine*"] + +[tool.black] +line-length = 100 + +[tool.isort] +profile = "black" +line_length = 100 + +[tool.ruff] +line-length = 100 + +[tool.ruff.lint] +select = ["E", "F", "B"] +ignore = [] + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F401"] + +[tool.mypy] +ignore_missing_imports = true +follow_imports = "silent" + +[tool.pytest.ini_options] +markers = [ + "smoke_operator: temporary smoke-only operator plumbing tests", + "unit: CPU-safe unit tests", +] diff --git a/rl_engine/integrations/vllm_runtime.py b/rl_engine/integrations/vllm_runtime.py index ade13cab..6351f0ab 100644 --- a/rl_engine/integrations/vllm_runtime.py +++ b/rl_engine/integrations/vllm_runtime.py @@ -475,11 +475,7 @@ def strict_row_parallel_forward(instance: Any, input_: torch.Tensor) -> Any: )[instance.tp_rank].contiguous() assert instance.quant_method is not None - bias_ = ( - None - if (instance.tp_rank > 0 or instance.skip_bias_add) - else instance.bias - ) + bias_ = None if (instance.tp_rank > 0 or instance.skip_bias_add) else instance.bias output_parallel = instance.quant_method.apply(instance, input_parallel, bias_) if instance.reduce_results and instance.tp_size > 1: diff --git a/rl_engine/kernels/ops/cuda/attention/flash_attn.py b/rl_engine/kernels/ops/cuda/attention/flash_attn.py index 9ad510b3..e57cdeb5 100644 --- a/rl_engine/kernels/ops/cuda/attention/flash_attn.py +++ b/rl_engine/kernels/ops/cuda/attention/flash_attn.py @@ -130,9 +130,7 @@ def precompile_training( tensors, RNG state, or distributed collectives. """ if torch.version.hip is not None: - raise StrictFlashAttentionUnavailable( - "FA4 CUDA precompile is unavailable on ROCm" - ) + raise StrictFlashAttentionUnavailable("FA4 CUDA precompile is unavailable on ROCm") if not torch.cuda.is_available(): raise StrictFlashAttentionUnavailable( "FA4 CUDA precompile requires an available CUDA device" @@ -144,11 +142,7 @@ def precompile_training( if head_dim <= 0 or sequence_length <= 0: raise ValueError("head_dim and sequence_length must be positive") - target = ( - torch.device("cuda", torch.cuda.current_device()) - if device is None - else device - ) + target = torch.device("cuda", torch.cuda.current_device()) if device is None else device if target.type != "cuda": raise ValueError("strict FA4 training precompile requires a CUDA device")