COREY: Entropy-Guided Runtime Chunk Scheduling for Selective Scan Kernels
Organizations: Auckland University of Technology; Resideo Technologies, Inc. · Guilin University of Electronic Technology · Auckland University of Technology
Abstract
Mamba selective state space models (SSMs) provide linear-time sequence modeling but remain sensitive to selective-scan chunk scheduling. We present COREY, a concept-and-feasibility runtime scheduler that maps fixed-bin activation entropy to chunk size. We evaluate COREY in three tiers: a prototype cost model, real-checkpoint kernel timing, and routed end-to-end ablations on modern GPUs. At the kernel level, a calibrated rule, , recovers the locally optimal chunk and matches a one-time static oracle, yielding lower latency than an unoptimized baseline on a consumer GPU and -- lower latency on a data-center accelerator. Routing this choice into a patched live scan kernel closes the engineering loop without improving end-to-end speed: in unified routed ablations, the best static chunk outperforms all entropy-guided and proxy schedulers. Sampled-histogram COREY adds overhead; a guarded fallback to Static-512 reduces this to ; and a lightweight sequence-length-keyed table further reduces it to . However, both remain slower than the static oracle because they retain scheduling cost. On an 80-prompt LongBench subset, passive and routed inference are exactly output-equivalent, with greedy-token agreement and zero metric deltas. A mixed-regime study shows that a single sequence-length rule matches the per-regime chunk oracle for balanced serving. COREY is therefore validated as a quality-preserving scheduling prototype, but current entropy statistics are not a robust throughput win over static chunk tuning on measured SSM checkpoint workloads. SourceCode: https://github.com/mabo1215/COREY_Transformer/.
Figures & tables
| Distribution | (nats) | Chunk ( ) | Chunk ( ) | ||
|---|---|---|---|---|---|
| Standard normal | |||||
| Standard normal | |||||
| Standard normal | |||||
| Standard normal | |||||
| Uniform | |||||
| Uniform |
| Policy | Chunk | Latency (ms) | Speedup |
|---|---|---|---|
| Static-64 | |||
| COREY (legacy ) | |||
| COREY (default ) | |||
| Static-512 (offline oracle) |
| Distribution | (nats) | Chunk | Calls | Latency (ms) | Speedup |
|---|---|---|---|---|---|
| Uniform | 5.545 | 512 | 8 | ||
| Normal (standard) | 4.612 | 256 | 16 | ||
| Laplace | 3.892 | 256 | 16 | ||
| Sparse (10% nz) | 0.789 | 64 | 64 | ||
| Sparse (2% nz) | 0.192 | 32 | 128 | ||
| Static-64 reference | 64 | 64 | ms | ||
| Platform | Configuration | Latency (ms) | Overhead |
|---|---|---|---|
| Consumer GPU | Passive (stock) | — | |
| Consumer GPU | Active, all 48 layers | ||
| Consumer GPU | Active, layer sampling | ||
| Data-center accel. | Passive (stock) | — | |
| Data-center accel. | Active hook only | ||
| Per-call scheduler cost (isolated) | ms | — | |
| Configuration | Scheduler | Latency (ms) | Slowdown vs. best static | Chunk distribution |
|---|---|---|---|---|
| Static chunk | constant | |||
| Static chunk | constant | |||
| Static chunk (oracle) | constant | |||
| Static chunk | constant | |||
| Static chunk | constant | |||
| No entropy | midpoint |
| Regime | Chunk 128 | Chunk 256 | Chunk 512 | Best |
| Short conversational ( 25 tok) | 184.1 5.6 | 185.5 5.4 | 187.6 5.5 | 128 |
| Long-document QA ( 1500 tok) | 307.8 4.6 | 306.0 5.2 | 305.0 3.9 | 512 |
| Source code ( 2100 tok) | 349.1 4.6 | 347.3 4.9 | 345.9 5.0 | 512 |
| Structured logs ( 2048 tok) | 347.6 3.3 | 342.6 4.8 | 342.7 3.1 | |
| Tabular data ( 2048 tok) | 371.5 9.9 | 349.8 3.8 | 349.7 3.9 | 512 |
| Repetitive policy ( 1550 tok) | 319.5 4.5 | 312.9 5.6 | 312.5 2.7 | 512 |
| Scheduler | Avg Latency (ms) | vs. Static-512 |
|---|---|---|
| Static-512 (global baseline) | — | |
| Learned-table (seq-len rule) | ( ms) | |
| Per-regime oracle (upper bound) | ( ) | |
| Data-center reference (different hardware; not directly comparable to rows above): | ||
| Guarded sampled-histogram † | † | |
| : Data-center accelerator, warmup , 976-token prompt; guard fires (chunk every call); | ||
| NarrativeQA | Qasper | MultiFieldQA-EN | GovReport | All | |
|---|---|---|---|---|---|
| Exact match | |||||
| PPL ratio | (all 80 prompts) | ||||
Appendix figures & tables33 assets
Supplementary material from the paper’s appendix.
Appendix
| Device | Mean Latency (ms) | Std (ms) | Repeats |
|---|---|---|---|
| TPU v4-8 (PyTorch XLA) | |||
| RTX 3070 (static-512, Triton) † |
| Parameter | Value |
|---|---|
| Fusion weights | |
| Default threshold | 0.52 |
| Threshold sweep | |
| Histogram bins and | 64, |
| EMA decay | 0.85 |
| Static-fusion group size | 3 operators |
| Configuration | Fusion depth | Surr. lat. (ms) | DRAM B/tok | Diagnostic proxy |
|---|---|---|---|---|
| No-signal | 1.00 | 100.94 | 122.98 | 0.0000 |
| Static fusion | 2.33 | 87.22 | 102.36 | 0.0851 |
| Arithmetic-only ( ) | 2.33 | 83.79 | — | — |
| Entropy-only ( ) | 1.08 | 99.07 | — | — |
| COREY default | 3.50 | 77.97 | 90.58 | 0.0000 |
| Policy | Model | NarrQA | Qasper | GovRpt | WT103 PPL | PG19 PPL | Avg Lat. (ms) |
|---|---|---|---|---|---|---|---|
| off | Mamba-370M | 0.0299 | 0.0458 | 0.1451 | 556.93 | 17.20 | 5142 |
| off | Mamba-1.4B | 0.0502 | 0.0827 | 0.1750 | 323.13 | 13.79 | 5552 |
| off | Mamba-2.8B | 0.0445 | 0.0399 | 0.1239 | 329.80 | 12.68 | 7343 |
| static | Mamba-370M | 0.0299 | 0.0458 | 0.1451 | 556.93 | 17.20 | 5401 |
| static | Mamba-1.4B | 0.0502 | 0.0827 | 0.1750 | 323.13 | 13.79 | 5788 |
| static | Mamba-2.8B | 0.0445 | 0.0399 | 0.1239 | 329.80 | 12.68 | 2,068 ‡ |
| Policy | Status | Latency (ms) | Tokens/s | Token-F1 |
|---|---|---|---|---|
| off | ok | 2846.8980 | 11.2403 | 0.148148 |
| static | ok | 2309.8472 | 13.8537 | 0.148148 |
| corey | ok | 2376.1357 | 13.4672 | 0.148148 |
| Scope | Mean | Std | p5 | p95 | Coarse bucket(s) | |
|---|---|---|---|---|---|---|
| All prompts | 80 | 4.022 | 0.092 | 3.871 | 4.139 | 100% in 256 |
| NarrativeQA | 20 | 3.999 | 0.079 | 3.887 | 4.138 | 100% in 256 |
| Qasper | 20 | 4.032 | 0.083 | 3.891 | 4.127 | 100% in 256 |
| MultiFieldQA-EN | 20 | 4.042 | 0.102 | 3.931 | 4.224 | 100% in 256 |
| GovReport | 20 | 4.017 | 0.096 | 3.869 | 4.130 | 100% in 256 |
| Regime | Entropy mean std | Prompts | Aggregate chunk distribution |
|---|---|---|---|
| Templated / repetitive | 20 | 128:4, 256:952, 512:4 | |
| Code-like / structured | 20 | 256:960 | |
| Dense narrative | 20 | 256:960 |
| Regime | Entropy mean std | Prompts | Aggregate chunk distribution |
|---|---|---|---|
| Extra code | 20 | 256:960 | |
| Extra logs | 20 | 256:960 | |
| Extra repetition | 20 | 256:960 | |
| Extra tables | 20 | 256:960 |
| Configuration | Chunk | Kernel calls | Latency (ms) | Speedup vs. static-64 |
|---|---|---|---|---|
| static-32 | 32 | 128 | ||
| static-64 | 64 | 64 | ||
| static-128 | 128 | 32 | ||
| corey-256 (legacy, ) | 256 | 16 | ||
| corey-512 (default, ) | 512 | 8 | ||
| static-512 | 512 | 8 |
| Setting | Static-64 (ms) | COREY chunk | COREY (ms) | Speedup | Static-512 oracle (ms) |
|---|---|---|---|---|---|
| H800 FP16, | 256 | ||||
| H800 BF16, | 256 | ||||
| H800 FP16, | 256 |
| Hardware | Policy | Chunk | Calls | Lat. (ms) | Std (ms) | Spdup-A | Spdup-B |
| Consumer GPU (CUDA 12.8, WSL2) | |||||||
| Static-64 | 64 | 64 | |||||
| COREY (legacy, ) | 256 | 16 | |||||
| COREY (default, ) | 512 | 8 | |||||
| Static-512 (offline oracle) | 512 | 8 | |||||
| TPU (torch_xla) | |||||||
| W1 benchmark ( nats) | Real checkpoint mean ( nats) | |||||
| Chunk | Latency (ms) | Chunk | Latency (ms) | |||
| 1.000 | 512 | 0.748 | 0.966 | 512 | 0.748 | |
| 5.0 | 0.921 | 512 | 0.748 | 0.804 | 512 | 0.748 |
| 6.0 | 0.767 | 512 | 0.748 | 0.670 | 256 | 1.148 |
| 8.0 ⋆ (legacy) | 0.576 | 256 | 1.148 | 0.503 | 256 | 1.148 |
| Distribution | (nats) | Chunk ⋄ | Chunk (fixed ) | Lat ⋄ (ms) | |||
|---|---|---|---|---|---|---|---|
| standard normal | 32 | 2.644 | 3.466 | 0.763 | 512 | 256 | 0.748 |
| standard normal | 64 | 3.334 | 4.159 | 0.802 | 512 | 256 | 0.748 |
| standard normal | 128 | 4.027 | 4.852 | 0.830 | 512 | 256 | 0.748 |
| standard normal | 256 | 4.720 | 5.545 | 0.851 | 512 | 256 | 0.748 |
| standard normal | 512 | 5.413 | 6.238 | 0.868 | 512 | 256 | 0.748 |
| standard normal | 1024 | 6.106 | 6.931 | 0.881 | 512 | 512 | 0.748 |
| Model | GPU | Prompt tok. | Base Lat. (ms) | Hook Lat. (ms) | Delta (%) | Score | Entropy | Tile |
|---|---|---|---|---|---|---|---|---|
| Mamba-370M | RTX 3070 | 512 | 2758.55 | 2658.39 | 0.0000 | 4.18 | 288 | |
| Mamba-370M | RTX 3090 | 512 | 2675.36 | 2567.73 | 0.0000 | 4.18 | 288 | |
| Mamba-1.4B | RTX 3090 | 512 | 2644.27 | 2609.94 | 0.0000 | 5.17 | 352 |
| Configuration | Latency (ms) | Overhead |
|---|---|---|
| Passive (stock fast path) | — | |
| Active (all 48 layers) | ||
| Active ( layer sampling, estimated) | ||
| Per-call scheduler cost (isolated) | ms | — |
| Configuration | Latency (ms) | vs. Passive |
|---|---|---|
| Passive (stock fast path) | ||
| Active hook only | ||
| Active + routed-call scaffold |
| Scheduler | Prompt | Repeats | Passive (ms) | Active+routed (ms) | vs. Passive |
|---|---|---|---|---|---|
| Full histogram | 122 tokens | 50 | |||
| Sampled histogram, stride 8 | 976 tokens | 50 | |||
| Constant chunk 512 | 976 tokens | 50 |
| Run | Configuration | Chunk | Active+routed (ms) | vs. best static | Chunk distribution |
|---|---|---|---|---|---|
| Full sweep | Static oracle | 128 | |||
| Full sweep | Adaptive sampled hist., stride 8 | – | |||
| Confirm subset | Static oracle | 1024 | |||
| Confirm subset | Adaptive sampled hist., stride 8 | – |
| Configuration | Scheduler | Active+routed (ms) | vs. passive | vs. best static | Chunk distribution |
|---|---|---|---|---|---|
| Static chunk 128 | constant | ||||
| Static chunk 256 | constant | ||||
| Static chunk 512 | constant | ||||
| Static chunk 1024 | constant | ||||
| Static chunk 2048 | constant | ||||
| No entropy | midpoint |
| Task | Exact match | Metric | Passive mean | Routed mean | Metric | PPL ratio | |
|---|---|---|---|---|---|---|---|
| NarrativeQA | 20 | token-F1 | |||||
| Qasper | 20 | token-F1 | |||||
| MultifieldQA-EN | 20 | exact-match | |||||
| GovReport | 20 | ROUGE-L | |||||
| Aggregate | 80 | 80/80 ( ) | — | — | — | all tasks | all |
| Layer | (nats) | Chunk | vs. synthetic | W1 ref. speedup |
|---|---|---|---|---|
| 0 | 2.27 | 128 | lower H; chunk differs | 1.92 |
| 8 | 2.91 | 256 | consistent | 3.24 |
| 16 | 3.22 | 256 | consistent | 3.24 |
| 24 | 3.29 | 256 | consistent | 3.24 |
| 32 | 3.61 | 256 | consistent | 3.24 |
| 40 | 3.54 | 256 | consistent | 3.24 |
| Hardware | Policy | Latency (ms) | Launches | CUDA Kernels | CUDA Time ( s) |
| RTX 3090 / CUDA 12.1 / Linux (4 GPU server), PyTorch 2.4.0, Triton 3.0 | |||||
| policy_off | 14.964 | 4096 | 16 | 19.1 | |
| policy_static | 2.216 | 64 | 16 | 18.1 | |
| policy_corey | 0.308 | 9 | 9 | 11.5 | |
| Speedup vs. policy_off ‡ | static: | corey: | |||
| RTX 4050 Laptop / CUDA 12.8 / WSL2, PyTorch 2.11.0, Triton 3.6 | |||||
| Platform | Model | NarrQA | Qasper | MF-EN | GovRpt | PPL | PPL | Avg Lat. (ms) |
|---|---|---|---|---|---|---|---|---|
| RTX 3070 / CUDA 12.8 | Mamba-370M | 0.0135 | 0.0350 | 0.000 | 0.1370 | 809.36 | 14.68 | 1384.25 |
| RTX 3070 / CUDA 12.8 | Mamba-1.4B | 0.0191 | 0.0460 | 0.000 | 0.1498 | 1128.40 | 11.66 | 2868.74 |
| RTX 3070 / CUDA 12.8 | Pythia-410M | 0.0190 | 0.0392 | 0.000 | 0.1550 | 5901.47 | – | 624.43 |
| RTX 3090 / CUDA 12.1 (1-GPU) | Mamba-370M | 0.0135 | 0.0443 | 0.000 | 0.1459 | – | – | 27205.05 |
| RTX 3090 / CUDA 12.1 (1-GPU) | Mamba-1.4B | 0.0191 | 0.0569 | 0.000 | 0.1582 | – | – | – ⋆ |
| RTX 3090 / CUDA 12.1 (2-GPU) | Mamba-1.4B | 0.0191 | 0.0569 | 0.000 | 0.1561 | – | – | 27971.14 |
| # GPUs | Wall-clock (s) | Agg. tok/s | Speedup |
|---|---|---|---|
| 1 (sequential) | 2154.3 | 5.04 | |
| 2 (data-parallel) | 1019.5 | 10.56 | |
| 4 (data-parallel) | 625.3 | 19.03 |
| Regime | Policy | Launches | Surr. lat. (ms) | Red. (%) | Solver ( s) | |
|---|---|---|---|---|---|---|
| 4 | low | no-fusion | 4 | 0.206 | — | — |
| 4 | low | static-3 | 2 | 0.103 | 50.0 | — |
| 4 | low | COREY | 1 | 0.052 | 75.0 | 211.7 |
| 4 | mixed | no-fusion | 4 | 0.206 | — | — |
| 4 | mixed | static-3 | 2 | 0.103 | 50.0 | — |
| 4 | mixed | COREY | 1 | 0.052 | 75.0 | 114.4 |
| Model | Arch | Platform | NarrQA | Qasper | GovRpt | PPL | Mean Lat. (ms) |
|---|---|---|---|---|---|---|---|
| Mamba-370M | Mamba-1 | RTX 3070 FP16 | 0.0135 | 0.0350 | 0.1370 | 809.4 | 1384 |
| Mamba-1.4B | Mamba-1 | RTX 3070 FP16 | 0.0191 | 0.0460 | 0.1498 | 1128.4 | 2869 |
| Pythia-410M | GPT-Neo | RTX 3070 FP16 | 0.0190 | 0.0392 | 0.1550 | 5901.5 | 624 |
| RWKV-4-430M | RWKV | CPU FP32 (ref.) | 0.028 | 0.031 | 0.121 | 13.7 | 134 † |
| GPT-2+FA2 | Attn. | RTX 3090 (ref.) | 0.019 | 0.022 | 0.108 | 29.4 | 58 † |
| Mamba2-2.7B | Mamba-2 | RTX 3070 FP16 ‡ | 0.098 | 0.106 | 0.044 § | — | 1,820 |
| Seq. len | Latency (ms) | Tokens/s | Nominal TFLOP/s |
|---|---|---|---|
| 1024 | |||
| 2048 | |||
| 4096 | |||
| 8192 |
| Task | Mean Lat. (ms) | Std (ms) | Tok/s |
|---|---|---|---|
| NarrativeQA | 1583 | 776 | 21.96 |
| Qasper | 1524 | 537 | 22.14 |
| GovReport | 2615 | 530 | 12.74 |
| MultifieldQA-EN | 1516 | 500 | 22.15 |
| Mean (short-ctx) | 1541 | — | 22.08 |
| Policy | NarrQA Lat. (ms) | Qasper Lat. (ms) | GovRpt Lat. (ms) | MField Lat. (ms) | Mean Tok/s |
|---|---|---|---|---|---|
| corey | 1,361 † | 1,363 † | 1,543 | 1,437 | 22.9 |
| static | 1,430 | 1,440 | 1,546 | 1,439 | 22.6 |
| : ; all other cells . | |||||
| Scheduler | Avg Lat. (ms) | vs. Static-512 | Source |
|---|---|---|---|
| Static-512 (global baseline) | 317.1 | — | RTX 3070 sweep |
| Learned-table (seq-len rule) | 316.7 | ( ms) | derived from sweep |
| Per-regime oracle (upper bound) | 316.7 | ( ms) | RTX 3070 sweep |
| Guarded sampled-hist (fallback=512) | 903.0 ms † | ( ms) † | H800 routed † |
| Learned-table (seq-len rule, H800) | 897.6 ms † | ( ms) † | H800 routed † |
| : H800 PCIe, , warmup , 976-token prompt; both variants route to chunk ; | |||
LLM Inference Scheduling
Large language model inference scheduling allocates requests, batches, compute, and KV-cache memory to balance latency, throughput, and service-level objectives.
See all 160 papers