Ingesting and storing ML data: MLA-C02 study notes and practice questions
What to know about Ingesting and storing ML data for the MLA-C02 exam, from the Data Preparation for ML and AI domain (28% of the exam guide), then 2 free questions to test it. Part of the MLA-C02 study guide.
Ingestion questions describe where training data lives today and ask how to feed it to SageMaker AI with the least copying, cost or delay.
Where training data lives
Store
Fits
Amazon S3
The default for training data and model artifacts; cheap and durable
FSx for Lustre linked to S3
Very fast, repeated reads for large training jobs; lazy-loads from S3
Amazon EFS
Data already on a shared file system; the job reads in place (needs a VPC subnet that reaches it)
DynamoDB, RDS, Redshift
Source systems; export or unload to S3 for training rather than reading during training
A DynamoDB export to S3 reads from point-in-time recovery data, so it uses no read capacity and gives a consistent snapshot.
SageMaker AI input modes
File mode copies the whole dataset to the instance before training starts. Simple, but slow for very large data.
Fast File mode streams S3 objects on demand while showing them as files, so training starts quickly with no code change.
Pipe mode streams data from S3 to the algorithm; it needs code or algorithms that read a stream.
Distribution:FullyReplicated sends all data to each instance; ShardedByS3Key splits files across instances for distributed training.
Formats
CSV (label in the first column, no header, for many built-in algorithms) and RecordIO-protobuf are common for built-in algorithms; some also read Parquet or JSON Lines.
Columnar Parquet suits Spark and data preparation; JSON Lines is the usual format for fine-tuning data in Bedrock.
Images often use manifest files (augmented manifest) that list S3 objects and labels.
Moving data in
AWS DataSync copies files from on-premises or other clouds to S3 or EFS.
Glue and EMR transform and land data in S3.
Athena or Redshift UNLOAD produce training extracts as Parquet.
Common traps
Copying a huge dataset to local storage when Fast File mode or FSx for Lustre would start sooner.
Scanning a production DynamoDB table for training data. Export to S3.
A nightly copy from EFS to S3 when the training job can read EFS directly.
A pet insurer keeps six years of policy and claims records in an Amazon DynamoDB table that serves customer-facing apps around the clock.
A data scientist needs a complete copy of that table in Amazon S3 each night to train a claims-fraud model. The copy must reflect one consistent point in time, and building it must not reduce the read capacity the live apps depend on.
Which solution meets these requirements?
Choose one answer.
AA. Turn on point-in-time recovery, run a full export of the table to Amazon S3 each night, and convert the output to Parquet with AWS Glue.
BB. Run an AWS Glue job that scans the table through the DynamoDB connector every night and writes Parquet files to Amazon S3.
CC. Run a SageMaker Processing job that pages through the table with Scan operations and writes CSV files to Amazon S3 each night.
DD. Enable DynamoDB Streams on the table, and deliver every change through Amazon Data Firehose to Amazon S3 so that the nightly training job can read it.
Show the answer and explanation
Answer: A
A. Right: Correct. A full export reads from the point-in-time backup, so it uses no read capacity and does not affect the live table, and it captures the table as of one chosen time. Glue then converts the DynamoDB JSON output to Parquet for training. Learn more: DynamoDB data export to Amazon S3: how it works (opens in a new tab)
B. Wrong: A full Scan reads every item through the live table's read capacity, competing with customer traffic. Items are read over the course of the job, so the copy does not represent a single moment in time. Learn more: Scan operation in DynamoDB (opens in a new tab)
C. Wrong: Paginated scans have the same drawbacks: they consume read capacity and do not capture one point in time. The team would also maintain pagination and retry code that a managed export already handles.
A full DynamoDB export to Amazon S3 reads from a point-in-time backup, so it does not use the table's read capacity and gives one consistent snapshot. The export requires point-in-time recovery to be enabled on the table. Scans load the live table and streams only capture new changes, so neither gives the nightly snapshot the team needs.
A dental chain stores about 9 TB of anonymized X-ray images and their labels in Amazon EFS. Analysts and SageMaker notebooks already mount this file system, and the images are organized in a folder tree the team wants to keep.
The chain's data science team plans to train an image classifier with a SageMaker training job in the same VPC. They want to avoid copying the images into another store before each run, and they need the job to read the files directly.
Which approach meets these requirements?
Choose one answer.
AA. Use AWS DataSync to copy the EFS file system into an Amazon S3 bucket every night, and point the training job's input channel at that bucket.
BB. Set the training channel to the EFS file system as a file system data source, and run the job in a subnet that can reach the file system.
CC. Copy the folder tree from a notebook instance to the training container with a shell script before each job starts, using the instance's local disk.
DD. Move the images into an Amazon DynamoDB table with one item per file, and read them from the table inside the training script.
B. Right: Correct. SageMaker AI can mount an Amazon EFS file system as a training data source and then start the training script, so the images are read in place. The training job must connect to a VPC that can reach the file system. Learn more: Setting up training jobs to access datasets (opens in a new tab)
C. Wrong: Copying the whole tree on every run adds time and depends on each notebook having a complete copy. The training job also would not benefit from the shared file system.
D. Wrong: DynamoDB items are capped in size, so large image files do not fit well, and reading 9 TB through item requests is slow and costly. The file system already holds the data in the right form.
Explanation
SageMaker AI training can use an Amazon EFS file system as a data source, so the job reads the images in place without a nightly copy. The job must run in a VPC subnet that can reach the file system. Copying the data to S3 or local disks adds delay and duplicates storage, and DynamoDB is a poor fit for large image files.
Want more on Ingesting and storing ML data? The 5 full-length practice sets have 11 more Ingesting and storing ML data questions, 325 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →