Skip to content

Commit

Permalink
Make the server random by default (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
merrymercy authored Jun 1, 2024
1 parent 7d1ebc2 commit 159cc74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 6 additions & 3 deletions docs/hyperparameter_tuning.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ On the other hand, if you see `token usage` very high and you frequently see war
### Tune `--dp-size` and `--tp-size`
Data parallelism is better for throughput. When there is enough GPU memory, always favor data parallelism for throughput.

### (Minor) Tune `--max-prefill-tokens`, `--mem-fraction-static`, `--max-running-requests`.
If you see out of memory (OOM) errors, you can decrease these parameters.
If OOM happens during prefill, try to decrease `--max-prefill-tokens`.
If OOM happens during decoding, try to decrease `--max-running-requests`.
You can also try to decrease `--mem-fraction-static`, which reduces the memory usage of the KV cache memory pool and helps both prefill and decoding.

### (Minor) Tune `--schedule-heuristic`
If you have many shared prefixes, use the default `--schedule-heuristic lpm`. `lpm` stands for longest prefix match.
When you have no shared prefixes at all or you always send the requests with the shared prefixes together,
you can try `--schedule-heuristic fcfs`. `fcfs` stands for first come first serve.

### (Minor) Tune `--max-prefill-tokens`, `--mem-fraction-static`, `--max-running-requests`.
If you see out of memory errors, you can decrease them. Otherwise, the default value should work well.
6 changes: 5 additions & 1 deletion python/sglang/srt/server_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import argparse
import dataclasses
import random
from typing import List, Optional, Union


Expand Down Expand Up @@ -32,7 +33,7 @@ class ServerArgs:
# Other runtime options
tp_size: int = 1
stream_interval: int = 8
random_seed: int = 42
random_seed: Optional[int] = None

# Logging
log_level: str = "info"
Expand Down Expand Up @@ -72,6 +73,9 @@ def __post_init__(self):
elif self.additional_ports is None:
self.additional_ports = []

if self.random_seed is None:
self.random_seed = random.randint(0, 1 << 30)

@staticmethod
def add_cli_args(parser: argparse.ArgumentParser):
parser.add_argument(
Expand Down

0 comments on commit 159cc74

Please sign in to comment.