Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
cade4d5
Add LLM benchmarking framework to staging
kubraaksux Jan 19, 2026
8e7d6da
Add LLM inference support to JMLC API via Py4J bridge
kubraaksux Feb 12, 2026
47dd0db
Refactor loadModel to accept worker script path as parameter
kubraaksux Feb 13, 2026
672a3fa
Add dynamic port allocation and improve resource cleanup
kubraaksux Feb 13, 2026
dacdc1c
Move llm_worker.py to fix Python module collision
kubraaksux Feb 13, 2026
29f657c
Use python3 with fallback to python in Connection.java
kubraaksux Feb 14, 2026
e40e4f2
Add batch inference with FrameBlock and metrics support
kubraaksux Feb 14, 2026
fdd1684
Clean up test: extract constants and shared setup method
kubraaksux Feb 14, 2026
b9ba3e0
Add token counts, GPU support, and improve error handling
kubraaksux Feb 14, 2026
5588dcc
Fix bugs and improve code quality in benchmark framework
kubraaksux Feb 14, 2026
1510e8a
Fix fake metrics and add compute cost tracking
kubraaksux Feb 15, 2026
4a06093
Add tests, ROUGE scoring, concurrent benchmarking, GPU profiling
kubraaksux Feb 15, 2026
a18979f
Fix bash 3.x compatibility in run_all_benchmarks.sh
kubraaksux Feb 15, 2026
3d4f9e8
Add embeddings workload (STS-B semantic similarity)
kubraaksux Feb 15, 2026
deb21ad
Add compute cost model and fix ROUGE/cost aggregation
kubraaksux Feb 15, 2026
7239460
Add benchmark results for project submission
kubraaksux Feb 15, 2026
1317509
Add vLLM benchmark results (Mistral 7B + Qwen 3B on H100)
kubraaksux Feb 15, 2026
fd3a117
Add LLM inference support to JMLC API via Py4J bridge
kubraaksux Feb 12, 2026
af42052
Refactor loadModel to accept worker script path as parameter
kubraaksux Feb 13, 2026
c4e57f9
Add dynamic port allocation and improve resource cleanup
kubraaksux Feb 13, 2026
0cc05f6
Move llm_worker.py to fix Python module collision
kubraaksux Feb 13, 2026
036a221
Use python3 with fallback to python in Connection.java
kubraaksux Feb 14, 2026
ef8c1f4
Add batch inference with FrameBlock and metrics support
kubraaksux Feb 14, 2026
af54019
Clean up test: extract constants and shared setup method
kubraaksux Feb 14, 2026
581669f
Add token counts, GPU support, and improve error handling
kubraaksux Feb 14, 2026
98b81bb
Add SystemDS JMLC backend with FrameBlock batch processing
kubraaksux Feb 15, 2026
190d952
Add embeddings workload for SystemDS backend
kubraaksux Feb 15, 2026
a39078c
Trim verbose docstring in systemds_backend.py
kubraaksux Feb 15, 2026
b19dff1
Replace SystemDS distilgpt2 with Qwen 3B for direct vLLM comparison
kubraaksux Feb 15, 2026
a94aee1
Run SystemDS with Qwen 3B and Mistral 7B for direct vLLM comparison
kubraaksux Feb 16, 2026
52d5269
Remove deprecated trust_remote_code from dataset loaders
kubraaksux Feb 16, 2026
d72711e
Update README with actual benchmark results and SystemDS backend docs
kubraaksux Feb 16, 2026
d4be2a1
Add gitignore rules for .env files, meeting notes, and local tool con…
kubraaksux Feb 16, 2026
1b9a6e3
Redesign benchmark report for clarity and minimal UI
kubraaksux Feb 16, 2026
27826ac
Update benchmark runner with systemds backend and GPU comparison mode
kubraaksux Feb 16, 2026
bd63237
Clean up report: remove dead code, unused CSS, and hardcoded model name
kubraaksux Feb 16, 2026
dbf6875
Add presentation-friendly summary tables to benchmark report
kubraaksux Feb 16, 2026
2e984a2
Increase worker startup timeout to 300s for larger models
kubraaksux Feb 16, 2026
bf666c2
Revert accidental changes to MatrixBlockDictionary.java
kubraaksux Feb 16, 2026
a8a1b79
Add concurrency=4 benchmark results and fix json_extraction type check
kubraaksux Feb 16, 2026
85bfa93
Revert accidental changes to MatrixBlockDictionary.java
kubraaksux Feb 16, 2026
7e48a8b
Regenerate benchmark report with SystemDS results
kubraaksux Feb 16, 2026
7e250a4
Add GPU batching to SystemDS JMLC backend with benchmark results
kubraaksux Feb 16, 2026
5faa691
Add GPU batching support to JMLC LLM inference
kubraaksux Feb 16, 2026
4e8e684
Keep both sequential and batched inference modes for reproducibility
kubraaksux Feb 16, 2026
c9c85d4
Keep both sequential and batched inference modes in PreparedScript
kubraaksux Feb 16, 2026
4b44dd1
Add gitignore rules for .env files, meeting notes, and local tool config
kubraaksux Feb 16, 2026
72bc334
Add llmPredict builtin, opcode and ParamBuiltinOp entries
kubraaksux Feb 16, 2026
0ad1b56
Add llmPredict parser validation in ParameterizedBuiltinFunctionExpre…
kubraaksux Feb 16, 2026
1e48362
Wire llmPredict through hop, lop and instruction generation
kubraaksux Feb 16, 2026
de675ac
Add llmPredict CP instruction with HTTP-based inference
kubraaksux Feb 16, 2026
5eab87d
Remove Py4J-based LLM inference from JMLC API
kubraaksux Feb 16, 2026
bea062a
Rewrite LLM test to use llmPredict DML built-in
kubraaksux Feb 16, 2026
edf4e39
Add OpenAI-compatible HTTP inference server for HuggingFace models
kubraaksux Feb 16, 2026
04f82ac
Merge branch 'llm-api' into llm-benchmark
kubraaksux Feb 16, 2026
f5fa4ec
Update benchmark backend to use llmPredict DML built-in
kubraaksux Feb 16, 2026
d92eb7c
Fix llmPredict code quality and clean up Py4J remnants
kubraaksux Feb 16, 2026
45882e2
Fix llmPredict code quality issues
kubraaksux Feb 16, 2026
c3e9a1f
Add concurrency parameter to llmPredict built-in
kubraaksux Feb 16, 2026
c0ec34b
Merge branch 'llm-api' into llm-benchmark
kubraaksux Feb 16, 2026
6d8797c
Remove old SystemDS results and clean up headers
kubraaksux Feb 16, 2026
223c606
Pass concurrency to llmPredict via SYSTEMDS_CONCURRENCY env var
kubraaksux Feb 16, 2026
d269db7
Route SystemDS concurrency through Java instead of Python threads
kubraaksux Feb 16, 2026
a27e0fa
Fix JVM incubator vector module for Py4J gateway
kubraaksux Feb 16, 2026
a710dca
Fix JMLC frame binding: match DML variable names to registered inputs
kubraaksux Feb 16, 2026
5d47925
Add SystemDS llmPredict benchmark results (c=1 and c=4)
kubraaksux Feb 16, 2026
4629465
Fix benchmark results accuracy and update documentation
kubraaksux Feb 16, 2026
d1adf16
Fix data accuracy across README, PR description, and HTML report
kubraaksux Feb 16, 2026
ac5a69e
Rewrite README and PR description with accurate data and honest concl…
kubraaksux Feb 16, 2026
83b90e4
Fix math extraction bug, add cost tables, cross-backend comparisons, …
kubraaksux Feb 16, 2026
e898879
Fix Mistral math explanation: 20/31 wrong math, 10/31 extractor failures
kubraaksux Feb 16, 2026
fa6e09a
Add dedicated LlmPredictCPInstruction with error handling, negative t…
kubraaksux Feb 25, 2026
2dfa618
Add OpenAI benchmark results and update README with all 3 backends
kubraaksux Feb 27, 2026
20e666d
Update README: llmPredict implementation merged from closed PR #2430
kubraaksux Feb 27, 2026
e6bb968
Clean up unused backends, add compute costs, fix stale references
kubraaksux Feb 27, 2026
bf72b49
Remove silent fallback patterns that could mask extraction failures
kubraaksux Feb 27, 2026
2b427fb
Add CUBLAS determinism experiment, APC root cause analysis, and updat…
kubraaksux Mar 3, 2026
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: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,3 @@ docker/mountFolder/*.bin
docker/mountFolder/*.bin.mtd

SEAL-*/

