Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include LICENSE README.md
include superbench/benchmarks/model_benchmarks/deepseek_v2_lite/h100_bf16_v6.json
recursive-include superbench *.py *.j2 *.yaml
global-exclude *.py[cod] __pycache__
1 change: 1 addition & 0 deletions dockerfile/cuda13.0.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ WORKDIR ${SB_HOME}

ADD third_party third_party
RUN make -C third_party cuda
RUN make -C third_party deepseek_v2_lite

ADD . .
RUN python3 -m pip install --upgrade setuptools==78.1.0 && \
Expand Down
53 changes: 53 additions & 0 deletions docs/user-tutorial/benchmarks/model-benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,56 @@ Run GPT pretrain tasks with float32, float16, bfloat16 precisions with [Megatron
| megatron-gpt/${precision}_train_mem_allocated | GB | The average GPU memory allocated per iteration. |
| megatron-gpt/${precision}_train_max_mem_allocated | GB | The average maximum GPU memory allocated per iteration. |

## DeepSeek-V2-Lite Inference

### `deepseek-v2-lite-inference`

#### Introduction

Run BF16 generative inference with the official
[DeepSeek-V2-Lite](https://huggingface.co/deepseek-ai/DeepSeek-V2-Lite) checkpoint at revision
`604d5664dddd88a0433dbae533b7fe9472482de0` on one GPU with vLLM 0.31.0. Each measured batch sends
`batch_size` fixed-text prompts of `seq_len` tokens and greedily generates up to `max_new_tokens`
tokens per prompt, stopping early at EOS. The job downloads the checkpoint and verifies the SHA256 of
its 31.4GB of weight files. Before measurement, the engine also answers fixed check requests; after
the engine shuts down, an independent official-code reference checks those outputs. Any failed check
fails the run.

`numerical_policy` defaults to `strict_fp32`, which requires the checked tokens to match the greedy
tokens of an FP32 reference exactly. The supplied profile selects `h100_bf16_v6`, which also accepts a
different token if it is the engine's greedy choice and its FP32 probability gap is within a bound
calibrated from official BF16 execution on the same input. A pass therefore does not imply exact FP32
token agreement. `h100_bf16_v6` accepts only the supplied profile's parameters and has been validated
only on one H100 80GB GPU. The FP32 reference needs an 80GB-class GPU.

#### Usage

Run the [inference profile](../../../superbench/config/deepseek-v2-lite-inference.yaml) as its own
benchmark entry with one local process (`proc_num: 1`) in the SuperBench CUDA 13.0 image. Its build runs
`make -C third_party deepseek_v2_lite`, which installs vLLM 0.31.0 in `/opt/vllm` (`runtime_python`) and
the official-code reference in `/opt/deepseek-reference` (`reference_python`). Both stay outside the
SuperBench Python because vLLM pins its own PyTorch. Elsewhere, run that target or point both
parameters at equivalent environments.

`cache_root` is required. Each run downloads the checkpoint into a new directory under it and deletes
that model cache at the end, keeping the report and logs. If deletion fails, the cache path is logged
for manual removal. `duration` must be below 3600 seconds and covers the whole job, from download to
cache deletion.

#### Metrics

| Name | Unit | Description |
|---|---|---|
| deepseek-v2-lite-inference/bf16_inference_step_time | time (ms) | The average time to generate one measured batch. |
| deepseek-v2-lite-inference/bf16_inference_output_tokens_per_second | throughput (tokens/s) | Generated tokens divided by the total measured batch time. |
| deepseek-v2-lite-inference/bf16_inference_request_prefill_time | time (ms) | The average time from scheduling a request to its first token. |
| deepseek-v2-lite-inference/bf16_inference_ttft | time (ms) | The average time from request arrival to its first token, including queueing. |
| deepseek-v2-lite-inference/bf16_inference_decode_tpot | time (ms) | The average time per output token after the first; requests with one output token are excluded. |
| deepseek-v2-lite-inference/bf16_inference_input_token_count | count | The average number of prompt tokens per request. |
| deepseek-v2-lite-inference/bf16_inference_output_token_count | count | The average number of generated tokens per request, including EOS. |
| deepseek-v2-lite-inference/successful_requests | count | The number of completed measured requests. |
| deepseek-v2-lite-inference/actual_output_tokens | count | The total number of generated tokens in measured batches. |
| deepseek-v2-lite-inference/end_to_end_seconds | time (s) | The complete job time, including checkpoint download and cache deletion. |
| deepseek-v2-lite-inference/checkpoint_bytes | size (bytes) | The total size of the checkpoint weight files. |
| deepseek-v2-lite-inference/numerical_reference_positions | count | `h100_bf16_v6` only: the number of generated positions that passed the reference check. |
| deepseek-v2-lite-inference/numerical_fault_rejections | count | `h100_bf16_v6` only: the number of injected faults that the check rejected. |
3 changes: 2 additions & 1 deletion superbench/benchmarks/model_benchmarks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
from superbench.benchmarks.model_benchmarks.megatron_gpt3 import MegatronGPT
from superbench.benchmarks.model_benchmarks.pytorch_llama import PytorchLlama
from superbench.benchmarks.model_benchmarks.pytorch_mixtral import PytorchMixtral
from superbench.benchmarks.model_benchmarks.vllm_deepseek_v2_lite import DeepSeekV2LiteInference

__all__ = [
'ModelBenchmark', 'PytorchBERT', 'PytorchGPT2', 'PytorchCNN', 'PytorchLSTM', 'MegatronGPT', 'PytorchLlama',
'PytorchMixtral'
'PytorchMixtral', 'DeepSeekV2LiteInference'
]

if PytorchMixtral is not None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""DeepSeek-V2-Lite workers and helpers.

Workers run as ``python -m deepseek_v2_lite.<module>``, the inference ones in interpreters without SuperBench,
so every module except ``cache`` imports only the standard library and this package at load time.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""Bounded removal of one V2-Lite run's downloaded model cache."""

import subprocess
import sys
import time
from pathlib import Path

from superbench.common.utils import logger

FAILURE_CLEANUP_GRACE_SECONDS = 60
_REMOVE_TREE = 'import os, shutil, sys\nif os.path.exists(sys.argv[1]):\n shutil.rmtree(sys.argv[1])'


def remove_model_cache(cache: Path, deadline: float) -> None:
"""Delete one run's model cache before a monotonic deadline, keeping reports and logs.

A missing budget, an expired deletion or a SuperBench SIGTERM raises TimeoutError. Other
filesystem errors are logged so that a validated measurement is not discarded.
"""
start = time.monotonic()
remaining = deadline - start
if remaining <= 0:
raise TimeoutError('No time remains to remove the V2-Lite model cache at {}.'.format(cache))
try:
# A child process can be stopped and reaped at the deadline; an in-process rmtree cannot.
subprocess.run(
[sys.executable, '-c', _REMOVE_TREE, str(cache)],
timeout=remaining,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
except subprocess.TimeoutExpired as error:
raise TimeoutError('V2-Lite model cache cleanup exceeded the deadline at {}.'.format(cache)) from error
except TimeoutError:
# The SuperBench SIGTERM handler raises TimeoutError, an OSError subclass; keep it fatal.
raise
except subprocess.CalledProcessError as error:
logger.error('Failed to remove the V2-Lite model cache %s: %s', cache, error.output or error)
return
except OSError as error:
logger.error('Failed to remove the V2-Lite model cache %s: %s', cache, error)
return
logger.info('V2-Lite model cache cleanup completed for %s in %.1f seconds.', cache, time.monotonic() - start)


def remove_model_cache_after_failure(cache: Path, deadline: float) -> None:
"""Remove the cache of a failed run without replacing the run's original error.

Cleanup may run until the job deadline or for FAILURE_CLEANUP_GRACE_SECONDS, whichever ends later,
so a timed-out worker does not leave its checkpoint behind only because the budget is spent.
"""
try:
remove_model_cache(cache, max(deadline, time.monotonic() + FAILURE_CLEANUP_GRACE_SECONDS))
except TimeoutError as error:
logger.error('V2-Lite model cache cleanup did not finish after a failed run: %s', error)
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"status": "qualified",
"calibrated_contract": {
"method": "bf16-input-matched-probability-log-v6",
"status": "candidate-not-heldout-qualified",
"reference_only": true,
"model_id": "deepseek-ai/DeepSeek-V2-Lite",
"revision": "604d5664dddd88a0433dbae533b7fe9472482de0",
"profile": {
"batch_size": 8,
"seq_len": 512,
"max_new_tokens": 64
},
"top_k": 20,
"limits": {
"max_probability_error": 0.07284170527726544,
"relative_probability_mass_error": 0.13143301942660637,
"normalized_logprob_error": 7.25253417079409
},
"probability_slack": 1e-06,
"calibration_cases_sha256": "0f853d935a28e6b4fbcf2454d47e0bf6872aa94aea931494f46d9f84a9df393d",
"script_sha256": "2dd64484cb0e0cbc00d726899c0b716f2c6326eb95b33ac9e2a6bdfd8f016222",
"runtime_identity": {
"torch_version": "2.13.0+cu130",
"transformers_version": "4.46.3",
"gpu_name": "NVIDIA H100 80GB HBM3",
"reference_loader_sha256": "19539a42ea67dc369b41c5ba5078ff3725dcac163057664937aa32413b5a49d6",
"tf32_allowed": false,
"bf16_reduced_precision_reduction": true
},
"fp32_oracle": "full-prefix at every position; no reference KV cache",
"logprob_normalization": {
"atol_scale": 0.05,
"rtol_scale": 0.02
},
"qualification_offsets": [
0,
1024,
32768,
98304,
130560,
131584
],
"qualification_stream": {
"num_warmup": 2,
"num_steps": 256
},
"continuation_modes": [
"teacher-forced",
"fp32-greedy"
],
"reference_validation_required": true,
"input_matched_limit_rule": "reference calibration budget + input-matched BF16 reference deviation",
"input_matched_reference": "Official BF16 cached execution in configured shape-matched batches",
"reference_holdout_corpora": [
"retained-v5",
"fresh-v6"
],
"qualification_required": [
"different performance inputs",
"half-normalization faults",
"temperature faults",
"wrong-context faults",
"malformed/missing results"
],
"frozen_limits_sha256": "f0916bfcdbfdac1ea3c888305cc0cb9641756b29559b57640cb8cbb02ee56533"
},
"reference_validation": {
"report_sha256": "819ef3e6180130828c956d05a73b314244fcd142568dab2ba1b4153bf3386791",
"holdout_cases_sha256": "5c0cd12116cd876ffc01fcbd1d010e5df6226556705ec6701a0ea5ce3715631d",
"comparisons": 2176,
"non_anchor_comparisons": 1152
},
"qualification": [
{
"profile_offset": 0,
"requests_sha256": "5bf572df5e5874bfb2e1c30c5778ff3cd93250e7d029d87f6967cd7706db6f35",
"report_sha256": "210d10db88b5f0ce01957047532fabcfd95cd2ea22772e939648f08088766f0b",
"positive_positions": 536,
"negative_positions": 1073,
"near_tie_positions": 0
},
{
"profile_offset": 1024,
"requests_sha256": "b12aeb6af0bb65fbb762e38c775e15dfcf16362491a37c138df7e60599f2876b",
"report_sha256": "7395f7d9e989ddac14e5ea528af8bd24fef9f09215e99bb9700a1aab8a3bfd6c",
"positive_positions": 536,
"negative_positions": 1073,
"near_tie_positions": 0
},
{
"profile_offset": 32768,
"requests_sha256": "8f0b5215ed3f5a5752bfa8157b86110cb806d644233d3f312e88adae04d57d5a",
"report_sha256": "9ffdf898774506893027f1991bb38f4f88b47318a9472dd28012a63b493249ed",
"positive_positions": 536,
"negative_positions": 1073,
"near_tie_positions": 0
},
{
"profile_offset": 98304,
"requests_sha256": "d352a40c0e315e01222910249f0de56de8185b544a1c96fb1629f1efa73b8c54",
"report_sha256": "5a6d0675c3a9ee5ce1e6a34224c041c7e315fa3c0e15d44ea3d8f52294a0f3b9",
"positive_positions": 536,
"negative_positions": 1073,
"near_tie_positions": 0
},
{
"profile_offset": 130560,
"requests_sha256": "df9b950e343ab6d7c0f77bfd563159d33e8bfb9793600b9fefc906413da58dd5",
"report_sha256": "dd0aa947578c603665e6701b3b50b7435dd8cf7a541cac4b351d4a3282c1ce9a",
"positive_positions": 536,
"negative_positions": 1073,
"near_tie_positions": 0
},
{
"profile_offset": 131584,
"requests_sha256": "e7d26e1f2316c46458e4c6ca884388c5af5a82ffdfbaca20e177a1ac1a55ee8f",
"report_sha256": "4b78db3a28ed12001d750a16e47f74c62e1692c2de3bcff781b41cf1a2150363",
"positive_positions": 536,
"negative_positions": 1073,
"near_tie_positions": 1
}
]
}
Loading
Loading