ElasticModels are the models produced by TheStage AI ANNA: Automated Neural Networks Accelerator. ANNA allows you to control model size, latency and quality with a simple slider movement, routing different compression algorithms to different layers. For each model, we have produced a series of optimized models:
XL: Mathematically equivalent neural network, optimized with our DNN compiler.
L: Near lossless model, with less than 1% degradation obtained on corresponding benchmarks.
M: Faster model, with accuracy degradation less than 1.5%.
S: The fastest model, with accuracy degradation less than 2%.
Models can be accessed via TheStage AI Python SDK: ElasticModels, or deployed as Docker containers with REST API endpoints (see Deploy section).
Installation
System Requirements
Property
Value
GPU
H100, B200
Python Version
3.10-3.12
CPU
Intel/AMD x86_64
CUDA Version
12.9+
TheStage AI Access token setup
Install TheStage AI CLI and setup API token:
bash
1pip install thestage
2thestage config set --access-token <YOUR_ACCESS_TOKEN>
Elastic Models provides the same interface as HuggingFace Transformers. Here is an example of how to use the Mistral-Small-24B-Instruct-2501 model:
python
1import torch
2from transformers import AutoTokenizer
3from elastic_models.transformers import AutoModelForCausalLM
45# Currently we require to have your HF token6# as we use original weights for part of layers and7# model configuration as well8model_name ="mistralai/Mistral-Small-24B-Instruct-2501"9hf_token =''10device = torch.device("cuda")1112# Create mode13tokenizer = AutoTokenizer.from_pretrained(14 model_name, token=hf_token
15)16model = AutoModelForCausalLM.from_pretrained(17 model_name,18 token=hf_token,19 torch_dtype=torch.bfloat16,20 attn_implementation="sdpa",21 mode='S'22).to(device)23model.generation_config.pad_token_id = tokenizer.eos_token_id
2425# Inference simple as transformers library26prompt ="Describe basics of DNNs quantization."27messages =[28{29"role":"system",30"content":"You are a search bot, answer on user text queries."31},32{33"role":"user",34"content": prompt
35}36]3738chat_prompt = tokenizer.apply_chat_template(39 messages, add_generation_prompt=True, tokenize=False40)4142inputs = tokenizer(chat_prompt, return_tensors="pt")43inputs.to(device)4445with torch.inference_mode():46 generate_ids = model.generate(**inputs, max_length=500)4748input_len = inputs['input_ids'].shape[1]49generate_ids = generate_ids[:, input_len:]50output = tokenizer.batch_decode(51 generate_ids,52 skip_special_tokens=True,53 clean_up_tokenization_spaces=False54)[0]5556# Validate answer57print(f"# Q:\n{prompt}\n")58print(f"# A:\n{output}\n")
Quality Benchmarks
We have used the lm_eval library to validate the models. For each model size (S, M, L, XL), we have run the following tasks: MMLU, PIQA, Arc Challenge, Winogrande.
Quality Benchmarking
Quality Benchmark Results
Metric/Model Size
S
M
L
XL
Original
MMLU
78.7
78.8
79.1
79.3
79.1
PIQA
82.7
83.0
82.5
82.6
82.4
Arc Challenge
63.7
64.2
64.3
64.2
64.1
Winogrande
78.8
79.5
80.1
79.4
79.4
Datasets
MMLU: Measures model performance on a diverse set of multiple-choice questions covering various academic subjects, testing general knowledge and reasoning.
PIQA: Evaluates physical commonsense reasoning by asking the model to choose the most plausible solution to everyday physical problems.
Arc Challenge: Assesses scientific and factual reasoning using challenging multiple-choice questions from the AI2 Reasoning Challenge dataset.
Winogrande: Tests commonsense understanding and pronoun resolution through sentences requiring the model to identify the correct referent.
Metrics
Accuracy: Accuracy measures the proportion of model predictions that exactly match the correct answers across evaluation tasks.
Latency Benchmarks
We measured TPS (tokens per second) for each model size using 100 input tokens and 300 output tokens.
Latency Benchmarking
Latency Benchmark Results
Tokens per second for different model sizes on various GPUs.
GPU/Model Size
S
M
L
XL
Original
H100
87
82
69
57
43
B200
126
125
113
102
62
Benchmarking Methodology
The benchmarking was performed on a single GPU with a batch size of 1. Each model was run for 10 iterations, and the average latency was calculated.
Algorithm summary:
Load the Mistral-Small-24B-Instruct-2501 model with the specified size (S, M, L, XL, original).
Move the model to the GPU.
Prepare a sample prompt for text generation.
Run the model for a number of iterations (e.g., 10) and measure the time taken for each iteration. On each iteration:
Synchronize the GPU to flush any previous operations.
Record the start time.
Generate the text using the model.
Synchronize the GPU again.
Record the end time and calculate the TTFT and TPS for that iteration.
Calculate the average TTFT and TPS over all iterations.
Serving with Docker Image
For serving with Nvidia GPUs, we provide ready-to-go Docker containers with OpenAI-compatible API endpoints.
Using our containers you can set up an inference endpoint on any desired cloud/serverless providers as well as on-premise servers.
You can also use this container to run inference through TheStage AI platform.
Bearer token for authentication. Should match the AUTH_TOKEN set during container startup.
Content-Type: string
Must be set to application/json.
X-Model-Name: string
Specifies the model to use for generation. Format: mistral-small-24b-instruct-2501-<size>-bs<batch_size>, where <size> is one of S, M, L, XL, original and <batch_size> is the maximum batch size configured during container startup.