Skip to content
Merged
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
13 changes: 12 additions & 1 deletion PROJECT_MANIFEST.sha256
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ e4e7fe0fb913eda0e53509083b9dc25680cc8e5e68ef5c22a60543ddc7c5a79d ./assets/chart
f65bd5f8df765c5247a2808ab465c8f7cb12381c9789949f19b462e8ee6a1125 ./CITATION.cff
7ddc4d0bcf64d5f8bc42be909b7a1a1a959b02004106e33f82e1b9ad85b1771e ./config/default.yaml
c091241a730c6245becafe6634947f35575f0a941d8375022cac8ecfd5549ded ./config/tensorrt-llm-capacity-120k.yaml
9877c3549295259f15cec64262cec9ee51d4aa329e2b7da97da95b14bad61bb5 ./config/tensorrt-llm-context-scaling.yaml
1b4ab1268e0c5f4e5c6948067944d4b7506e40617bad1aceff9b6f1339f5b174 ./config/tensorrt-llm-profile-c4.yaml
9828c4c66605cc2c93859ffa7484c472d69587c6be94acd250748dd1f7cf6afa ./config/tensorrt-llm-smoke.yaml
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ./data/.gitkeep
72784da5ab0d762248ed8526fe3284e32c15a15eb1e9c2e99ed5b801bfed4176 ./docs/architecture.md
a7de43adec127ff112ab556095247b019f362d63460f294d33fb2f50785aad7f ./docs/capacity.md
51cdd637b3114158b5a93275aaa06ad27308c338ad38e7659ab296659997f1d3 ./docs/context-scaling.md
67dab2a1559389f73148d1055fc20c2de0eae79c625985c011fca438d9b7140a ./docs/DESIGN_MAPPING.md
cb7cbbbf69a14ccced146130f9735ce76dc72f4d77c349a42889954767e07b82 ./docs/fairness-and-limitations.md
181ed639e1a1553745d78d9ff99219f4b73a86be2b0b48601cefd0671024a0db ./docs/methodology.md
Expand All @@ -36,7 +38,7 @@ fc9737e71d1258113190b602d769a91537979af56cefe3b6bf1d763b08cece97 ./.env.example
9a76f67fdf6e34a5a296fc0c6dc8790f68c980da882fe7dfcfa7c239181fa602 ./.gitignore
1126322e2cc8d165adc4c792eeb195717de2bcc7b39be1ce77959d78e87ef685 ./LICENSE
c6ce66613fe24e44b86db05bb0ff42734f3109cff378eea1f33a5738463667d3 ./pyproject.toml
2ab3775a9eba72ecc6c79b7754788762761a2095bb90b3351c03bf43c6e643be ./README.md
98837d71e9c8efc8834e94e82740ee2efa11c52b1291c768b10a44973a9d75c5 ./README.md
f9d4e391eee30f9d6cb74404521826859c0aabe7a88708899ecf51c1da090626 ./reports/benchmark-report.md
b8b508ae02706f1f807ef74add54aefe1f4cd488f45684e215a0241c891c269a ./reports/executive-summary.md
a3eb564b35671d3757bc5cc5387f8eeca05f865ecc991fb5eaed003528bf6d11 ./requirements.lock
Expand All @@ -49,22 +51,29 @@ a35a62233b000188b3f22a1acfcf6a2f2cccdb9dfe7324a7d5870f0b8eea36f2 ./results/summ
6f2b6c6306d42fd9f848eb299d4e46b20d94bbdb19100753107212a39b34a620 ./results/summaries/tensorrt-llm-capacity-analysis.md
3943bd5d7494ded94b75977fa12befe278ee2deb4246eb013b67703ed0f1009b ./results/summaries/tensorrt-llm-capacity-provenance.json
09d5cb91d8aa05ae9c19839f3967b1b08ec1404cca67a1e5108c9bf35ec10f4f ./results/summaries/tensorrt-llm-capacity-validation.csv
a1bec1f39ec8103505a86c45553d95b6b2d455a09040ce973e4bda183cf81e71 ./results/summaries/tensorrt-llm-context-scaling-analysis.md
792bb9e84fda513aa8b2d71f8c3397b756af81ba1dda634b9a0500750e62a3e4 ./results/summaries/tensorrt-llm-context-scaling-provenance.json
0f25c359b35bae0ec6af80c330ff37dd69b0f129f61d572027ba8ee25d51eabe ./results/summaries/tensorrt-llm-context-scaling-validation.csv
f68cfded99ca189e652973d85c02ec637b13f09d0010598453783b728e5a86a0 ./results/summaries/tensorrt-llm-prefill-budget-analysis.md
a0870ff18a976b91ddb91fd2c28f4d14cab8fb9b52d797d2fdc8eefe93eae257 ./results/summaries/tensorrt-llm-prefill-budget-profiling.csv
4867a7373ee0695c9bf49496a4ed9d3de655aafcfdb266d3d58f98c12649d022 ./results/summaries/tensorrt-llm-prefill-budget-provenance.json
133169aa89cce5d0d3a9b5b900d76fc94838274113bf6d179ae7429cae42af23 ./results/summaries/tensorrt-llm-prefill-budget-validation.csv
f7de43402a7474aa39f3e4bac55e59933ac930577e34f94405ad165446f717b6 ./results/summaries/tensorrt-llm-summary.csv
b23f3b977e56f77d35b562b226ec112d2cebd11fccedddd81e60650ca5846fa3 ./results/summaries/vllm-summary.csv
aba14f17fa19bd6e9e4413c8997eeafd63f383fc6c7117621b25cfdcab4433a2 ./scripts/analyze_capacity_boundary.py
a94ab61cde2db57941d58fda29324ff965205f08ea6b7565340864219441927e ./scripts/analyze_context_scaling.py
e35723c2ebd5531edd871209fe43a4c9e1f2d2c20b4de2f217e920800af2206b ./scripts/analyze_prefill_budget.py
1f4a4309a8f5a9909dae41b5ce7738968848f967f74e8c04a2e5e8a155ee1876 ./scripts/full_benchmark.sh
9380bbc0f80642d14cefa04c5cd8fb8c166b3b5d117cada91b8bf1e1fff39ffd ./scripts/generate_charts.py
cd738a4e620a7fbf7719bb0ea7a935f9cf94d1b34c5355cf447456c21ab4d049 ./scripts/run_context_scaling.py
52cd89acdd68d2dae50a3ad3ffcf90e1fe32eb3fe01a896dcdda5759dd6cb33f ./scripts/smoke_test.sh
04e686f48e0096f64f19f2eb1262c143bc0aa55cc561da3c5901eab8ea61b4c2 ./src/llm_engine_benchmark/capacity_analysis.py
d6a0ad368e1fe8b757deb56a9d41f86891adc3630b4ac7885872277898132742 ./src/llm_engine_benchmark/capacity.py
1da2ff0df243bc9db2fdcc8250c915151f222b4b29afa18c2979385b90865717 ./src/llm_engine_benchmark/client.py
821afb010e241333b6eab9c1dd353035509c3a737a1668a4c45be888f064ef13 ./src/llm_engine_benchmark/cli.py
844b2c190ebf00118095ce5c92723081e065e3eb0f0599102b5c09d6594e4bc3 ./src/llm_engine_benchmark/config.py
b5fce406ab84a6f879f301189ee0414f605c764c4808f99ec8976ee40b1b0bb1 ./src/llm_engine_benchmark/context_analysis.py
5ad52bdb3db54f29e8ae9dec5fc8e93923d6db0e9ac2836a1a80d77b5fc535f8 ./src/llm_engine_benchmark/context_scaling.py
e43a14a1019d648bdca921c9cd966996319a0817b047b7f093485887806af1d3 ./src/llm_engine_benchmark/datasets.py
7ddc4d0bcf64d5f8bc42be909b7a1a1a959b02004106e33f82e1b9ad85b1771e ./src/llm_engine_benchmark/default.yaml
1db5a9299c1ea0c77660af3f63783919ae14c7ee78c6e49cd5825a7dd8ff1692 ./src/llm_engine_benchmark/environment.py
Expand All @@ -85,6 +94,8 @@ df823bfd5f8ea0d70ba68e3d6179beccc56f4d5b517551a8d1417b1457b5c230 ./tests/test_c
89c8fe02dba6b2f3fccd9dd2bb32933cd2c612c251dc10ebea5dfcab10c58b17 ./tests/test_client.py
a1d02b16aa83bdfc805dd8610f8973452fa3264b51c5e87d4fbc2c85b407a5a4 ./tests/test_cli.py
3b74c7b4d48d9be2c383cd03c2d6779da495b6beb8b258253e06e5a9306ece24 ./tests/test_config.py
6fdb2831427d2d30cf8b3f759b75e219bebdee3cff8f2d2b0ca5146b0f277dd5 ./tests/test_context_analysis.py
c3a6a9cf09931c84ea16cd9c5dbe97592deb50a2e4e9cc674551c58709ba2e86 ./tests/test_context_scaling.py
49b879b257a013957a5a90bda9ae0812fad67cb7d19a40d3965448ba0ea1b367 ./tests/test_datasets.py
3f856fa35069b6b359ac0454eeb91d9206f57fa620d26cf7fb4fade2b589ae38 ./tests/test_locking.py
092803291540aa802307989209272861c4888a9a5b55c4bf9144d6e6ce6d7717 ./tests/test_normalize.py
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ accepted run JSON + request timings
- [Profiling plan](docs/profiling.md)
- [Prefill-budget case study](docs/prefill-budget-case-study.md)
- [SLA-constrained capacity runbook](docs/capacity.md)
- [Context-length characterization runbook](docs/context-scaling.md)
- Context campaigns support immutable-contract resume and compatible multi-source
consolidation through `scripts/analyze_context_scaling.py`.
- [Fairness and limitations](docs/fairness-and-limitations.md)
- [Production recommendations](docs/production-recommendations.md)
- [Reproducibility and implementation details](docs/reproducibility.md)
Expand All @@ -142,7 +145,7 @@ The repository excludes model weights, Hugging Face caches, TensorRT engines, se
- [x] Nsight Systems capture integration
- [x] Profiler-backed root cause for the TensorRT-LLM cold-C4 ITL anomaly
- [ ] TensorRT-LLM through Triton
- [ ] Context scaling: 8K, 32K, 64K, 120K
- [ ] Context scaling: 8K, 32K, 64K, 120K ([isolated workflow implemented](docs/context-scaling.md); GPU validation pending)
- [x] SLA-constrained throughput with [validated production capacity evidence](results/summaries/tensorrt-llm-capacity-analysis.md)

