LIVE · Thursday 3 December

Deploy a Custom Decision Model in Your AWS VPC: ECS on GPU Instances or SageMaker with PrivateLink

Run the model on GPU-backed ECS in private subnets, or host it on SageMaker and invoke it through a runtime interface endpoint. Keep the container stateless, so that network isolation blocks nothing that the model needs.

By Nick11 min read

To deploy a custom decision model in your VPC on AWS, run its container on Amazon ECS with GPU-backed EC2 instances in private subnets behind an internal load balancer. Alternatively, host it on a SageMaker custom inference container and invoke it privately through a SageMaker Runtime interface endpoint (AWS PrivateLink). Fargate is not an option for a GPU model, because AWS lists the gpu task parameter as invalid on Fargate. Turn on SageMaker network isolation only when the container needs no outbound calls, since isolation also blocks your databases and feature services.

"In our VPC" can mean four different requirements, and AWS meets each one with a different feature.

Teams often use one phrase for several goals. Security reviews go faster when the team names which goal it means before choosing a service. AWS documents each goal separately, and the features do not substitute for each other.

Requirement AWS feature What it does not do
Model compute runs in your private subnets ECS on EC2 GPU instances, internal NLB Does not provide a managed SageMaker endpoint
Callers reach a managed endpoint privately SageMaker Runtime interface endpoint Does not move SageMaker hosting into your VPC
The model reaches your VPC resources VpcConfig on SageMaker CreateModel Does not change the invocation path
The container makes no network calls at all EnableNetworkIsolation=True Blocks your VPC resources as well as the internet

The second and third rows are easy to confuse. AWS's guide to SageMaker VPC access states that "specifying a VPC configuration alone doesn't change the invocation path." Callers still need a VPC endpoint to invoke the model privately. In the other direction, the interface endpoint gives callers a private path in, but the container cannot reach your VPC resources without a VPC configuration.

The fourth row is the strictest one. According to AWS, an isolated container "can't make any outbound network calls to any service, including Amazon S3," and it receives no AWS credentials. SageMaker still downloads the model artifacts with your execution role, outside the container. When isolation is combined with a VPC, those downloads run through your subnet, but the container still cannot reach "any resource within your VPC or on the internet."

A decision model works with every option when the application owns state, permissions and fallback.

A decision model differs from a chat model in a way that makes private hosting easier. It scores a fixed list of options instead of writing text. Parsec's TOD is a public example of the type. Parsec's TOD page describes a model that reads text, images, policy and task state, and then ranks the next action from a list of allowed actions. It generates no free text and invents no actions.

The repo describes the interface as predict(state, options, question, images). The call returns one probability per supplied option, and the probabilities sum to 1. The repo states that it was measured with up to 300 options. A request therefore carries everything that the model needs: the current state, the question and the allowed options. The response is a list of scores.

That contract suggests a clean split of duties, which has four parts:

  1. The application assembles the state from its own databases and feature services before it calls the model, so that the container needs no database access.
  2. The application filters the options to the actions that the current user is allowed to take, so that authorization stays outside the model.
  3. The application applies a confidence threshold to the scores and sends low-confidence turns to a fallback model. Parsec's TOD page describes the same pattern as a confidence gate that passes the turn unchanged to the parent LLM.
  4. The application executes the chosen action itself, because the model only returns probabilities.

With this split, the container needs only its weights and its inputs. Network isolation then blocks nothing that inference requires, so it can be turned on safely. Deployment alone also does not require more fine-tuning when an existing model already meets the workload.

The model's artifacts, licence and hardware set the container requirements before any networking work starts.

The public TOD release shows what a pinned decision-model container has to hold. According to the model card and repo, the release consists of LoRA adapters on google/gemma-4-12B-it plus a ModernBERT-base retriever. The base weights are not included. Users must accept the Gemma 4 licence before they download them. The adapters are listed as Apache-2.0, while the base model stays under the Gemma 4 terms.

Parsec's TOD page labels its results "TOD decision v1 release evaluation, 29 September 2026." Pin the container to that release and record the exact base, adapter and retriever files that you package. Every later test then refers to one known set of weights.

