Faster inference backend for Open-Jev-27B: fused CUDA kernels, prefix tree, CUDA Graphs (B300, bf16)
See the code
A faster inference backend for Open-Jev. It runs locally as a drop-in replacement for Open-Jev's own local server (python -m jev.server, same request format), with the same model (Open-Jev-27B-v1.1 on Qwen3.8-27B), in bf16 with no quantization. It replaces the model forward pass with hand-written CUDA kernels (including its own Gated DeltaNet and tree-attention kernels), a prefix tree that computes shared prompt text once, tuned matrix multiplies and CUDA Graphs.
Open-Jev is by the Open-Jev contributors; this repository runs on top of it and needs an Open-Jev installation and the model weights. Built on: Open-Jev [1], Open-Jev-27B-v1.1 / Qwen3.8-27B [2, 3], flash-linear-attention [4], Hugging Face Transformers [7], PEFT [8], PyTorch [9]; evaluated with JevBench [11]. What is used from each project is listed in THIRD_PARTY_NOTICES.md.
| Open-Jev, default PyTorch path | Open-Jev + FLA kernels | open-jev-fast | |
|---|---|---|---|
| Example request, one inference (3 questions, 7 candidates, 539 tokens; forward pass + scoring head) | 256.0 ms | 103.7 ms | 17.3 ms (14.8× / 6.0×) |
| JevBench, mean per-task latency (231 tasks, HTTP, concurrency 1) | — | 258 ms | 42.0 ms (6.1×) |
| JevBench P50 / P95 / max | — | 150 / 802 / 1489 ms | 17.4 / 137 / 208 ms |
| JevBench accuracy (our runs) | — | 198/231 | 197/231 (one near-tie prediction changed, see below) |
Open-Jev's default install does not include flash-linear-attention (FLA) [4], so Transformers runs the linear-attention layers as plain PyTorch ops: that is the first column. The second column is Open-Jev with FLA installed, which is also what our JevBench baseline server used.

