Real-Time Inference Data: The Final Puzzle for Model Improvement
Teams deploying foundation models in production environments face a dilemma. Real-time influx of domain-specific jargon, unexpected input formats, new product launches, and changes in user behavior cannot be covered by pre-curated datasets, yet there is a lack of a systematic pipeline to collect this data for model improvement. Amazon Web Services (AWS) has filled this gap by officially adding Amazon SageMaker HyperPod Data Capture as a feature in November 2024.
"Foundation models deployed on Amazon SageMaker HyperPod meet inputs that no pre-curated dataset covers: domain-specific jargon, unexpected formats, new products, and changing user behavior. Without a record of production inference data, teams can't detect drift, find failure patterns, or use real interactions to improve the model."
This feature automatically records inference requests and responses to Amazon S3, minimizing latency impact and having zero impact on model availability. It enables the implementation of a complete flywheel that proceeds from capture → analysis → labeling → fine-tuning → redeployment on a single HyperPod cluster.
Three-Tier Architecture: Capture Strategies for Different Purposes
HyperPod Data Capture provides three independent tiers that operate at different points along the request path. Within a single `dataCapture` block, desired combinations can be activated simultaneously.
| Tier | Recording Point | Stored Content | Main Use | Sampling Default |
|---|---|---|---|---|
| Tier 1 | Before and after model inference | Full payload (input/output) | Compliance, Model Monitor integration | 100% |
| Tier 2 | Proxy level | Only metadata (timestamp, latency, status code, etc.) | Traffic monitoring, cost optimization | 100% |
| Tier 3 | Proxy level | Full payload (input/output) | Reuse of training data, pattern analysis | 100% |
"Tiers 1 and 3 both store full payloads, so enabling both stores every record twice. Use Tier 1 for compliance and Model Monitor, Tier 2 when you only need traffic metadata, and Tier 3 when you intend to use the payloads."
The walkthrough will proceed with only Tier 3 activated. Tier 3 stores complete payloads, which means personal identifiable information (PII) such as names, addresses, and order numbers may be included. Therefore, before converting capture data into training data, protective measures such as sampling rate adjustment, AWS KMS encryption (`kmsKeyId`), S3 lifecycle rules, and Amazon Comprehend-based PII obfuscation must be implemented.
Five-Step Flywheel Walkthrough: New Product Adaptation for Appliance Support Router
AWS has publicly demonstrated the entire process in a reproducible form on a single HyperPod cluster. The scenario involves a customer support ticket router for an appliance distributor. It classifies tickets into six categories (`ProductFridge`, `ProductWasher`, `ProductOven`, `ProductDryer`, `ProductDishwasher`, `Other`) using `vLLM guided JSON decoding`.
- Real-time inference capture (S3) → Pattern analysis with Athena → Labeling with SQL policy → Fine-tuning with Training Operator → New endpoint side-by-side deployment
Steps 0-2: Setting Environment Variables, Staging Base Model, Configuring IAM Permissions
- Base Model: Qwen2.5-3B-Instruct — selected as a lightweight model that can be fine-tuned in about 1 minute on a single L40S (48 GB)
- Hardware: Inference `ml.g6e.8xlarge` (1 L40S), training `ml.g6e.xlarge` (1 L40S)
- Four essential IAM roles (if missing, capture files will not be created, but the endpoint will function normally):
- Mountpoint-S3 CSI driver role (IRSA): `s3:PutObject`, `s3:AbortMultipartUpload`, `s3:DeleteObject` + KMS decryption/data key creation/key retrieval permissions
- Inference Operator execution role: `s3:PutObject` + KMS permissions
- Training pod service account (`$TRAIN_SA`): Read base model and training data, write merged model (EKS Pod Identity)
- Athena: Read capture prefix + query result storage location
"If this is missing, the endpoint stays healthy and requests succeed, but no captures appear. See Mountpoint for Amazon S3 CSI driver."
Steps 3-5: Deploying Tier 3 Capture Activation, Confirming Pod Startup, Validating Capture
```yaml # Key: dataCapture.modelPod.enabled: true modelPod: enabled: true # sampling: 1.0 # default 100% # captureInput: true # default true # captureOutput: true # default true ```
The capture activation pod consists of four containers: `model`, `sidecar-reverse-proxy` (NGINX), `otel-collector`, `s3-uploader`. After `kubectl apply`, it takes about 5 minutes to reach Ready status, mostly due to weight download time.
Important: Inference requests must be sent to port 8081 (capture proxy) to be recorded. If requests are sent to port 8000, which the model directly listens to, they will bypass the proxy and will not be captured.
Capture files are stored in the path `{s3Uri}/{uniqueID}/pod/{variant}/{YYYY}/{MM}/{DD}/{HH}/` in `.jsonl` format, with each line following the SageMaker data capture format. The request and response bodies are stored Base64 encoded, so decoding and JSON parsing are required during analysis.
Steps 6-7: Athena Analysis → SQL Labeling → Fine-Tuning → Redeployment
1. Scan capture logs with Athena, discovering patterns where new product-related tickets (e.g., `ProductAirPurifier`) are incorrectly classified as `Other` 2. Assign correct labels to those records using SQL policy 3. The Training Operator (`HyperPodPyTorchJob`) performs fine-tuning on the second GPU 4. Deploy a new endpoint while maintaining capture functionality — completing the flywheel
Operational Considerations: Security, Cost, Governance Checklist
- Encryption: When specifying `kmsKeyId`, it is essential to allow `kms:Decrypt`, `kms:GenerateDataKey`, and `kms:DescribeKey` for the CSI driver role and Inference Operator role in the KMS key policy
- Cost Control: Storing all of Tier 3 may lead to a surge in S3 storage and PUT request costs → Adjust sampling rate (`sampling`), automate archiving/deletion with S3 Intelligent-Tiering/lifecycle
- PII Protection: It is recommended to insert Amazon Comprehend PII detection and obfuscation jobs in the capture to training pipeline
- Fault Isolation: Capture pipeline failures do not impact inference availability (zero impact), but if permissions for the CSI driver role are missing, silent failures may occur → Monitoring capture success rates with CloudWatch metrics and alarms is necessary
So What? Specific Implications for Developers, Companies, and Industries
Developer and ML Engineer Perspective
- Automate production data collection by simply adding a `dataCapture` block without modifying inference serving code
- Compatible with standard serving stacks like vLLM and TGI, low invasiveness with sidecar pattern
- No need to build separate ETL pipelines due to native integration with Athena, SQL, and Training Operator
Company and Platform Team Perspective
- Simultaneous operation of serving, training, and data collection on a single cluster and single orchestration (EKS) → Reduced infrastructure fragmentation, optimized TCO
- Governance separation for compliance (Tier 1), monitoring (Tier 2), and training (Tier 3)
- Natural support for A/B testing and canary releases through side-by-side deployment
Industry and Ecosystem Perspective
- A precedent for implementing the data flywheel concept at the managed infrastructure level → A benchmark for other clouds and on-premises
- Expected acceleration in closing the loop with real data while reducing dependence on synthetic data
Limitations and Future Challenges
- The walkthrough is based on synthetic data — performance and cost validation at the scale and diversity of real production traffic is necessary
- Limited to single GPU fine-tuning (about 1 minute) scenario — validation of Training Operator scaling during large model and distributed learning is needed
- Data governance pipelines such as PII obfuscation, sampling, and lifecycle must be built directly by users (managed features not provided)
- Documentation and automation tools need to be supplemented for operational constraints such as separation of ports 8081/8000
---
Summary: SageMaker HyperPod Data Capture provides an infrastructure-level flywheel primitive that transforms the "forget after deployment" pattern into "improve with data after deployment." The separation of purposes by tier, zero-impact capture, and native analysis and training linkage are strengths, but in real operations, security, cost, and governance layers must be designed separately. It is recommended to use the manifest, SQL, and synthetic datasets from the GitHub repository as a starting point to build a flywheel tailored to your domain.