## Authorship and citation
Expand Down
13 changes: 13 additions & 0 deletions config/tensorrt-llm-context-scaling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Layered on default.yaml. Input lengths are selected by the standalone runner.
# Keep the server context ceiling fixed across cells to isolate input-length effects.
project:
engines: [tensorrt_llm]
cache_modes: [cold]
output_tokens: 512
context_length: 131072
engines:
tensorrt_llm:
max_batch_size: 4
max_num_tokens: 2048
kv_cache_free_gpu_memory_fraction: 0.80
kv_cache_dtype: fp8
204 changes: 204 additions & 0 deletions docs/context-scaling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
# Phase 1: context-length characterization

This opt-in workflow measures fixed-length cold-prefix requests at bounded client
concurrency. It is **not** mixed-workload production capacity, an accuracy benchmark,
or evidence of P99 reliability. Existing `bench run`, `bench capacity`, preparation,
and reporting code paths are unchanged.

## Experimental contract

| Dimension | Default |
| --- | --- |
| Engine and model | Direct TensorRT-LLM, existing pinned model/tokenizer lock |
| Input lengths | 8,000 / 32,000 / 64,000 / 120,000 tokens, exactly |
| Client concurrency | 1 and 4 |
| Output | 512 tokens; server usage required |
| Server context ceiling | Fixed at 131,072; not resized per input length |
| Prefill budget | Fixed at 2,048; not claimed optimal at every length |
| KV dtype / memory fraction | FP8 / 0.80 |
| Discovery | 20 measured requests, one repetition per cell |
| Warm-up | Two waves of C unique requests, target input length and full output length |
| Run order | Seeded shuffle of eight cells; reversed on even repetitions |