The repo also gives two serving rules that change accuracy, not just speed. It says to use chunked_eager or eager attention instead of sdpa. It also warns against bitsandbytes int8, which it says flips 8% of picks. Serve in bf16, which is the precision behind both published latency figures.

Hardware is where the two published latency sets differ, so each figure stays with its own setup:

  • Parsec's TOD page reports a median model forward pass of 69 ms and a p95 of 121 ms on one H100 80GB in bf16, excluding provider look-ups.
  • The repo reports a p50 of 542 ms for up to 16 options and 182 ms for 50 to 174 options with the retriever, on an A100-40G in bf16 at batch 1.

No CPU-only latency has been published for the retriever or for the full model. The compact retriever should not be treated as a CPU route until somebody measures it. The smallest GPU that either source documents has 40 GB. The ECS GPU guide lists g6e.xlarge with one GPU and 48 GiB of GPU memory, and AWS says that G6e uses NVIDIA L40S GPUs. TOD has not been benchmarked on L40S, so that pairing needs its own test.

The ECS route keeps the model compute in your private subnets, but it needs EC2 GPU instances and seven endpoints.

AWS's Prescriptive Guidance pattern for private container access places ECS tasks behind an internal Network Load Balancer with IP targets. It exposes the service through PrivateLink as a VPC endpoint service, which other VPCs can then reach through their own endpoints. The pattern uses Fargate and adds a NAT gateway in each Availability Zone. A GPU model needs two changes to it.

First, replace Fargate with EC2 container instances. The ECS GPU guide supports the g4, g5, g6, g6e, p4d and p5 families, among others. It provides a GPU-optimized AMI with NVIDIA drivers and a Docker GPU runtime. The guide asks you to set ECS_ENABLE_GPU_SUPPORT=true in the agent configuration and to declare the GPU count in the task definition. It also asks you to set NVIDIA_DRIVER_CAPABILITIES if the image does not use an NVIDIA CUDA base image.

Second, remove the NAT gateways and add VPC endpoints, so that the subnets have no route to the internet. AWS's ECS and ECR guides require these endpoints for EC2-hosted tasks:

  • com.amazonaws.<region>.ecs, ecs-agent and ecs-telemetry, which let the container agent reach ECS. AWS warns that traffic uses public endpoints if any of the three are missing.
  • com.amazonaws.<region>.ecr.api and ecr.dkr, with private DNS enabled on ecr.dkr, which let the instances pull the image.
  • The S3 gateway endpoint com.amazonaws.<region>.s3, which is needed because ECR stores image layers in S3.
  • com.amazonaws.<region>.logs, which is needed for the awslogs driver when the VPC has no internet gateway.

Each endpoint's security group must allow inbound TCP 443 from the private subnets. The instances must run ECS agent 1.25.1 or later. The endpoints also do not serve cross-Region requests. Stage the base weights, adapters and retriever in S3 or bake them into the image, because the instances cannot reach Hugging Face without egress.

The SageMaker route gives you a managed endpoint that callers reach privately, with a strict container contract.

SageMaker runs your image as docker run <image> serve. The container must listen on port 8080, accept POST /invocations and answer /ping. It must accept connections within 250 ms and respond within 60 seconds. GPU images must be compatible with nvidia-docker and must not bundle NVIDIA drivers.

Model artifacts arrive through ModelDataUrl, which must point to a tar.gz file that SageMaker unpacks into /opt/ml/model before the container starts. AWS recommends uncompressed model deployment for large models. Loading time matters here. If the container does not answer /ping with 200 consistently during the 8 minutes after startup, the launch fails and CreateEndpoint fails. AWS also recommends a /ping handler that checks that the model has loaded and that a small test prediction succeeds.

Private access then takes three settings. Set VpcConfig on CreateModel with at least two subnets in different Availability Zones, which AWS requires even for a single instance. Add an S3 endpoint, because model containers in a VPC without internet access cannot reach S3 without one. Then create the SageMaker Runtime interface endpoint for callers.