34 changes: 34 additions & 0 deletions scripts/staging/llm-bench/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Benchmark outputs (committed for project submission)
# results/

# Python
__pycache__/
*.pyc
*.pyo
*.egg-info/
.eggs/

# Virtual environment
.venv/
venv/
env/

# IDE
.idea/
.vscode/
*.swp
*.swo

# Environment variables
.env

# OS
.DS_Store
Thumbs.db

# Reports (committed for project submission)
# *.html
!templates/*.html

# Dataset cache
.cache/
910 changes: 910 additions & 0 deletions scripts/staging/llm-bench/README.md

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions scripts/staging/llm-bench/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#-------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#-------------------------------------------------------------

"""Allow running the benchmark as ``python runner.py`` from within the llm-bench directory."""

from runner import main

if __name__ == "__main__":
main()
21 changes: 21 additions & 0 deletions scripts/staging/llm-bench/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#-------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#-------------------------------------------------------------

40 changes: 40 additions & 0 deletions scripts/staging/llm-bench/backends/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#-------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#-------------------------------------------------------------

from typing import Any, Dict, List, Optional, Protocol, TypedDict


class GenerationResult(TypedDict, total=False):
text: str
latency_ms: float
ttft_ms: float
generation_ms: float
extra: Dict[str, Any]


class InferenceBackend(Protocol):

def generate(
self,
prompts: List[str],
config: Dict[str, Any],
) -> List[GenerationResult]:
...
251 changes: 251 additions & 0 deletions scripts/staging/llm-bench/backends/openai_backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
#-------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#-------------------------------------------------------------

import json
import logging
import os
import time
from pathlib import Path
from typing import Any, Dict, List, Optional

from dotenv import load_dotenv
from openai import OpenAI

logger = logging.getLogger(__name__)


# Pricing per million tokens (USD).
# Reference: https://openai.com/api/pricing/
# Last verified: 2026-02-18. OpenAI does not expose a pricing API, so this
# table must be updated manually when prices change.
# To add a missing model without editing this file, create a file called
# pricing.json next to this file with the format:
# {"my-model": {"input": 1.00, "output": 2.00}}
# It will be merged with the table below at import time.
PRICING_LAST_UPDATED = "2026-02-18"
PRICING: Dict[str, Dict[str, float]] = {
"gpt-4.1-mini": {"input": 0.40, "output": 1.60},
"gpt-4.1-mini-2025-04-14": {"input": 0.40, "output": 1.60},
"gpt-4.1": {"input": 2.00, "output": 8.00},
"gpt-4.1-2025-04-14": {"input": 2.00, "output": 8.00},
"gpt-4.1-nano": {"input": 0.10, "output": 0.40},
"gpt-4.1-nano-2025-04-14": {"input": 0.10, "output": 0.40},
"gpt-4o": {"input": 2.50, "output": 10.00},
"gpt-4o-mini": {"input": 0.15, "output": 0.60},
}

_pricing_override = Path(__file__).parent / "pricing.json"
if _pricing_override.exists():
try:
_extra = json.loads(_pricing_override.read_text(encoding="utf-8"))
PRICING.update(_extra)
logger.debug("Loaded %d pricing overrides from %s", len(_extra), _pricing_override)
except Exception as _e:
logger.warning("Could not load %s: %s", _pricing_override, _e)


class OpenAIBackend:

def __init__(self, api_key: Optional[str] = None):
load_dotenv()
api_key = api_key or os.getenv("OPENAI_API_KEY")
if not api_key:
raise RuntimeError("OPENAI_API_KEY is not set.")
self.client = OpenAI(api_key=api_key)

def generate(self, prompts: List[str], config: Dict[str, Any]) -> List[Dict[str, Any]]:
model = config.get("model", "gpt-4.1-mini")
max_output_tokens = int(config.get("max_output_tokens", config.get("max_tokens", 256)))
temperature = config.get("temperature", 0.0)
top_p = float(config.get("top_p", 0.9))
use_streaming = config.get("streaming", False)
max_retries = int(config.get("max_retries", 5))
base_sleep = float(config.get("base_sleep_s", 0.5))

results = []

for prompt in prompts:
last_err = None
for attempt in range(max_retries):
try:
if use_streaming:
result = self._generate_streaming(
prompt, model, max_output_tokens, temperature, top_p
)
else:
result = self._generate_non_streaming(
prompt, model, max_output_tokens, temperature, top_p
)

results.append(result)
last_err = None
break
except Exception as e:
last_err = e
time.sleep(base_sleep * (2**attempt))

if last_err is not None:
results.append(
{
"text": "",
"latency_ms": 0.0,
"extra": {"error": repr(last_err)},
}
)

return results

def _generate_non_streaming(self, prompt: str, model: str, max_output_tokens: int, temperature: float, top_p: float) -> Dict[str, Any]:
t0 = time.perf_counter()
resp = self.client.responses.create(
model=model,
input=prompt,
max_output_tokens=max_output_tokens,
temperature=temperature,
top_p=top_p,
)
t1 = time.perf_counter()

text = resp.output_text

extra: Dict[str, Any] = {}
usage = getattr(resp, "usage", None)
if usage is not None:
usage_data = self._extract_usage(usage)
if usage_data is not None:
extra["usage"] = usage_data
cost = self._calculate_cost(usage_data, model)
if cost is not None:
extra["cost_usd"] = cost
extra["response_id"] = getattr(resp, "id", None)

return {
"text": text,
"latency_ms": (t1 - t0) * 1000.0,
"extra": extra,
}

def _generate_streaming(self, prompt: str, model: str, max_output_tokens: int, temperature: float, top_p: float) -> Dict[str, Any]:
t0 = time.perf_counter()
stream = self.client.responses.create(
model=model,
input=prompt,
max_output_tokens=max_output_tokens,
temperature=temperature,
top_p=top_p,
stream=True,
)

t_first = None
t_final = None
full_text = ""
response_id = None
usage_data = None

for event in stream:
if event.type == "response.output_text.delta":
if t_first is None:
t_first = time.perf_counter()
full_text += event.delta

elif event.type == "response.completed":
t_final = time.perf_counter()
response = getattr(event, "response", None)
if response is not None:
response_id = getattr(response, "id", None)
usage = getattr(response, "usage", None)
if usage is not None:
usage_data = self._extract_usage(usage)
else:
response_id = getattr(event, "response_id", None) or getattr(event, "id", None)
usage = getattr(event, "usage", None)
if usage is not None:
usage_data = self._extract_usage(usage)

if usage_data is None:
stream_usage = getattr(stream, "usage", None)
if stream_usage is not None:
usage_data = self._extract_usage(stream_usage)

if t_first is None:
t_first = time.perf_counter()
if t_final is None:
t_final = time.perf_counter()

ttft_ms = (t_first - t0) * 1000.0
generation_ms = (t_final - t_first) * 1000.0
total_latency_ms = (t_final - t0) * 1000.0

extra: Dict[str, Any] = {
"ttft_ms": ttft_ms,
"generation_ms": generation_ms,
"response_id": response_id,
}

if usage_data is not None:
extra["usage"] = usage_data
cost = self._calculate_cost(usage_data, model)
if cost is not None:
extra["cost_usd"] = cost

return {
"text": full_text,
"latency_ms": total_latency_ms,
"extra": extra,
}

def _extract_usage(self, usage: Any) -> Optional[Dict[str, Any]]:
if usage is None:
return None
if hasattr(usage, "model_dump"):
return usage.model_dump()
elif hasattr(usage, "dict"):
return usage.dict()
elif isinstance(usage, dict):
return usage
else:
return {"raw": str(usage)}

def _calculate_cost(self, usage_data: Optional[Dict[str, Any]], model: str) -> Optional[float]:
if usage_data is None:
return None

input_tokens = usage_data.get("input_tokens", 0)
output_tokens = usage_data.get("output_tokens", 0)

if input_tokens == 0 and output_tokens == 0:
return None

prices = PRICING.get(model)
if prices is None:
logger.warning(
"No pricing data for model '%s' (table last updated %s). "
"Cost will not be reported. Check https://openai.com/api/pricing/ "
"and update PRICING in openai_backend.py if needed.",
model, PRICING_LAST_UPDATED,
)
return None

cost = (
input_tokens * prices["input"] / 1_000_000 +
output_tokens * prices["output"] / 1_000_000
)
return cost
Loading