Skip to content

Commit 729963d

Browse files
nv-dmajchrowskinv-kkudrynski
authored andcommitted
[TSPP] 24.03 Release
1 parent 2788e44 commit 729963d

File tree

552 files changed

+11939
-16353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

552 files changed

+11939
-16353
lines changed

Tools/PyTorch/TimeSeriesPredictionPlatform/.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66
.gitignore
77
Dockerfile
88
.dockerignore
9+
/outputs/
10+
/datasets/
11+
/multirun/
12+
/notebooks/

Tools/PyTorch/TimeSeriesPredictionPlatform/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ __pycache__
33
/outputs/
44
*.zip
55
/datasets/*/
6+
/datasets/
7+
/notebooks/

Tools/PyTorch/TimeSeriesPredictionPlatform/Dockerfile

+26-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
# Copyright 2021-2024 NVIDIA CORPORATION
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
#SPDX-License-Identifier: Apache-2.0
2-
ARG FROM_IMAGE_NAME=nvcr.io/nvidia/pytorch:22.04-py3
16+
ARG FROM_IMAGE_NAME=nvcr.io/nvidia/pytorch:22.12-py3
317

418
FROM ${FROM_IMAGE_NAME}
519

@@ -30,26 +44,31 @@ RUN apt-get update && \
3044
rm -rf /var/lib/apt/lists/*
3145

3246

33-
# Install perf_client required library
3447
RUN apt-get update && \
3548
apt-get install -y libb64-dev libb64-0d curl && \
3649
apt-get clean && \
3750
rm -rf /var/lib/apt/lists/*
3851

39-
# Set workdir and python path
4052
WORKDIR /workspace
4153
ENV PYTHONPATH /workspace
4254

55+
RUN rm /usr/lib/libxgboost.so
56+
4357
ADD requirements.txt /workspace/requirements.txt
4458
ADD triton/requirements.txt /workspace/triton/requirements.txt
4559
RUN pip install -r /workspace/requirements.txt
4660
RUN pip install -r /workspace/triton/requirements.txt
4761
RUN pip install nvidia-pyindex
4862
RUN pip install git+https://github.com/NVIDIA/dllogger#egg=dllogger
49-
RUN pip install --no-cache-dir -r requirements.txt -f https://data.dgl.ai/wheels/repo.html
63+
RUN pip install --no-cache-dir -r requirements.txt
64+
RUN pip install dgl==1.0.1 -f https://data.dgl.ai/wheels/cu117/repo.html
5065

51-
# Add model files to workspace
52-
ADD . /workspace
66+
ADD ./hydra_plugins /workspace/hydra_plugins
67+
RUN pip install /workspace/hydra_plugins/hydra_optuna_sweeper/
68+
RUN pip install /workspace/hydra_plugins/hydra_joblib_launcher/
69+
RUN pip install /workspace/hydra_plugins/hydra_multiprocessing_launcher/
70+
RUN pip install /workspace/hydra_plugins/hydra_torchrun_launcher/
71+
RUN cp /workspace/hydra_plugins/optuna_sweeper.py /usr/local/lib/python3.8/dist-packages/hydra/plugins/sweeper.py
5372

54-
RUN pip install -e distributed_launcher
73+
ADD . /workspace
5574
RUN rm -rf examples docker-examples tutorials

Tools/PyTorch/TimeSeriesPredictionPlatform/LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2021-2022 NVIDIA Corporation
189+
Copyright [yyyy] [name of copyright owner]
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

Tools/PyTorch/TimeSeriesPredictionPlatform/NOTICE

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ This repository contains code from https://github.com/rwightman/pytorch-image-mo
190190
same "printed page" as the copyright notice for easier
191191
identification within third-party archives.
192192

193-
Copyright 2021-2022 NVIDIA Corporation
193+
Copyright [yyyy] [name of copyright owner]
194194

195195
Licensed under the Apache License, Version 2.0 (the "License");
196196
you may not use this file except in compliance with the License.

Tools/PyTorch/TimeSeriesPredictionPlatform/README.md

+429-108
Large diffs are not rendered by default.

Tools/PyTorch/TimeSeriesPredictionPlatform/callbacks/callbacks.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
1+
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# SPDX-License-Identifier: Apache-2.0
1516
class Callback(object):
1617
"""
1718
Base class for building new callbacks.

Tools/PyTorch/TimeSeriesPredictionPlatform/callbacks/ctl_callbacks.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
1+
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# SPDX-License-Identifier: Apache-2.0
1516
import time
1617

1718
import dllogger

Tools/PyTorch/TimeSeriesPredictionPlatform/callbacks/hydra_callbacks.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
1+
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -13,26 +13,27 @@
1313
# limitations under the License.
1414

1515
import os
16+
import mlflow
1617
import pandas as pd
1718

1819
from omegaconf import OmegaConf
1920
from hydra.experimental.callback import Callback
2021

2122
from loggers.log_helper import jsonlog_2_df
23+
from mlflow.entities import Metric, Param
2224

2325
class MergeLogs(Callback):
2426
def on_multirun_end(self, config, **kwargs):
2527
OmegaConf.resolve(config)
2628

27-
ALLOWED_KEYS=['timestamp', 'elapsed_time', 'step', 'loss', 'val_loss', 'MAE', 'MSE', 'RMSE', 'P50', 'P90']
29+
ALLOWED_KEYS=['timestamp', 'elapsed_time', 'step', 'loss', 'val_loss', 'MAE', 'MSE', 'RMSE', 'P50', 'P90', 'SMAPE', 'TDI']
2830

2931
dfs = []
3032
for p, sub_dirs, files in os.walk(config.hydra.sweep.dir):
3133
if 'log.json' in files:
3234
path = os.path.join(p, 'log.json')
3335
df = jsonlog_2_df(path, ALLOWED_KEYS)
3436
dfs.append(df)
35-
3637
# Transpose dataframes
3738
plots = {}
3839
for c in dfs[0].columns:
@@ -49,3 +50,15 @@ def on_multirun_end(self, config, **kwargs):
4950
timestamps = (timestamps * 1000).astype(int)
5051
if not timestamps.is_monotonic:
5152
raise ValueError('Timestamps are not monotonic')
53+
54+
metrics = [Metric('_'.join((k,name)), v, timestamp, step)
55+
for k, df in plots.items()
56+
for timestamp, (step, series) in zip(timestamps, df.iterrows())
57+
for name, v in series.items()
58+
]
59+
client = mlflow.tracking.MlflowClient(tracking_uri=config.trainer.config.mlflow_store)
60+
exp = client.get_experiment_by_name(config.trainer.config.get('experiment_name', ''))
61+
run = client.create_run(exp.experiment_id if exp else '0')
62+
for i in range(0, len(metrics), 1000):
63+
client.log_batch(run.info.run_id, metrics=metrics[i:i+1000])
64+
client.set_terminated(run.info.run_id)

Tools/PyTorch/TimeSeriesPredictionPlatform/conf/conf_utils.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
1+
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -14,8 +14,10 @@
1414

1515
from omegaconf import OmegaConf
1616
from data.data_utils import InputTypes, DataTypes, FeatureSpec
17+
import functools
18+
from hydra.utils import get_method
1719

18-
OmegaConf.register_new_resolver("and", lambda x, y: x and y, use_cache=True)
20+
OmegaConf.register_new_resolver("and", lambda x, y: bool(x and y), use_cache=True)
1921
OmegaConf.register_new_resolver("feature.selector",
2022
lambda x,feat_type,embed_type:
2123
OmegaConf.create([elem for elem in x if elem.feature_type == feat_type and elem.feature_embed_type == embed_type])
@@ -27,10 +29,12 @@
2729
OmegaConf.register_new_resolver("cmp", lambda x, y: x == y)
2830
OmegaConf.register_new_resolver("cont.lower", lambda x, y: y.lower() in x.lower())
2931

30-
# XXX I don't know whether it is the best idea to allow user to sum over nested structure without checks
3132
def sum_nested(*args):
3233
if len(args) == 1 and isinstance(args[0], (int, float)):
3334
return args[0]
3435
return sum(arg if isinstance(arg, (int, float)) else sum_nested(*arg) for arg in args)
3536

3637
OmegaConf.register_new_resolver("sum", sum_nested)
38+
39+
def partial(func, *args, **kwargs):
40+
return functools.partial(get_method(func), *args, **kwargs)
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
1+
# SPDX-License-Identifier: Apache-2.0
152
defaults:
163
- deployment: convert
174

18-
checkpoint: ???
5+
checkpoint: ???
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# SPDX-License-Identifier: MIT
2+
_target_: data.datasets.create_datasets
3+
config:
4+
source_path: /workspace/datasets/M5/M5.csv
5+
dest_path: /workspace/datasets/M5/
6+
iterable: False
7+
encoder_length: 28
8+
input_length: 28
9+
example_length: 56
10+
valid_boundary: '2016-04-25'
11+
train_samples: 1000000
12+
time_series_count: 30490
13+
drop_unseen: True
14+
MultiID: False
15+
features:
16+
- name: 'id'
17+
feature_type: 'ID'
18+
feature_embed_type: 'CATEGORICAL'
19+
cardinality: 30490
20+
- name: "date"
21+
feature_type: 'TIME'
22+
feature_embed_type: 'DATE'
23+
- name: "weight"
24+
feature_type: 'WEIGHT'
25+
feature_embed_type: 'CONTINUOUS'
26+
- name: "item_id"
27+
feature_type: 'STATIC'
28+
feature_embed_type: 'CATEGORICAL'
29+
cardinality: 3050
30+
- name: "dept_id"
31+
feature_type: 'STATIC'
32+
feature_embed_type: 'CATEGORICAL'
33+
cardinality: 8
34+
- name: "cat_id"
35+
feature_type: 'STATIC'
36+
feature_embed_type: 'CATEGORICAL'
37+
cardinality: 4
38+
- name: "store_id"
39+
feature_type: 'STATIC'
40+
feature_embed_type: 'CATEGORICAL'
41+
cardinality: 11
42+
- name: "state_id"
43+
feature_type: 'STATIC'
44+
feature_embed_type: 'CATEGORICAL'
45+
cardinality: 4
46+
- name: "items_sold"
47+
feature_type: 'TARGET'
48+
feature_embed_type: 'CONTINUOUS'
49+
scaler:
50+
_target_: data.data_utils.Log1pScaler
51+
- name: "wday"
52+
feature_type: 'KNOWN'
53+
feature_embed_type: 'CATEGORICAL'
54+
cardinality: 8
55+
- name: "month"
56+
feature_type: 'KNOWN'
57+
feature_embed_type: 'CATEGORICAL'
58+
cardinality: 13
59+
- name: "event_name_1"
60+
feature_type: 'KNOWN'
61+
feature_embed_type: 'CATEGORICAL'
62+
cardinality: 31
63+
- name: "event_type_1"
64+
feature_type: 'KNOWN'
65+
feature_embed_type: 'CATEGORICAL'
66+
cardinality: 5
67+
- name: "event_type_2"
68+
feature_type: 'KNOWN'
69+
feature_embed_type: 'CATEGORICAL'
70+
cardinality: 3
71+
- name: "event_name_2"
72+
feature_type: 'KNOWN'
73+
feature_embed_type: 'CATEGORICAL'
74+
cardinality: 5
75+
- name: "snap_CA"
76+
feature_type: 'KNOWN'
77+
feature_embed_type: 'CATEGORICAL'
78+
cardinality: 3
79+
- name: "snap_TX"
80+
feature_type: 'KNOWN'
81+
feature_embed_type: 'CATEGORICAL'
82+
cardinality: 3
83+
- name: "snap_WI"
84+
feature_type: 'KNOWN'
85+
feature_embed_type: 'CATEGORICAL'
86+
cardinality: 3
87+
- name: "sell_price"
88+
feature_type: 'KNOWN'
89+
feature_embed_type: 'CONTINUOUS'
90+
scaler:
91+
_target_: sklearn.preprocessing.StandardScaler
92+
binarized: True

0 commit comments

Comments
 (0)