-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fea-hps-torch-plugin-kingsleyl' into 'main'
Add torch extension for hps Closes #833 See merge request dl/hugectr/hugectr!1434
- Loading branch information
Showing
38 changed files
with
1,631 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
srun --container-image="${CONT}" --container-mounts="${MOUNTS}" bash -cx "bash /workdir/ci/benchmark/hps_torch_fuse_table_benchmark/test.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
mkdir -p /hps_torch_fuse_table_benchmark | ||
|
||
cd /hps_torch_fuse_table_benchmark | ||
|
||
cp -r /model_repo ./ | ||
|
||
cp -r /model_repo/8_table.json ./ | ||
|
||
cp -r /model_repo/embeddings ./ | ||
|
||
LD_PRELOAD=/usr/local/lib/python${PYTHON_VERSION}/dist-packages/merlin_hps-0.0.0-py${PYTHON_VERSION}-linux-x86_64.egg/hps_torch/lib/libhps_torch.so tritonserver --model-repository=model_repo --load-model=8_static_table_autofused --load-model=8_static_table_unfused --load-model=8_dynamic_table_autofused --load-model=8_dynamic_table_unfused --model-control-mode=explicit & | ||
|
||
while [[ $(curl -v localhost:8000/v2/health/ready 2>&1 | grep "OK" | wc -l) -eq 0 ]]; do | ||
sleep 10; | ||
done | ||
|
||
echo "Successfully launching the Triton server for all models" | ||
|
||
batch_size=(256 1024 4096 16384) | ||
|
||
model_name=("8_static_table_unfused" "8_static_table_autofused" "8_dynamic_table_unfused" "8_dynamic_table_autofused") | ||
|
||
for b in ${batch_size[*]}; | ||
do | ||
for m in ${model_name[*]}; | ||
do | ||
echo $b $m | ||
perf_analyzer -m ${m} -u localhost:8000 --input-data /perf_data/${b}.json --shape input_1:8,${b},10 | ||
done | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
srun --ntasks=1 --container-image="${CONT}" --container-mounts="${MOUNTS}" bash -cx " \ | ||
cd /workdir/hps_torch/test/unit && \ | ||
pytest -s && \ | ||
cd /workdir/hps_torch/test/integration && \ | ||
pytest test_hps_table_fusion.py -s" | ||
|
||
# Add workaround due to the known issue of tensorflow | ||
sleep 10 | ||
EXITCODE=`sacct -j "${SLURM_JOBID}" -n --format=exitcode | sort -r -u | head -1 | cut -f 1 -d":" | sed 's/ //g'` | ||
echo "Job exit code: ${EXITCODE}" | ||
|
||
if [ ${EXITCODE} -eq 6 ]&&[ ${CI_JOB_NAME}=="hps_tf" ]; then | ||
echo "Rerun the job, if job exit code is 6 and job name is hps_tf." | ||
srun --ntasks=1 --container-image="${CONT}" --container-mounts="${MOUNTS}" bash -cx " \ | ||
cd /workdir/hps_torch/test/unit && \ | ||
pytest -s && \ | ||
cd /workdir/hps_torch/test/integration && \ | ||
pytest test_hps_table_fusion.py -s" | ||
# Get the last job step exit code as job exit code. | ||
sed -i 's/sort -r -u | head -1/tail -1/g' ${JOBSCRIPTSDIR}/mlperf-ci/jobexitcode.sh | ||
echo "Rerun job finished!"; | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
srun --ntasks=1 --container-image="${CONT}" --container-mounts="${MOUNTS}" bash -cx " \ | ||
python3 /workdir/ci/post_test/check_performance.py --job_name hps_torch_fuse_table_benchmark --log_path /logs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
docs/source/hierarchical_parameter_server/hps_torch_api/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
HPS Plugin for Torch API | ||
=========================== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
LookupLayer <lookup_layer> |
35 changes: 35 additions & 0 deletions
35
docs/source/hierarchical_parameter_server/hps_torch_api/lookup_layer.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# HPS Plugin for Torch | ||
|
||
```{contents} | ||
--- | ||
depth: 2 | ||
local: true | ||
backlinks: none | ||
--- | ||
``` | ||
|
||
#### LookupLayer class | ||
|
||
This is a wrapper class for HPS lookup layer, which basically performs the same function as ``torch.nn.Embedding``. It inherits `torch.nn.Module`. | ||
|
||
```python | ||
hps_torch.LookupLayer.__init__ | ||
``` | ||
**Arguments** | ||
* `ps_config_file`: String. The JSON configuration file for HPS initialization. | ||
|
||
* `model_name`: String. The name of the model that has embedding tables. | ||
|
||
* `table_id`: Integer. The index of the embedding table for the model specified by `model_name`. | ||
|
||
* `emb_vec_size`: Integer. The embedding vector size for the embedding table specified by `model_name` and `table_id`. | ||
|
||
|
||
```python | ||
hps_torch.LookupLayer.forward | ||
``` | ||
**Arguments** | ||
* `keys`: Tensor of ``torch.int32`` or ``torch.int64``. | ||
|
||
**Returns** | ||
* `vectors`: Tensor of `torch.float32`. |
Oops, something went wrong.