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

platform framework #2193

Merged
merged 51 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2421c09
expand model archiver runtime type and add model config file
lxning Feb 4, 2023
9ebb6bf
lmi frontend poc init
lxning Feb 22, 2023
d50e4ae
add modelConfig.java
lxning Feb 22, 2023
5a69b62
try run_pippy
lxning Feb 24, 2023
f0cc445
update archive modification
lxning Feb 24, 2023
a06598c
add model config file in mar file; frontend add torchrun and update c…
lxning Feb 28, 2023
8119bc0
clean up parameters
lxning Feb 28, 2023
568720f
fix the start command
HamidShojanazeri Mar 2, 2023
2b571b7
updated as per Li's suggestion
HamidShojanazeri Mar 2, 2023
ebda4eb
adding pippy all_compile
HamidShojanazeri Mar 3, 2023
eebd8a9
adding pippy all_compile
HamidShojanazeri Mar 3, 2023
77d7a07
adding pippy all_compile, fix inference
HamidShojanazeri Mar 3, 2023
049a715
fix Reply queue is full
lxning Mar 3, 2023
b3e4fd9
adding device mapping
HamidShojanazeri Mar 4, 2023
c1e9f9f
update device map
lxning Mar 4, 2023
5d81bd4
support torchelastic log
lxning Mar 5, 2023
3aff4ff
add torchrun config
lxning Mar 6, 2023
afc0ed0
fixed initialize and unit test
lxning Mar 9, 2023
e1ad19f
update model-config.yaml
lxning Mar 9, 2023
0cd1fa8
update modelConfig
lxning Mar 9, 2023
b78aedd
update archiver readme
lxning Mar 10, 2023
6ab3e07
update archiver readme
lxning Mar 10, 2023
2b490dc
update ModelConfig and extend backend to parse model config yaml
lxning Mar 13, 2023
fc115bc
add tp handler init
lxning Mar 13, 2023
6d315a0
fix model config parser
lxning Mar 15, 2023
71bcacc
update pippy_pptp_handler
lxning Mar 15, 2023
ea58747
get gpuid by rotating model's deviceIds
lxning Mar 16, 2023
fdf8d51
code clean up
lxning Mar 21, 2023
2b978b6
update config yaml
lxning Mar 22, 2023
ab43251
update gradle
lxning Mar 22, 2023
60441bc
update docs
lxning Mar 22, 2023
5c95682
clean up code
lxning Mar 22, 2023
2988690
revert to original doc for the example
lxning Mar 22, 2023
dacc252
update doc link
lxning Mar 22, 2023
5485d06
fmt
lxning Mar 23, 2023
5c15ea7
Merge branch 'master' into issue_2192
lxning Mar 23, 2023
4877c56
fmt
lxning Mar 24, 2023
b3544cd
use basename
lxning Mar 24, 2023
35857b7
precommit fmt
lxning Mar 24, 2023
94f03f4
check model config input
lxning Mar 25, 2023
de1efb3
add Model
lxning Mar 25, 2023
7a60dd3
check deviceIds
lxning Mar 25, 2023
615e91a
set gpu >=1000 as invlid config
lxning Mar 25, 2023
8e7acad
precommit fmt
lxning Mar 26, 2023
83605dd
optimize gpu assignment
lxning Mar 26, 2023
a706378
fix merge master conflict
lxning Mar 28, 2023
681015e
Merge branch 'master' into issue_2192
lxning Mar 29, 2023
8e4a1c5
precommit fmt
lxning Mar 29, 2023
628f58b
fix sanity test error caused by auto merge
lxning Mar 29, 2023
08b6eab
fix test_archive_creation_with_zip_store
lxning Mar 29, 2023
333c189
Merge branch 'master' into issue_2192
lxning Mar 29, 2023
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.4.0
hooks:
- id: check-ast
- id: check-builtin-literals
Expand All @@ -18,23 +18,23 @@ repos:
- id: check-vcs-permalinks
- id: check-shebang-scripts-are-executable
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: v1.10.0
hooks:
- id: python-check-mock-methods
- id: python-no-log-warn
- id: python-use-type-annotations
- repo: https://github.com/hadialqattan/pycln
rev: v1.2.5
rev: v2.1.3
hooks:
- id: pycln
args: [--all]
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.1.0
hooks:
- id: black
additional_dependencies: ['click==8.0.4']
- repo: https://github.com/PyCQA/isort
rev: 5.11.5
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
5 changes: 5 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ models={\
}\
}
```
As of version 0.8.0, TorchServe allows for model configuration using a YAML file embedded in the MAR file. This YAML file contains two distinct parts that determine how a model is configured: frontend parameters and backend parameters. (see [details](https://github.com/pytorch/serve/tree/master/model-archiver))

* The frontend parameters are controlled by TorchServe's frontend and specify the parameter name and default values. TorchServe now uses a priority order to determine the final value of a model's parameters in frontend. Specifically, the config.property file has the lowest priority, followed by the model configuration YAML file, and finally, the REST or gRPC model management API has the highest priority.

* The backend parameters are fully controlled by the user. Users customized handler can access the backend parameters via the `model_yaml_config` property of the context object.

### Other properties

Expand Down
1 change: 1 addition & 0 deletions frontend/archive/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dependencies {
api "org.slf4j:slf4j-api:${slf4j_api_version}"
api "org.apache.logging.log4j:log4j-slf4j-impl:${slf4j_log4j_version}"
api "com.google.code.gson:gson:${gson_version}"
implementation "org.yaml:snakeyaml:${snakeyaml_version}"

testImplementation "commons-cli:commons-cli:${commons_cli_version}"
testImplementation "org.testng:testng:${testng_version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static final class Model {
private String handler;
private String envelope;
private String requirementsFile;
private String configFile;

public Model() {}

Expand Down Expand Up @@ -122,6 +123,14 @@ public String getEnvelope() {
public void setEnvelope(String envelope) {
this.envelope = envelope;
}

public String getConfigFile() {
return configFile;
}

public void setConfigFile(String configFile) {
this.configFile = configFile;
}
}

public enum RuntimeType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.pytorch.serve.archive.DownloadArchiveException;
Expand All @@ -25,12 +26,14 @@ public class ModelArchive {
private String url;
private File modelDir;
private boolean extracted;
private ModelConfig modelConfig;

public ModelArchive(Manifest manifest, String url, File modelDir, boolean extracted) {
this.manifest = manifest;
this.url = url;
this.modelDir = modelDir;
this.extracted = extracted;
this.modelConfig = null;
msaroufim marked this conversation as resolved.
Show resolved Hide resolved
}

public static ModelArchive downloadModel(
Expand Down Expand Up @@ -92,7 +95,7 @@ private static ModelArchive load(String url, File dir, boolean extracted)
boolean failed = true;
try {
File manifestFile = new File(dir, "MAR-INF/" + MANIFEST_FILE);
Manifest manifest = null;
Manifest manifest;
if (manifestFile.exists()) {
manifest = ArchiveUtils.readFile(manifestFile, Manifest.class);
} else {
Expand Down Expand Up @@ -179,4 +182,21 @@ public void clean() {
FileUtils.deleteQuietly(modelDir);
}
}

public ModelConfig getModelConfig() {
if (this.modelConfig == null && manifest.getModel().getConfigFile() != null) {
try {
File configFile =
new File(modelDir.getAbsolutePath(), manifest.getModel().getConfigFile());
Map<String, Object> modelConfigMap = ArchiveUtils.readYamlFile(configFile);
this.modelConfig = ModelConfig.build(modelConfigMap);
} catch (InvalidModelException | IOException e) {
logger.error(
"Failed to parse model config file {}",
manifest.getModel().getConfigFile(),
e);
}
}
return this.modelConfig;
}
}
Loading