Skip to main content

NeMo Eval: Evaluation Utilities for LLM and VLM models

Project description

Overview

The NeMo Framework is NVIDIAโ€™s GPU-accelerated, end-to-end training platform for large language models (LLMs), multimodal models, and speech models. It enables seamless scaling of both pretraining and post-training workloads, from a single GPU to clusters with thousands of nodes, supporting Hugging Face/PyTorch and Megatron models. NeMo includes a suite of libraries and curated training recipes to help users build models from start to finish.

The Eval library ("NeMo Eval") is a comprehensive evaluation module within the NeMo Framework for LLMs. It offers streamlined deployment and advanced evaluation capabilities for models trained using NeMo, leveraging state-of-the-art evaluation harnesses.

image

๐Ÿš€ Features

  • Multi-Backend Deployment: Supports PyTriton and multi-instance evaluations using the Ray Serve deployment backend
  • Comprehensive Evaluation: Includes state-of-the-art evaluation harnesses for academic benchmarks, reasoning benchmarks, code generation, and safety testing
  • Adapter System: Features a flexible architecture with chained interceptors for customizable request and response processing
  • Production-Ready: Supports high-performance inference with CUDA graphs and flash decoding
  • Multi-GPU and Multi-Node Support: Enables distributed inference across multiple GPUs and compute nodes
  • OpenAI-Compatible API: Provides RESTful endpoints aligned with OpenAI API specifications

๐Ÿ”ง Install NeMo Eval

Prerequisites

  • Python 3.10 or higher
  • CUDA-compatible GPU(s) (tested on RTX A6000, A100, H100)
  • NeMo Framework container (recommended)

Use pip

For quick exploration of NeMo Eval, we recommend installing our pip package:

pip install nemo-eval

Use Docker

For optimal performance and user experience, use the latest version of the NeMo Framework container. Please fetch the most recent $TAG and run the following command to start a container:

docker run --rm -it -w /workdir -v $(pwd):/workdir \
  --entrypoint bash \
  --gpus all \
  nvcr.io/nvidia/nemo:${TAG}

Use uv

To install NeMo Eval with uv, please refer to our Contribution guide.

๐Ÿš€ Quick Start

1. Deploy a Model

from nemo_eval.api import deploy

# Deploy a NeMo checkpoint
deploy(
    nemo_checkpoint="/path/to/your/checkpoint",
    serving_backend="pytriton",  # or "ray"
    server_port=8080,
    num_gpus=1,
    max_input_len=4096,
    max_batch_size=8
)

2. Evaluate the Model

from nvidia_eval_commons.core.evaluate import evaluate
from nvidia_eval_commons.api.api_dataclasses import ApiEndpoint, EvaluationConfig, EvaluationTarget

# Configure evaluation
api_endpoint = ApiEndpoint(
    url="http://0.0.0.0:8080/v1/completions/",
    model_id="megatron_model"
)
target = EvaluationTarget(api_endpoint=api_endpoint)
config = EvaluationConfig(type="gsm8k", output_dir="results")

# Run evaluation
results = evaluate(target_cfg=target, eval_cfg=config)
print(results)

๐Ÿ“Š Support Matrix

Checkpoint Type Inference Backend Deployment Server Evaluation Harnesses Supported
NeMo FW checkpoint via Megatron Core backend Megatron Core in-framework inference engine PyTriton (single and multi node model parallelism), Ray (single node model parallelism with multi instance evals) lm-evaluation-harness, simple-evals, BigCode, BFCL, safety-harness, garak

๐Ÿ—๏ธ Architecture

Core Components

1. Deployment Layer

  • PyTriton Backend: Provides high-performance inference through the NVIDIA Triton Inference Server, with OpenAI API compatibility via a FastAPI interface. Supports model parallelism across single-node and multi-node configurations. Note: Multi-instance evaluation is not supported.
  • Ray Backend: Enables multi-instance evaluation with model parallelism on a single node using Ray Serve, while maintaining OpenAI API compatibility. Multi-node support is coming soon.

2. Evaluation Layer

  • NVIDIA Eval Factory: Provides standardized benchmark evaluations using packages from NVIDIA Eval Factory, bundled in the NeMo Framework container. The lm-evaluation-harness is pre-installed by default, and additional tools listed in the support matrix can be added as needed. For more information, see the documentation.

  • Adapter System: Flexible request/response processing pipeline with Interceptors that provide modular processing:

    • Available Interceptors: Modular components for request/response processing
      • SystemMessageInterceptor: Customize system prompts
      • RequestLoggingInterceptor: Log incoming requests
      • ResponseLoggingInterceptor: Log outgoing responses
      • ResponseReasoningInterceptor: Process reasoning outputs
      • EndpointInterceptor: Route requests to the actual model

๐Ÿ“– Usage Examples

Basic Deployment with PyTriton as the Serving Backend

from nemo_eval.api import deploy

# Deploy model
deploy(
    nemo_checkpoint="/path/to/checkpoint",
    serving_backend="pytriton",
    server_port=8080,
    num_gpus=1,
    max_input_len=8192,
    max_batch_size=4
)

