Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vLLM] add speculative configs #1553

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add speculative configs
  • Loading branch information
Qing Lan committed Feb 23, 2024
commit 1b308109a86fe25d52b6a50d6526bcdc6c20bb19
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class VllmRbProperties(Properties):
# TODO: try to get good default from vLLM to prevent revisiting
# TODO: last time check: vllm 0.3.1
gpu_memory_utilization: Optional[float] = 0.9
# TODO: speculative decoding changes
speculative_draft_model: Optional[str] = None
speculative_length: int = 5
draft_model_tp_size: int = 1

@validator('engine')
def validate_engine(cls, engine):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def __init__(self, model_id_or_path, properties, **kwargs):
trust_remote_code=self.vllm_configs.trust_remote_code,
load_format=self.vllm_configs.load_format,
quantization=self.vllm_configs.quantize,
draft_model=self.vllm_configs.speculative_draft_model,
speculate_length=self.vllm_configs.speculative_length,
draft_model_tp_size=self.vllm_configs.draft_model_tp_size,
revision=self.vllm_configs.revision)
self.engine = LLMEngine.from_engine_args(args)
self.request_cache = OrderedDict()
Expand Down
51 changes: 31 additions & 20 deletions wlm/src/main/java/ai/djl/serving/wlm/ModelInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,39 @@ private long getAvailableCpuMemory() {
return Integer.MAX_VALUE * 1024L;
}

private Path downloadS3ToDownloadDir(String s3Url) throws IOException, ModelException {
logger.info("{}: S3 url found, start downloading from {}", uid, s3Url);
// Use fixed download path to avoid repeat download
String hash = Utils.hash(s3Url);
String download = Utils.getenv("SERVING_DOWNLOAD_DIR", null);
Path parent = download == null ? Utils.getCacheDir() : Paths.get(download);
parent = parent.resolve("download");
Path downloadModelDir = parent.resolve(hash);
if (Files.exists(downloadModelDir)) {
logger.info("{}: artifacts has been downloaded already: {}", uid, downloadModelDir);
} else {
Files.createDirectories(parent);
Path tmp = Files.createTempDirectory(parent, "tmp");
try {
downloadS3(s3Url, tmp.toAbsolutePath().toString());
Utils.moveQuietly(tmp, downloadModelDir);
logger.info("{}: Download completed! Files saved to {}", uid, downloadModelDir);
} finally {
Utils.deleteQuietly(tmp);
}
}
return downloadModelDir;
}

void downloadS3() throws ModelException, IOException {
String s3Url = prop.getProperty("option.s3url");
String modelId = prop.getProperty("option.model_id");
String draftModelId = prop.getProperty("option.speculative_draft_model");
if (draftModelId != null && draftModelId.startsWith("s3://")) {
Path draftDownloadDir = downloadS3ToDownloadDir(draftModelId);
prop.setProperty(
"option.speculative_draft_model", draftDownloadDir.toAbsolutePath().toString());
}
if (s3Url != null) {
// s3url is deprecated, use model_id instead
if (modelId != null) {
Expand All @@ -970,26 +1000,7 @@ void downloadS3() throws ModelException, IOException {
return;
}
if (modelId.startsWith("s3://")) {
logger.info("{}: S3 url found, start downloading from {}", uid, modelId);
// Use fixed download path to avoid repeat download
String hash = Utils.hash(modelId);
String download = Utils.getenv("SERVING_DOWNLOAD_DIR", null);
Path parent = download == null ? Utils.getCacheDir() : Paths.get(download);
parent = parent.resolve("download");
this.downloadDir = parent.resolve(hash);
if (Files.exists(this.downloadDir)) {
logger.info("{}: artifacts has been downloaded already: {}", uid, this.downloadDir);
return;
}
Files.createDirectories(parent);
Path tmp = Files.createTempDirectory(parent, "tmp");
try {
downloadS3(modelId, tmp.toAbsolutePath().toString());
Utils.moveQuietly(tmp, this.downloadDir);
logger.info("{}: Download completed! Files saved to {}", uid, this.downloadDir);
} finally {
Utils.deleteQuietly(tmp);
}
this.downloadDir = downloadS3ToDownloadDir(modelId);
} else if (modelId.startsWith("djl://")) {
logger.info("{}: djl model zoo url found: {}", uid, modelId);
modelUrl = modelId;
Expand Down
Loading