UNPKG

aws-cdk-neuronx-patterns

Version:
107 lines (106 loc) 3.96 kB
import * as ecs from "aws-cdk-lib/aws-ecs"; import { ApplicationListener, ApplicationLoadBalancer, ApplicationTargetGroup } from "aws-cdk-lib/aws-elasticloadbalancingv2"; import { Construct } from "constructs"; import { ApplicationLoadBalancedNeuronxServiceProps, NeuronxTaskDefinition, NeuronxTaskDefinitionPropsBase } from "../base/aws-ecs-patterns"; import { IVllmInferenceNeuronxImage } from "../base/neuronx"; import { INeuronxContainerImage } from "../base/neuronx-compiler"; import { VllmNxdInferenceCompiledModel } from "./vllm-nxd-inference-compiler"; export interface VllmNxdInferenceImageOptions { readonly vllmGitBranch?: string; readonly vllmGitCommitHash?: string; } /** * Base class for VllmNxdInferenceImage. */ export declare abstract class VllmNxdInferenceEcsImageBase implements INeuronxContainerImage { /** * The container image. */ abstract readonly image: ecs.ContainerImage; /** * The neuronx SDK version. */ readonly neuronSdkVersion: string; constructor(neuronxImage: IVllmInferenceNeuronxImage); } /** * Inference ECS container image for vLLM on NxD Inference. * This image uses the official AWS Neuron Deep Learning Containers which come with vLLM pre-installed. * * @example new VllmNxdInferenceEcsImage(VllmInferenceNeuronxImage.LATEST) */ export declare class VllmNxdInferenceEcsImage extends VllmNxdInferenceEcsImageBase { readonly image: ecs.ContainerImage; /** * Create a VllmNxdInferenceImage from a custom neuronx image. * This will build a container image using a Dockerfile that installs vLLM from source. * * @example * new VllmNxdInferenceEcsImage(VllmInferenceNeuronxImage.LATEST) */ constructor(vllmInferenceNeuronxImage?: IVllmInferenceNeuronxImage); } /** * Task definition for VllmNxdInference. */ export interface VllmNxdInferenceTaskDefinitionProps extends NeuronxTaskDefinitionPropsBase { /** * The model to be compiled. */ readonly compiledModel: VllmNxdInferenceCompiledModel; /** * The image to be used for the container. * @default - latest VllmNxdInferenceImage */ readonly image?: VllmNxdInferenceEcsImageBase; /** * The environment variables to pass to the container. * This is only applicable when using container runtime. * * @default - No environment variables. */ readonly environment?: { [key: string]: string; }; } /** * Task definition for VllmNxdInference. */ export declare class VllmNxdInferenceTaskDefinition extends NeuronxTaskDefinition { constructor(scope: Construct, id: string, props: VllmNxdInferenceTaskDefinitionProps); } /** * Props for ApplicationLoadBalancedVllmNxDInferenceService. */ export interface ApplicationLoadBalancedVllmNxDInferenceServiceProps extends ApplicationLoadBalancedNeuronxServiceProps { } /** * ApplicationLoadBalancedVllmNxDInferenceService is a wrapper of ApplicationLoadBalancedNeuronxServiceBase. * It provides a simple way to deploy vLLM on NxD Inference. * @example * const compiler = new VllmNxdInferenceCompiler(this, "Compiler", { * vpc, * bucket, * model: Model.fromHuggingFace("example/example-7b-chat"), * }); * const compiledModel = compiler.compile(); * const taskDefinition = new VllmNxdInferenceTaskDefinition( * this, * "TaskDefinition", * { * vpc, * compiledModel, * }, * ); * new ApplicationLoadBalancedVllmNxDInferenceService(this, "Service", { * taskDefinition, * }); */ export declare class ApplicationLoadBalancedVllmNxDInferenceService extends Construct { readonly loadBalancer: ApplicationLoadBalancer; readonly listener: ApplicationListener; readonly targetGroup: ApplicationTargetGroup; readonly service: ecs.Ec2Service; readonly taskDefinition: ecs.Ec2TaskDefinition; constructor(scope: Construct, id: string, props: ApplicationLoadBalancedVllmNxDInferenceServiceProps); }