Client-observed overlap is verified during warm-up and measurement. It does not
prove simultaneous GPU execution or that every compilation path is initialized.
Raw warm-up timings are retained for inspection. Warm-up requests are never
counted in the measured report. Nsight captures can include startup/warm-up;
filter the timeline before attributing activity to the measurement interval.

## Preservation and isolation

- Start from an idle Spark1. Do not run other GPU workloads during the experiment.
- The existing lock and canonical manifest are mandatory, checked, and read-only.
The runner never auto-prepares or refreshes the canonical dataset or lock.
- New prompts are generated from a deterministic task-stratified source subset.
The same selected samples are used at each length; source context is truncated
or extended through the existing normalizer, retaining the instruction suffix.
Truncation may remove answer evidence. This measures serving cost, not quality.
- Derived prompts live under the new results directory, never `data/prepared`.
- Phase 1 prompt format v3 allocates deterministic markers using the pinned
tokenizer so every prompt starts with a different token. Allocation covers the
entire measured set and every warm-up wave together. Markers are selected from
decimal and letter candidates; insufficient distinct tokens fail preparation.
The variable body is refitted to preserve the exact token count and task
instruction suffix. The legacy benchmark prompt builder remains unchanged.
- Saved prompt text is re-tokenized and hashed. Duplicate IDs or even a single
shared first token across measured/warm-up requests are rejected. Actual server
usage is still checked; no cached-token tolerance is introduced.
- Any reported cached input tokens reject the run. Missing cache usage is labeled
protocol-only evidence, not a measured zero cache-hit rate.
- Active benchmark containers, active GPU compute processes, or a busy server port
stop execution without killing another workload. This is a preflight check, not
a reservation against unrelated applications starting later.
- Containers use unique names. Existing benchmark containers are never removed.
- The results directory must not exist for a new campaign. There is no overwrite
option. `--resume` accepts only an existing campaign whose source hashes, lock,
resolved configuration, plan, prompt format, measurement protocol and immutable
options match. Every accepted cell is revalidated from its metadata, request
counts, zero-cache evidence, prepared-input hashes and observed concurrency.
Accepted cells are never overwritten. An incomplete cell is moved intact under
`interrupted/` before the same planned cell is attempted again.
- Model/runtime caches remain shared as in the existing server wrapper; they may
be populated by the engine. Existing benchmark result files are not modified.

