Skip to content

Commit

Permalink
fix data racing due to mutable reference using deepcopy (#1255)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiezhq-hermann authored Aug 29, 2024
1 parent 6c34d63 commit 8153168
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/sglang/srt/managers/io_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
processes (TokenizerManager, DetokenizerManager, Controller).
"""

import copy
import uuid
from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Union

from sglang.srt.managers.schedule_batch import BaseFinishReason
Expand Down Expand Up @@ -249,6 +250,10 @@ class BatchTokenIDOut:
meta_info: List[Dict]
finished_reason: List[BaseFinishReason]

def __post_init__(self):
# deepcopy meta_info to avoid modification in place
self.meta_info = copy.deepcopy(self.meta_info)


@dataclass
class BatchStrOut:
Expand Down

0 comments on commit 8153168

Please sign in to comment.