aws-cdk-neuronx-patterns
Version:
> [!WARNING] > This library is experimental module.
121 lines (120 loc) • 3.5 kB
TypeScript
import { Size } from "aws-cdk-lib";
import * as batch from "aws-cdk-lib/aws-batch";
import * as ec2 from "aws-cdk-lib/aws-ec2";
import { ContainerImage } from "aws-cdk-lib/aws-ecs";
import { IBucket } from "aws-cdk-lib/aws-s3";
import { Construct } from "constructs";
import { INeuronxInstanceType, Model } from "../neuronx";
/**
* Compile runtime.
*/
export interface INeuronxContainerImage {
/**
* An image of the container where the compile job is executed.
*/
readonly image: ContainerImage;
/**
* Neuronx version included in container image.
*/
readonly sdkVersion: string;
}
/**
* Props of NeuronxCompiler.
*/
export interface NeuronxCompilerProps {
/**
* VPC in which this will launch compile worker instance.
*/
readonly vpc: ec2.IVpc;
/**
* The bucket to upload compiled artifacts.
*/
readonly bucket: IBucket;
/**
* Secrets to pass to the container.
*/
readonly secrets?: {
[key: string]: batch.Secret;
};
/**
* S3 Prefix that compiled artifact uploaded.
* This property is not depends on compile job finish.
*/
readonly artifactS3Prefix: string;
/**
* The instance type of compile worker instance.
*/
readonly neuronxInstanceType: INeuronxInstanceType;
/**
* The model to be compiled.
*/
readonly model: Model;
/**
* An image of the container where the compile job is executed.
*/
readonly image: INeuronxContainerImage;
readonly command?: string[];
/**
* The root volume of worker instance.
* @default - N bilion parameters * 5GiB EBS
*/
readonly volumeSize?: Size;
/**
* Whether or not to use spot instances. Spot instances are less expensive EC2 instances that can be reclaimed by EC2 at any time; your job will be given two minutes of notice before reclamation.
*
* @default false
*/
readonly spot?: boolean;
/**
* The VPC Subnets this Compute Environment will launch instances in.
*
* @default - new subnets will be created
*/
readonly vpcSubnets?: ec2.SubnetSelection;
/**
* 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;
};
}
export interface NeuronxCompiledModel {
readonly compileTimeInstanceType: INeuronxInstanceType;
/**
* The bucket to upload compiled artifacts.
*/
readonly bucket: IBucket;
/**
* S3 URL that compiled artifact uploaded.
*/
readonly s3Uri: string;
/**
* S3 prefix that compiled artifact uploaded.
*/
readonly s3Prefix: string;
/**
* The model name.
*/
readonly modelName: string;
readonly weightSize: Size;
}
/**
* Neuronx compiler construct.
* Compile the model to work with Inferentia2 and Trainium1 and upload it to an S3 bucket.
*/
export declare class NeuronxCompiler extends Construct {
private compiledModel?;
private readonly entrypoint;
private readonly jobDefinition;
private readonly jobQueue;
private readonly artifactS3Prefix;
private readonly weightSize;
private readonly neuronxInstanceType;
private readonly model;
private readonly bucket;
constructor(scope: Construct, id: string, props: NeuronxCompilerProps);
compile(): NeuronxCompiledModel;
}