Example request: 3 questions, 7 candidates, 539 tokens. Median latency of the forward pass plus scoring head.
The Open-Jev-27B-v1.1 model card reports 197/231 on public JevBench for this checkpoint; our runs of the original server scored 198/231.
Single inference (example request).
configs/example-request.json, a customer-service conversation with 3 questions (routing, 1 of 3; refund review, yes/no; urgency, 3 levels). That is 7 candidate prompts and 539 tokens.bench/e2e_bench.py, run one after another on the same GPU.
torch.cuda.synchronize() before and after each (bench/logs/e2e_bench.log; values in results/e2e_latency.json).JevBench.
f8ce713, run once in order at concurrency 1.TypeSafeAdapter: tokenization, HTTP and JSON included, with a new connection per task. The client runs on the same machine as the server, for both servers.score_task.jev.server and this server ran with --max-length 16384, so that every JevBench task fits. The model card's saved limit is 4,096 tokens per candidate.results/summary.json). The earlier published comparison (original mean 703 ms) used a first pass of the original.results/ (phase 1, service v1 and v3) were measured with the client on another machine of the cluster, which adds about 25 ms per task through the new connection; see results/summary.json.Per-task results for every version are in results/ (task ID, prediction, correctness, latency); results/summary.json has the aggregates.
Without FLA, the Gated DeltaNet layers run as many small PyTorch ops (256 ms). With FLA, the original is CPU-bound: each request launches about 5000 small GPU kernels, and the GPU is busy for only about 51 of its ~103 ms. The seven candidate prompts also repeat most of their text.
Phase 1, PyTorch level (103 → 32.4 ms).
src/graph_patches.py; both are "skip the mask if there is no padding" shortcuts, so the math is unchanged).torch.compile.Phase 2, hand-written CUDA (32.4 → 20.1 ms). This path replaces the phase-1 path. (Phase 3 below replaces the Gated DeltaNet core and, for trees up to 384 rows, full attention.)
Six fused kernels (src/kernels.cu) take over every non-matmul operation in a layer:
Matrix multiplies are merged from 9 to 4 per layer, and kernels per request drop from about 5000 to 945. Each kernel reproduces the bf16 rounding points of the Transformers reference [7] and FLA [4]. In phase 2 the Gated DeltaNet core was still FLA's chunk_gated_delta_rule [4, 5] and full attention was PyTorch SDPA.
Prefix tree (src/fastmodel.py: gtree_build, forward_gtree). One packed forward pass computes the shared context once, each question's text once, and each candidate's tail, so the weights are read once. For the example request, computed rows go from 574 to 277.
Related ideas: shared-prefix attention [12, 13] and tree attention masks [14, 15].
Matrix multiplies (src/lt.cpp):
Serving (src/server.py):
TCP_NODELAYPhase 3, hand-written kernels for the remaining hot spots (20.1 → 17.3 ms).
gdn_fused6_k / gdn_fused4_k in src/kernels.cu) replaces FLA's chunk_gated_delta_rule on the prefix-tree path: 74 µs → 36.5 µs per layer.
mma.sync (bf16 in, fp32 accumulate) with ldmatrix, and tiles arrive by cp.async, all as inline PTX. The fp32 state stays in registers. The 64×64 inverse follows FLA's block order with tf32 MMAs, and every bf16 rounding point of FLA [4, 5] is kept.fattn_k) replaces SDPA and the separate gate multiply when the tree has at most 384 rows: 21.4 µs → 12.7 µs per layer.
bench/logs/r4/.Matrix multiplies are now 68% of the example's latency (11.8 of 17.4 ms). Under sustained load they run against the B300's 1,100 W power limit, with the SM clock near 1.2 GHz.
A step-by-step breakdown, the GPU time budget and the failed attempts are in the report.
We checked at three levels:
bench/logs/correct.log);bench/logs/r4/gdn_kernel.log);bench/logs/r4/tree_attention.log).Probability differences from the original grow with input length, because bf16 rounding-order differences accumulate through 64 layers and the recurrent state:
tests/test_gtree.py; the previous version: 0.035, bench/logs/gtree2.log).On JevBench, two tasks changed prediction versus the original:
hard-opus-c-long_policy-03 is wrong both before and after.hard-opus-a-temporal_numeric-09 is a near-tie prediction that changed: the original gives no/yes = 0.504/0.496, merging LoRA alone gives 0.503/0.497, and the hand-written kernels give 0.496/0.504.Phase 3 changed no JevBench prediction relative to the previous release (v3).
mma.sync, ldmatrix, cp.async; sm_80 or newer), compiled for sm_103 by default. For another GPU with enough memory, change the -gencode flag in src/ext.py. That path is untested, and the speedups will differ.nvidia-smi after the full JevBench run), so an 80 GB GPU is not enough as is.
tests/ need about as much.Requirements: a GPU with about 98 GiB of free memory (tested only on an NVIDIA B300), CUDA 13 (nvcc, cuBLASLt), and Python with Open-Jev installed (commit 3308a15) and its dependencies. We used torch 2.14 (cu130), transformers 5.10.2, peft 0.19.1, flash-linear-attention 0.5.2 and triton 3.8.0.
git clone https://github.com/Zefan-Cai/Open-Jev.git && (cd Open-Jev && git checkout 3308a15 && pip install -e '.[train]')
pip install flash-linear-attention==0.5.2
hf download ZefanCai/Open-Jev-27B-v1.1 --local-dir ./open-jev-27b-v1.1 # Open-Jev's loader fetches the pinned Qwen3.8-27B base
export OPEN_JEV_DIR=$PWD/Open-Jev OJ_CKPT=$PWD/open-jev-27b-v1.1/package/checkpoint
export CUDA_HOME=/path/to/cuda-13 # needs bin/nvcc, include/, lib/libcublasLt.so
./scripts/launch_server.sh # local server, same request format as jev.server: POST http://localhost:18791/v1/systemone
Kernels are compiled on first import (torch.utils.cpp_extension.load_inline).
Correctness and benchmarks (each loads the original model as the reference):
export JEVBENCH_DIR=/path/to/jevbench # https://github.com/fstandhartinger/jevbench @ f8ce713 (long test inputs + runner)
python tests/test_correct.py # kernel-by-kernel, 64-layer and probability comparison
python tests/test_gtree.py # two-level prefix tree vs original + CUDA Graph timing
python tests/test_r4_gdn.py # Gated DeltaNet kernel vs FLA, timing, whole-model probabilities
JEVBENCH_DIR=... python tests/test_r4_fattn.py # tree attention kernel vs cuDNN SDPA
for m in torch fla fast; do E2E_MODE=$m python bench/e2e_bench.py; done # the headline numbers (256.0 / 103.7 / 17.3 ms)
python bench/run_jevbench.py http://localhost:18791 open-jev out.json
| Path | Contents |
|---|---|
src/ | CUDA kernels (kernels.cu, built by ext.py), cuBLASLt wrapper (lt.cpp, lt_ext.py), fast backbone and prefix tree (fastmodel.py), Transformers patches (graph_patches.py), server (server.py) |
tests/ | Correctness tests against the original implementation |
bench/ | Benchmarks (GEMM, split-K, cuBLASLt, FLA, kernel phases, profiling) and the JevBench runner; bench/logs/ has their recorded output, bench/logs/r4/ the phase-3 (round 4) experiments |
phase1/ | Phase-1 PyTorch-level scripts (LoRA merge, sync removal, CUDA Graph, torch.compile) |
patches/ | causal-conv1d build patch for sm_103 (phase 1 only) and its license |
results/ | JevBench per-task results for the original and each optimized version |
docs/ | Report web page (index.html + static/, served by GitHub Pages at https://yiqilyu.me/open-jev-fast/), PDF report, figures, and the scripts that generate them |
3308a15), 2026. MIT.1d4bf0f). Apache-2.0.f8ce713), 2026. MIT.mma.sync, ldmatrix, cp.async, bar.sync). https://docs.nvidia.com/cuda/parallel-thread-execution/MIT for the code in this repository (LICENSE). The report web page (docs/index.html, docs/static/css/index.css) is adapted from the Academic Project Page Template and is under CC BY-SA 4.0. Models, datasets and third-party libraries keep their own licenses; see THIRD_PARTY_NOTICES.md.
222 followers · starred Oct 2026
152 followers · starred Sep 2026
Faster inference backend for Open-Jev-27B: fused CUDA kernels, prefix tree, CUDA Graphs (B300, bf16)
See the code
A faster inference backend for Open-Jev. It runs locally as a drop-in replacement for Open-Jev's own local server (python -m jev.server, same request format), with the same model (Open-Jev-27B-v1.1 on Qwen3.8-27B), in bf16 with no quantization. It replaces the model forward pass with hand-written CUDA kernels (including its own Gated DeltaNet and tree-attention kernels), a prefix tree that computes shared prompt text once, tuned matrix multiplies and CUDA Graphs.
Open-Jev is by the Open-Jev contributors; this repository runs on top of it and needs an Open-Jev installation and the model weights. Built on: Open-Jev [1], Open-Jev-27B-v1.1 / Qwen3.8-27B [2, 3], flash-linear-attention [4], Hugging Face Transformers [7], PEFT [8], PyTorch [9]; evaluated with JevBench [11]. What is used from each project is listed in THIRD_PARTY_NOTICES.md.
| Open-Jev, default PyTorch path | Open-Jev + FLA kernels | open-jev-fast | |
|---|---|---|---|
| Example request, one inference (3 questions, 7 candidates, 539 tokens; forward pass + scoring head) | 256.0 ms | 103.7 ms | 17.3 ms (14.8× / 6.0×) |
| JevBench, mean per-task latency (231 tasks, HTTP, concurrency 1) | — | 258 ms | 42.0 ms (6.1×) |
| JevBench P50 / P95 / max | — | 150 / 802 / 1489 ms | 17.4 / 137 / 208 ms |
| JevBench accuracy (our runs) | — | 198/231 | 197/231 (one near-tie prediction changed, see below) |
Open-Jev's default install does not include flash-linear-attention (FLA) [4], so Transformers runs the linear-attention layers as plain PyTorch ops: that is the first column. The second column is Open-Jev with FLA installed, which is also what our JevBench baseline server used.