## Safe launch sequence

Use the repository's installed virtual environment and run from the repository root.
First inspect the plan; this command performs no preparation, Docker calls, or writes:

```bash
.venv/bin/python scripts/run_context_scaling.py \
--results-dir results/context-scaling/discovery-01 \
--dry-run
```

Then smoke-test the smallest length at both concurrencies. Use at least four
requests so C4 actually has four requests to issue:

```bash
.venv/bin/python -u scripts/run_context_scaling.py \
--lengths 8000 --concurrency 1,4 \
--samples 4 --repetitions 1 \
--results-dir results/context-scaling/smoke-8k-01 \
--skip-image-pull
```

After checking `context_status.json`, `context_report.md`, warm-up metadata and
token usage, run all eight discovery cells in a tmux session:

```bash
.venv/bin/python -u scripts/run_context_scaling.py \
--samples 20 --repetitions 1 \
--results-dir results/context-scaling/discovery-01 \
--skip-image-pull
```

If the controlling process is interrupted, first stop only the uniquely named
orphan container recorded for that cell and verify that no benchmark process is
active. Resume with the identical experimental arguments plus `--resume`:

```bash
.venv/bin/python -u scripts/run_context_scaling.py \
--samples 20 --repetitions 1 \
--results-dir results/context-scaling/discovery-01 \
--skip-image-pull --resume
```

Changing lengths, concurrencies, sample count, repetitions, warm-up, profiling,
cooldown, image-pull policy, source data, lock or configuration rejects resume.
The runner records resume history and archived attempts in the experiment artifacts.
It does not remove containers automatically because ownership must be checked by the
operator after abrupt process termination.

Confirm the matrix in another fresh directory:

```bash
.venv/bin/python -u scripts/run_context_scaling.py \
--samples 20 --repetitions 3 \
--results-dir results/context-scaling/confirmation-01 \
--skip-image-pull
```

Twenty requests per repetition supports exploratory comparison, not precise tail
estimation. For stronger request-tail evidence use `--samples 100` at selected
cells. The runner accepts up to the canonical 100 samples without duplicating them.

Optional targeted profiling, **separate** from primary latency results:

```bash
.venv/bin/python -u scripts/run_context_scaling.py \
--lengths 64000 --concurrency 4 --samples 20 \
--profile-nsys \
--results-dir results/context-scaling/profile-64k-c4-01 \
--skip-image-pull
```

`--config` can select another override file. Inspect and retain the resolved config
before comparing studies. All lengths must fit input + output within the fixed
server context ceiling; invalid options fail before workload execution.

## Consolidating discovery or validation campaigns

Recovery cells may be collected in new output directories when they predate resume
support. Consolidate compatible, non-overlapping sources without copying raw data:

```bash
.venv/bin/python scripts/analyze_context_scaling.py \
--source results/context-scaling/discovery-01 \
--source results/context-scaling/discovery-01-recovery-120k-c1 \
--source results/context-scaling/discovery-01-recovery-32k-c4 \
--repetitions 1 \
--output-dir results/summaries
```

The analyzer requires matching source hashes, lock, resolved configuration, image
digest, sample count, warm-up policy, prompt format and measurement protocol. It
rejects duplicate accepted cells and measured-prompt hash differences. Its CSV
retains each run; Markdown reports per-cell summaries and C4/C1 ratios; provenance
hashes every consumed plan, metadata, result and request-timing file. Missing cells
produce `incomplete`, one complete repetition produces `complete_discovery`, and at
least three complete repetitions produce `complete_repeated_validation`.

## Evidence and interpretation

