Amazon SageMaker Batch Transform
I am working on time series forecasting problem using customized LSTM model and want to use batch transform to run my inference. I have 100,000 time series each take 48rows (past sales data with external features in CSV format) as input and forecast 4 (sales) values ahead. I want to know
- How do I run batch transform for inference on these 100,000 time series?
- In what format do I store data? Currently its 100,000 small 48 rows CSV stored on S3.
- I am confused how to use split type for my application. I want to finish inference of all these time series in say 30mins. Each one of them takes 2seconds to run. Currently I am launching 1000 endpoints to pass group of time series to run inference, I believe batch transform is the answer for my problem. Please help. Thanks in advance.
Hi @cna274 , Sorry for the delayed response.
In order to make SageMaker batch transformation work for this use case, you'll likely need to convert the 48 records from each time series into a single row of data. SageMaker DeepAR for example does this by storing all values of each time series as a single jsonlines object. So, in the end you'll have 100,000 rows of data rather than (48 * 100,000 =) 4.8 million rows.
Then, for performance, you'll probably want to include multiple time-series in a single file. However, you'll want at least as many files as the number of instances you plan to use in your batch transform job. So, if you wanted to use 20 instances, you'd need 20 files (each one with 5,000 lines / time series).
Then, you can tune SplitType and MaxConcurrentTransforms to fully utilize your instances and generate predictions.
Thanks.
you'll want at least as many files as the number of instances you plan to use in your batch transform job
@djarpin, is having one input file per instance a requirement for batch transform?
I've been having a strange issue where no matter how many instances I specify when configuring a batch transform job, only one instance does the real work. Each of the instances gets started up and runs my flask server, but - from looking at the logs - I can see that only one of the instances is actually processing the data. I've recreated the same behavior even using Amazon's example notebook.
Does this sound like anything you're aware of?
@dorg-jmiller - You can have more than one input file per instance and SageMaker will shard the data by S3 key across the instances, but if you have fewer files than instances you will get the behavior you mentioned, where some instances are running, but not actually processing data.
Thanks.
Thanks for the response, @djarpin. This behavior is counterintuitive to me.
Just to clarify -- you're saying that to take advantage of multiple instances with batch transform it's necessary to manually split the input data into as many (or more) files as instances? I would expect SageMaker to know to automatically shard the input data across the number of requested instances, regardless of the number of input files.
Another way to phrase the same point -- I would expect the total number of records requested for processing to matter more than the total number of input files.
This info could even be added as a tooltip.
Dear SageMaker Community, In our attempts to provide this repository with a better level of support going forward, we’re closing issues that were opened prior to the v2 release of the SDK. This is because we believe that over time many of the issues posted were solved with the latest release or other recent changes to the repo. This will help us reallocate resources towards issues that are more likely to still be relevant today. Some of the issues experienced now can be resolved by referencing the v2 guide: https://sagemaker.readthedocs.io/en/stable/v2.html In this guide, you can find simple solutions to common notebook errors, like the renaming of parameters and classes. If you believe your issue is still ongoing and you have updated error messaging or other info, please re-open it, and we investigate the issue. Best Regards, AWS SageMaker Team
Can this issue be reopened? It's still confusing behavior and an awkward workaround to have to split the input file up according to the number of hosts.