With private DNS enabled, the standard hostname runtime.sagemaker.<region>.amazonaws.com resolves to the endpoint. The endpoint must be active in each caller's Availability Zone, or private DNS resolution can fail. An endpoint policy can allow sagemaker:InvokeEndpoint on one named endpoint only. If you use a custom IAM policy instead of AmazonSageMakerFullAccess, it needs the ec2:CreateNetworkInterface family of permissions that AWS lists.

Network isolation blocks only the dependencies that a stateless decision container should not call.

Each dependency behaves differently under the three hosting settings, according to AWS's descriptions of each mode.

Dependency ECS private subnets SageMaker with VpcConfig SageMaker with isolation
Database or feature service Reachable through security groups Reachable through the ENI Blocked
Model download from Hugging Face Blocked without NAT Blocked without NAT Blocked
Weights staged in S3 Through the S3 gateway endpoint Through the S3 endpoint Fetched by SageMaker, not the container
Fallback LLM Called by the application Called by the application Called by the application

The design rule follows from the table. If the application assembles state and calls the fallback model, the container's only dependency is its weights. In that case, isolation removes a path for data to leave without blocking anything that inference needs. If the container must look up features itself, use VpcConfig without isolation, and limit its security group to the feature service.

Decide in advance how the system behaves when a dependency is down. When the feature service fails, the application should not call the model with partial state. When the model endpoint fails its health check or times out, the application should send the turn to the fallback model.

Parsec publishes the model and a hosted price, but it does not publish a tested VPC deployment.

Parsec's TOD page lists a hosted price of $0.30 per 1,000 decisions, flat regardless of context length and separate from parent-model costs. The page does not describe deployment options, and Parsec's site does not state an SLA, on-premises or edge hosting for TOD. Its decision-models page offers to tune models on a customer's own decisions, with no published price. Neither ECS nor SageMaker has a published, tested TOD configuration from Parsec. A team that hosts TOD privately therefore builds its own configuration from AWS's documentation and the repo's serving notes. The only VPC option on Parsec's site belongs to its separate coding-agent product.

A fixed ECS deployment costs about $2,821 a month before traffic charges.

The example assumes two g6e.xlarge instances, one in each of two Availability Zones, running for 730 hours a month in US East (N. Virginia). AWS's on-demand price on November 24, 2026 was $1.861 an hour, so the instances cost $2,717.06.

The six interface endpoints (ecs, ecs-agent, ecs-telemetry, ecr.api, ecr.dkr and logs) in two zones cost $87.60 at $0.01 per endpoint per zone per hour. AWS's PrivateLink pricing adds $0.01 per GB processed. An internal NLB adds $16.43 in hourly charges, plus $0.006 per NLCU-hour. The S3 gateway endpoint is left out of the total.

The fixed total is about $2,821 a month. At the hosted rate of $0.30 per 1,000 decisions, the same sum pays for about 9.4 million hosted decisions. The comparison holds only on these assumptions, and the hosted service runs outside your VPC. How many decisions per second one L40S instance can serve has not been measured. Measure it before you size the fleet.

Seven tests should pass before the deployment takes production traffic.

Run these checks in the target account and Region, and record the results for the exact setup that you tested:

  1. Confirm the cloud, Region, VPC and two private subnets in different Availability Zones, and confirm that the chosen GPU instance type is available in both.
  2. Resolve runtime.sagemaker.<region>.amazonaws.com or the internal NLB name from a caller in each zone, and confirm that it returns private IP addresses.
  3. From inside the container, try to reach a public address, S3 and a VPC database, and confirm that denied egress blocks each call that the design intends to block.
  4. Restart the service and confirm that health checks pass within the 8-minute window, with a test prediction inside the /ping handler.
  5. Deploy a second version, shift traffic to it, and roll back to the first version without dropping requests.
  6. Replay a sample of real decisions and compare the scores and the deferral rate with the results from your evaluation environment.
  7. Measure latency and cost per decision under expected peak load on this hardware, and publish only those measured figures.

Support terms, response times and responsibility for patching belong in a written scope with the model vendor. None of them follows from the architecture.

Sources

More in Chips & Compute

All Chips & Compute →