Each experiment contains a plan, pinned source hashes, code hashes and Git identity,
resolved config/environment, prepared prompts, image identity, per-cell artifacts,
CSV/Markdown reports and SHA-256 provenance. Per-cell files include client request
timings, warm-up timings, server logs/command, metrics snapshots and telemetry status.
The default telemetry records GPU, power/thermal and system resource information
where supported. Inspect availability before making memory/utilization claims;
unavailable Spark counters are not zero. GPU process overlap is not proof of GPU
occupancy. Peak memory extraction/visualization is not part of this initial report.

CSV rows retain per-repetition TTFT P50/P95, ITL P50/P95, TPOT mean, E2E P95,
output token throughput, request throughput, sample count and maximum observed ITL.
Markdown is a compact view. No averaging of percentiles is presented as a pooled
percentile, and no P99 claim is generated. ITL is based on observed SSE events, not
independently timestamped hardware tokens. Closed-loop client waiting is not a
production admission-queue measurement.

Only cells accepted after measurement, cleanup and optional CUDA trace validation
enter numeric summaries. Failed and unrun cells remain visible. Whole-process
termination (SIGKILL, power loss) may prevent final reports or cleanup; inspect and
stop only the uniquely named container before using `--resume`. The runner preserves
the interrupted evidence directory rather than deleting it.

The next phase adds workload mixtures, arrival-rate sweeps, cache-locality scenarios
and per-class SLOs using the capacity harness. It is intentionally outside this runner.

## Initial smoke-test correction

The initial 8K C4 warm-up reported cached tokens of 0, 8, 8, and 8. The former
32-token uniqueness check allowed a common leading header to survive. Format v2
moved hashes to the beginning but still allowed first-token collisions: w0-0 and
w0-2 both began with token 69, and one reported one cached token. Format v3 assigns
distinct first tokens using the actual tokenizer, then validates the fitted text.
This does not relax zero-cache acceptance or disable engine prefix caching.
Retain `smoke-8k-01` and `smoke-8k-02`; rerun in `smoke-8k-03`. GPU validation is
required before launching the full matrix. Do not pool different prompt formats.

Offline validation used the tokenizer JSON pinned at
`6cee5e81ee83917806bbde320786a8fb61efebee`: allocation produced 108 distinct
starting tokens, and 12 synthetic prompts at each of 8,000 and 120,000 tokens
passed exact-length and first-token checks. These checks do not substitute for
the next GPU smoke test or establish engine-reported zero cache usage.
35 changes: 35 additions & 0 deletions results/summaries/tensorrt-llm-context-scaling-analysis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# TensorRT-LLM Context-Scaling Analysis

- Evidence status: **complete_discovery**.
- Accepted cells: 8 / 8.
- Repetitions expected per cell: 1.
- Controlled closed-loop cold-prefix characterization; not production capacity.

## Context matrix

| Input tokens | C | Runs | TTFT P95 | ITL P95 | E2E P95 | Output tok/s |
| ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| 8000 | 1 | 1 | 0.879 s | 0.023 s | 11.966 s | 42.859 |
| 8000 | 4 | 1 | 2.661 s | 0.040 s | 23.643 s | 93.228 |
| 32000 | 1 | 1 | 5.531 s | 0.024 s | 17.522 s | 29.314 |
| 32000 | 4 | 1 | 16.974 s | 0.306 s | 52.228 s | 48.011 |
| 64000 | 1 | 1 | 16.864 s | 0.027 s | 30.146 s | 17.081 |
| 64000 | 4 | 1 | 51.807 s | 0.663 s | 120.516 s | 22.783 |
| 120000 | 1 | 1 | 50.050 s | 0.031 s | 65.361 s | 7.860 |
| 120000 | 4 | 1 | 146.148 s | 1.225 s | 305.989 s | 9.362 |

## Concurrency effect

| Input tokens | TTFT C4/C1 | ITL C4/C1 | E2E C4/C1 | Throughput C4/C1 |
| ---: | ---: | ---: | ---: | ---: |
| 8000 | 3.03× | 1.79× | 1.98× | 2.18× |
| 32000 | 3.07× | 12.48× | 2.98× | 1.64× |
| 64000 | 3.07× | 24.44× | 4.00× | 1.33× |
| 120000 | 2.92× | 39.40× | 4.68× | 1.19× |

## Interpretation guardrails

- This is complete discovery evidence, but one run per cell does not establish repeatability or confidence intervals.
- P95 values are per-run summaries; averaging repeated P95 values is not a pooled percentile.
- Concurrency ratios describe this fixed workload and do not identify a kernel-level cause.
- Use separate Nsight runs before attributing changes to attention, KV memory, or scheduling.
Loading
Loading