scripts/code_sync/guideline.md
You can use the following principles and tools to sync the code between a private fork and the OSS repo sgl-project/sglang. It learns from Copybara, a tool used at Google for maintaining open-source code synchronization.
python/sglang/srt) are 100% mirrored between the private fork and OSS repo.python/sglang/srt in the private repo, the change should be synced to the OSS repo as soon as possible with the action B below.python/sglang/srt. The private-specific code (e.g., with private-specific features, confidential info) goes to python/sglang/private .python/sglang/srt, duplicate the file and move it under python/sglang/private. You can achieve code reuse by importing and inheriting.python/sglang/srt , test/srt , sgl-kernel ) from the OSS main branch to the private fork.python/sglang/srt , test/srt , sgl-kernel ) and ignore changes under private folders (e.g., python/sglang/private )python/sglang/srt and python/sglang/private/srt. Once you merge the PR into the private repo, python/sglang/srt becomes desynced between the two repos. You need to run this action on your merge commit immediately to open a PR to send your diff to the OSS repo. Then, we need to merge the OSS PR as soon as possible. Once your OSS PR is merged, we can run action A again.python/sglang/private/server_args.py. It defines a class that inherits the oss ServerArgs.
from sglang.srt.server_args import ServerArgs as ServerArgsOSS
@dataclasses.dataclass
class ServerArgs(ServerArgsOSS):
private_flag: str = "foo"
@staticmethod
def add_cli_args(parser: argparse.ArgumentParser):
# Get all public args
ServerArgsOSS.add_cli_args(parser)
# Add your private flags
parser.add_argument(
"--private-flag",
type=str,
default=ServerArgs.private_flag,
)
Engine and override its fields. You can override server_args_class to use your own ServerArgs,
override init_tokenizer_manager_func to use your own TokenizerManager, override run_scheduler_process_func to use your own scheduler.