polish code with new pre-commit rule (#2923)

This commit is contained in:
Zero Rains
2025-07-19 23:19:27 +08:00
committed by GitHub
parent b8676d71a8
commit 25698d56d1
424 changed files with 14307 additions and 13518 deletions

View File

@@ -13,11 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""
import gc
from typing import List, Optional
import paddle
import paddle.nn as nn
from paddle import nn
from fastdeploy.config import FDConfig
from fastdeploy.engine.request import Request
@@ -46,8 +47,7 @@ class GcuWorker(WorkerBase):
pass
def init_device(self):
""" Initialize device and Construct model runner
"""
"""Initialize device and Construct model runner"""
if paddle.is_compiled_with_custom_device("gcu"):
# Set evironment variable
self.device_ids = self.parallel_config.device_ids.split(",")
@@ -58,8 +58,7 @@ class GcuWorker(WorkerBase):
gc.collect()
else:
raise RuntimeError(
f"Not support device type: {self.device_config.device}")
raise RuntimeError(f"Not support device type: {self.device_config.device}")
# Construct model runner
self.model_runner: GCUModelRunner = GCUModelRunner(
@@ -67,7 +66,8 @@ class GcuWorker(WorkerBase):
device=self.device,
device_id=self.device_ids[self.local_rank],
rank=self.rank,
local_rank=self.local_rank)
local_rank=self.local_rank,
)
def prefill_finished(self):
"""
@@ -98,8 +98,7 @@ class GcuWorker(WorkerBase):
""" """
return self.model_runner.get_model()
def initialize_cache(self, num_gpu_blocks: int,
num_cpu_blocks: int) -> None:
def initialize_cache(self, num_gpu_blocks: int, num_cpu_blocks: int) -> None:
""" """
pass
@@ -112,7 +111,7 @@ class GcuWorker(WorkerBase):
return output
def preprocess_new_task(self, req_dicts: List[Request]) -> None:
""" Process new requests and then start the decode loop
"""Process new requests and then start the decode loop
TODO(gongshaotian):The scheduler should schedule the handling of prefill,
and workers and modelrunners should not perceive it.
"""
@@ -138,5 +137,4 @@ class GcuWorker(WorkerBase):
def reinitialize_kv_cache(self, num_gpu_blocks: int) -> None:
""" """
self.model_runner.update_share_input_block_num(
num_gpu_blocks=num_gpu_blocks)
self.model_runner.update_share_input_block_num(num_gpu_blocks=num_gpu_blocks)