Example request: 3 questions, 7 candidates, 539 tokens. Median latency of the forward pass plus scoring head.
The Open-Jev-27B-v1.1 model card reports 197/231 on public JevBench for this checkpoint; our runs of the original server scored 198/231.
Single inference (example request).
configs/example-request.json, a customer-service conversation with 3 questions (routing, 1 of 3; refund review, yes/no; urgency, 3 levels). That is 7 candidate prompts and 539 tokens.bench/e2e_bench.py, run one after another on the same GPU.
torch.cuda.synchronize() before and after each (bench/logs/e2e_bench.log; values in results/e2e_latency.json).JevBench.
f8ce713, run once in order at concurrency 1.TypeSafeAdapter: tokenization, HTTP and JSON included, with a new connection per task. The client runs on the same machine as the server, for both servers.score_task.jev.server and this server ran with --max-length 16384, so that every JevBench task fits. The model card's saved limit is 4,096 tokens per candidate.results/summary.json). The earlier published comparison (original mean 703 ms) used a first pass of the original.results/ (phase 1, service v1 and v3) were measured with the client on another machine of the cluster, which adds about 25 ms per task through the new connection; see results/summary.json.Per-task results for every version are in results/ (task ID, prediction, correctness, latency); results/summary.json has the aggregates.
Without FLA, the Gated DeltaNet layers run as many small PyTorch ops (256 ms). With FLA, the original is CPU-bound: each request launches about 5000 small GPU kernels, and the GPU is busy for only about 51 of its ~103 ms. The seven candidate prompts also repeat most of their text.
Phase 1, PyTorch level (103 → 32.4 ms).
src/graph_patches.py; both are "skip the mask if there is no padding" shortcuts, so the math is unchanged).torch.compile.Phase 2, hand-written CUDA (32.4 → 20.1 ms). This path replaces the phase-1 path. (Phase 3 below replaces the Gated DeltaNet core and, for trees up to 384 rows, full attention.)
Six fused kernels (src/kernels.cu) take over every non-matmul operation in a layer:
Matrix multiplies are merged from 9 to 4 per layer, and kernels per request drop from about 5000 to 945. Each kernel reproduces the bf16 rounding points of the Transformers reference [7] and FLA [4]. In phase 2 the Gated DeltaNet core was still FLA's chunk_gated_delta_rule [4, 5] and full attention was PyTorch SDPA.
Prefix tree (src/fastmodel.py: gtree_build, forward_gtree). One packed forward pass computes the shared context once, each question's text once, and each candidate's tail, so the weights are read once. For the example request, computed rows go from 574 to 277.
Related ideas: shared-prefix attention [12, 13] and tree attention masks [14, 15].
Matrix multiplies (src/lt.cpp):
Serving (src/server.py):
TCP_NODELAYPhase 3, hand-written kernels for the remaining hot spots (20.1 → 17.3 ms).
gdn_fused6_k / gdn_fused4_k in src/kernels.cu) replaces FLA's chunk_gated_delta_rule on the prefix-tree path: 74 µs → 36.5 µs per layer.
mma.sync (bf16 in, fp32 accumulate) with ldmatrix, and tiles arrive by cp.async, all as inline PTX. The fp32 state stays in registers. The 64×64 inverse follows FLA's block order with tf32 MMAs, and every bf16 rounding point of FLA [4, 5] is kept.fattn_k) replaces SDPA and the separate gate multiply when the tree has at most 384 rows: 21.4 µs → 12.7 µs per layer.
bench/logs/r4/.Matrix multiplies are now 68% of the example's latency (11.8 of 17.4 ms). Under sustained load they run against the B300's 1,100 W power limit, with the SM clock near 1.2 GHz.
A step-by-step breakdown, the GPU time budget and the failed attempts are in the report.
We checked at three levels:
bench/logs/correct.log);bench/logs/r4/gdn_kernel.log);bench/logs/r4/tree_attention.log).Probability differences from the original grow with input length, because bf16 rounding-order differences accumulate through 64 layers and the recurrent state:
tests/test_gtree.py; the previous version: 0.035, bench/logs/gtree2.log).On JevBench, two tasks changed prediction versus the original:
hard-opus-c-long_policy-03 is wrong both before and after.hard-opus-a-temporal_numeric-09 is a near-tie prediction that changed: the original gives no/yes = 0.504/0.496, merging LoRA alone gives 0.503/0.497, and the hand-written kernels give 0.496/0.504.Phase 3 changed no JevBench prediction relative to the previous release (v3).
mma.sync, ldmatrix, cp.async; sm_80 or newer), compiled for sm_103 by default. For another GPU with enough memory, change the -gencode flag in src/ext.py. That path is untested, and the speedups will differ.nvidia-smi after the full JevBench run), so an 80 GB GPU is not enough as is.
tests/ need about as much.Requirements: a GPU with about 98 GiB of free memory (tested only on an NVIDIA B300), CUDA 13 (nvcc, cuBLASLt), and Python with Open-Jev installed (commit 3308a15) and its dependencies. We used torch 2.14 (cu130), transformers 5.10.2, peft 0.19.1, flash-linear-attention 0.5.2 and triton 3.8.0.
git clone https://github.com/Zefan-Cai/Open-Jev.git && (cd Open-Jev && git checkout 3308a15 && pip install -e '.[train]')
pip install flash-linear-attention==0.5.2
hf download ZefanCai/Open-Jev-27B-v1.1 --local-dir ./open-jev-27b-v1.1 # Open-Jev's loader fetches the pinned Qwen3.8-27B base
export OPEN_JEV_DIR=$PWD/Open-Jev OJ_CKPT=$PWD/open-jev-27b-v1.1/package/checkpoint
export CUDA_HOME=/path/to/cuda-13 # needs bin/nvcc, include/, lib/libcublasLt.so
./scripts/launch_server.sh # local server, same request format as jev.server: POST http://localhost:18791/v1/systemone
Kernels are compiled on first import (torch.utils.cpp_extension.load_inline).
Correctness and benchmarks (each loads the original model as the reference):
export JEVBENCH_DIR=/path/to/jevbench # https://github.com/fstandhartinger/jevbench @ f8ce713 (long test inputs + runner)
python tests/test_correct.py # kernel-by-kernel, 64-layer and probability comparison
python tests/test_gtree.py # two-level prefix tree vs original + CUDA Graph timing
python tests/test_r4_gdn.py # Gated DeltaNet kernel vs FLA, timing, whole-model probabilities
JEVBENCH_DIR=... python tests/test_r4_fattn.py # tree attention kernel vs cuDNN SDPA
for m in torch fla fast; do E2E_MODE=$m python bench/e2e_bench.py; done # the headline numbers (256.0 / 103.7 / 17.3 ms)
python bench/run_jevbench.py http://localhost:18791 open-jev out.json
| Path | Contents |
|---|---|
src/ | CUDA kernels (kernels.cu, built by ext.py), cuBLASLt wrapper (lt.cpp, lt_ext.py), fast backbone and prefix tree (fastmodel.py), Transformers patches (graph_patches.py), server (server.py) |
tests/ | Correctness tests against the original implementation |
bench/ | Benchmarks (GEMM, split-K, cuBLASLt, FLA, kernel phases, profiling) and the JevBench runner; bench/logs/ has their recorded output, bench/logs/r4/ the phase-3 (round 4) experiments |
phase1/ | Phase-1 PyTorch-level scripts (LoRA merge, sync removal, CUDA Graph, torch.compile) |
patches/ | causal-conv1d build patch for sm_103 (phase 1 only) and its license |
results/ | JevBench per-task results for the original and each optimized version |
docs/ | Report web page (index.html + static/, served by GitHub Pages at https://yiqilyu.me/open-jev-fast/), PDF report, figures, and the scripts that generate them |
3308a15), 2026. MIT.1d4bf0f). Apache-2.0.f8ce713), 2026. MIT.mma.sync, ldmatrix, cp.async, bar.sync). https://docs.nvidia.com/cuda/parallel-thread-execution/MIT for the code in this repository (LICENSE). The report web page (docs/index.html, docs/static/css/index.css) is adapted from the Academic Project Page Template and is under CC BY-SA 4.0. Models, datasets and third-party libraries keep their own licenses; see THIRD_PARTY_NOTICES.md.
222 followers · starred Oct 2026
152 followers · starred Sep 2026