Basic Evaluation

from nvidia_eval_commons.core.evaluate import evaluate
from nvidia_eval_commons.api.api_dataclasses import ApiEndpoint, ConfigParams, EvaluationConfig, EvaluationTarget
# Configure Endpoint
api_endpoint = ApiEndpoint(
    url="http://0.0.0.0:8080/v1/completions/",
    model_id="megatron_model"
)
# Evaluation target configuration
target = EvaluationTarget(api_endpoint=api_endpoint)
# Configure EvaluationConfig with type, number of samples to evaluate on, etc.
config = EvaluationConfig(type="gsm8k",
            output_dir="results",
            params=ConfigParams(
                    limit_samples=10
                ))

# Run evaluation
results = evaluate(target_cfg=target, eval_cfg=config)

Use Adapters

The example below demonstrates how to configure an Adapter to provide a custom system prompt. Requests and responses are processed through interceptors, which are automatically selected based on the parameters defined in AdapterConfig.

from nemo_eval.utils.api import AdapterConfig

# Configure adapter for reasoning
adapter_config = AdapterConfig(
    api_url="http://0.0.0.0:8080/v1/completions/",
    use_reasoning=True,
    end_reasoning_token="</think>",
    custom_system_prompt="You are a helpful assistant that thinks step by step.",
    max_logged_requests=5,
    max_logged_responses=5
)

# Run evaluation with adapter
results = evaluate(
    target_cfg=target,
    eval_cfg=config,
    adapter_cfg=adapter_config
)

Deploy with Multiple GPUs

# Deploy with tensor parallelism or pipeline parallelism
deploy(
    nemo_checkpoint="/path/to/checkpoint",
    serving_backend="pytriton",
    num_gpus=4,
    tensor_parallelism_size=4,
    pipeline_parallelism_size=1,
    max_input_len=8192,
    max_batch_size=8
)

Deploy with Ray

# Deploy using Ray Serve
deploy(
    nemo_checkpoint="/path/to/checkpoint",
    serving_backend="ray",
    num_gpus=2,
    num_replicas=2,
    num_cpus_per_replica=8,
    server_port=8080,
    include_dashboard=True,
    cuda_visible_devices="0,1"
)

๐Ÿ“ Project Structure

Eval/
โ”œโ”€โ”€ src/nemo_eval/           # Main package
โ”‚   โ”œโ”€โ”€ api.py               # Main API functions
โ”‚   โ”œโ”€โ”€ package_info.py      # Package metadata
โ”‚   โ”œโ”€โ”€ adapters/            # Adapter system
โ”‚   โ”‚   โ”œโ”€โ”€ server.py        # Adapter server
โ”‚   โ”‚   โ”œโ”€โ”€ utils.py         # Adapter utilities
โ”‚   โ”‚   โ””โ”€โ”€ interceptors/    # Request/response interceptors
โ”‚   โ””โ”€โ”€ utils/               # Utility modules
โ”‚       โ”œโ”€โ”€ api.py           # API configuration classes
โ”‚       โ”œโ”€โ”€ base.py          # Base utilities
โ”‚       โ””โ”€โ”€ ray_deploy.py    # Ray deployment utilities
โ”œโ”€โ”€ tests/                   # Test suite
โ”‚   โ”œโ”€โ”€ unit_tests/          # Unit tests
โ”‚   โ””โ”€โ”€ functional_tests/    # Functional tests
โ”œโ”€โ”€ tutorials/               # Tutorial notebooks
โ”œโ”€โ”€ scripts/                 # Reference nemo-run scripts
โ”œโ”€โ”€ docs/                    # Documentation
โ”œโ”€โ”€ docker/                  # Docker configuration
โ””โ”€โ”€ external/                # External dependencies

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details on development setup, testing, and code style guidelines

๐Ÿ“„ License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

๐Ÿ“ž Support

๐Ÿ”— Related Projects


Note: This project is actively maintained by NVIDIA. For the latest updates and features, please check our releases page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nemo_eval-0.1.0rc2.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nemo_eval-0.1.0rc2-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file nemo_eval-0.1.0rc2.tar.gz.

File metadata

  • Download URL: nemo_eval-0.1.0rc2.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for nemo_eval-0.1.0rc2.tar.gz
Algorithm Hash digest
SHA256 0e37bd47e699e5cd987de6286c7c4d8b35b4da9b6eff113f79aa1daddcdd81ec
MD5 dce2551aa1e0162df63037e857d7b071
BLAKE2b-256 ed46bd0a40b8535f6f6244a16dc16bbb428ea35c34611dc519b9185a897b1fca

See more details on using hashes here.

File details

Details for the file nemo_eval-0.1.0rc2-py3-none-any.whl.

File metadata

  • Download URL: nemo_eval-0.1.0rc2-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for nemo_eval-0.1.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 54a2b76a281c20929ffc54ba53bc8ef20269a7f0980ad3ec23444872e8f8284b
MD5 313400602400dffe387462589a43dce2
BLAKE2b-256 fa3dc718c451928f0110728fc587779c674c61abbce1541f43aca67f48f3bd56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page