This document is used to list steps of reproducing PyTorch DLRM tuning zoo result. and original DLRM README is in DLRM README
Note
Please ensure your PC have >370G memory to run DLRM IPEX version >= 1.11
PyTorch 1.11 or higher version is needed with pytorch_fx backend.
# Install dependency
cd examples/pytorch/recommendation/dlrm/quantization/ptq/ipex
pip install -r requirements.txt
Note: Validated PyTorch Version.
The code supports interface with the Criteo Terabyte Dataset
- download the raw data files day_0.gz, ...,day_23.gz and unzip them.
- Specify the location of the unzipped text files day_0, ...,day_23, using --raw-data-file=<path/day> (the day number will be appended automatically), please refer "Run" command.
Download the DLRM PyTorch weights (tb00_40M.pt
, 90GB) from the
MLPerf repo
cd examples/pytorch/recommendation/dlrm/quantization/ptq/ipex
bash run_quant.sh --input_model="/path/of/pretrained/model" --dataset_location="/path/of/dataset"
bash run_benchmark.sh --input_model="/path/of/pretrained/model" --dataset_location="/path/of/dataset" --mode=accuracy --int8=true
This is a tutorial of how to enable DLRM model with Intel® Neural Compressor.
We need update dlrm_s_pytorch.py like below
class DLRM_DataLoader(object):
def __init__(self, loader=None):
self.loader = loader
self.batch_size = loader.dataset.batch_size
def __iter__(self):
for X_test, lS_o_test, lS_i_test, T in self.loader:
yield (X_test, lS_o_test, lS_i_test), T
def eval_func(model):
args.int8 = False if model.ipex_config_path is None else True
args.int8_configure = "" \
if model.ipex_config_path is None else model.ipex_config_path
with torch.no_grad():
return inference(
args,
model,
best_acc_test,
best_auc_test,
test_ld,
trace=args.int8
)
eval_dataloader = DLRM_DataLoader(train_ld)
from neural_compressor import PostTrainingQuantConfig, quantization
conf = PostTrainingQuantConfig(backend="ipex")
q_model = quantization.fit(
dlrm,
conf=conf,
eval_func=eval_func,
calib_dataloader=eval_dataloader
)
q_model.save("saved_results")