Skip to content

perf(gdn): dispatch exact causal-conv chunks - #127

Closed
richiejp wants to merge 4 commits into
mudler:mainfrom
richiejp:row/KERNEL-SSM-MAMBA-EXACT-CHUNKS
Closed

perf(gdn): dispatch exact causal-conv chunks#127
richiejp wants to merge 4 commits into
mudler:mainfrom
richiejp:row/KERNEL-SSM-MAMBA-EXACT-CHUNKS

Conversation

@richiejp

@richiejp richiejp commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Row

KERNEL-SSM-MAMBA — exact causal-convolution chunk-dispatch sublever; one row per PR.

Before starting

  • Issue/PR search and existing claim: no matching open issue or PR; this clean transplant supersedes the earlier local seven-commit benchmark branch.
  • Roadmap or matrix row, plus scripts/ready-for-helper.py result when applicable: .agents/kernel-matrix.md:156 (KERNEL-SSM-MAMBA, INVENTORIED); feeds ROAD-V1-C2-LOCAL-BF16. The scoped spike is .agents/specs/sm120-qwen35-conv-chunking-2026-08-07.md.
  • Exact current-code and test/evidence anchors inspected: src/vt/cuda/cuda_gdn.cu:702-819, include/vllm/v1/attention/backends/gdn_attn.h:33-43, tests/vt/test_ops_gdn.cpp, and pinned vLLM vllm/model_executor/layers/mamba/ops/causal_conv1d.py:15-28,71-79,123-124 at 555967922.

What changed

Build exact (sequence, 8-token chunk) causal-convolution descriptors once per engine step, upload them once, reuse them across GDN layers, and dispatch one register-kernel program per descriptor. Exact dispatch is default ON; VT_CONV_EXACT_CHUNKS=0 restores the former whole-sequence mapping and VT_CONV_REG=0 retains the tiled/scalar rollback. The PR also corrects vllm-bench to drive the production AsyncLLM frontend used to select and measure this kernel lever.

Evidence

  • scripts/agent-preflight.sh passes: all record gates, mutation suites, live-row audit, and committed-range document checks green against canonical upstream/main f91a5917a.
  • Tests covering this change: contained CPU/CUDA build; focused CPU CTest 6/6; full CUDA test_ops_gdn 66/66 cases, 4300/4300 assertions; cached Qwen3.5-4B 3/3 cases, 1672/1672 assertions. Rollback/default production token files compare byte-for-byte.
  • Same-change doc obligations: docs/STATUS.md, docs/BENCHMARKS.md, and docs/FEATURES.md updated; complete repro and profiler evidence is in docs/bench-evidence/qwen35-4b-sm120-main-20260807.md.

Speed claims

  • The operator ran the numbers under ${GPU_LOCK} and they are recorded in docs/BENCHMARKS.md with the repro recipe.

On the local RTX 5070 Ti / Qwen3.5-4B c32 workload, a clean-current-main same-binary Nsight Systems comparison reduces causal-conv GPU time from 720.216507 ms to 234.379395 ms (3.072866x) and improves the profiled enclosing run from 6587.66 to 6727.35 tok/s (+2.1205%), with byte-identical tokens. Three alternating unprofiled pairs measured +2.152% total/output throughput and improvements in TTFT, TPOT/ITL, and E2E latency. The sealed same-hardware vLLM throughput ratio becomes 1.021246x.

Honest gaps

  • The hardware-unavailable 27B and 35B release gates remain pending; the 4B result is not extrapolated to them.
  • Against the sealed vLLM denominator, TTFT, TPOT/ITL, and peak VRAM remain open. The causal-conv kernel retains a 1.611730x residual gap.
  • Fresh full-oracle reruns were voided by FlashInfer/Torch/Triton JIT infrastructure failures, so the accepted cross-engine comparison retains the sealed same-box denominator; same-binary A/B and current-main reproduction are fresh.
  • Broad generic Mamba support remains inventoried; this changes the existing Qwen GDN-specific path.
  • The PR is draft pending independent review; no independent reviewer was available in this single-agent run.

@richiejp
richiejp force-pushed the row/KERNEL-SSM-MAMBA-EXACT-CHUNKS branch 3 times, most recently from ac373b7 to c3bb0f3 Compare August 8, 2026 06:59
@localai-bot

Copy link
Copy Markdown
Collaborator

Operator triage: parking blocker named per protocol — this draft is CONFLICTING against main (the GDN/qwen3_5 files moved under it: the Kimi runner fold #122 landed config-side GDN-geometry synthesis and main took several Vulkan/device lanes). Since it touches SACRED-adjacent files (qwen3_5.cpp, gdn_attn, cuda_gdn.cu), the standing bar applies: rebase onto current main, re-run the qwen35/qwen27 paged-forward + GDN suites on the rebased tree, and mark ready — then it enters the normal mutation-review + land flow. Happy to do the record-file reconciliation at landing (keyed files = main wholesale + your rows) if you handle the code-side rebase.

richiejp added a commit to richiejp/vllm.cpp that referenced this pull request Aug 8, 2026
Make the row-PR provenance visible to GitHub's synthetic merge check without changing the measured tree.

FOLLOWING_AGENTS_PROTOCOL

Assisted-by: Codex:gpt-5.6-sol [Codex]
@richiejp
richiejp force-pushed the row/KERNEL-SSM-MAMBA-EXACT-CHUNKS branch from c3bb0f3 to 0f7efbb Compare August 8, 2026 08:08
richiejp added a commit to richiejp/vllm.cpp that referenced this pull request Aug 8, 2026
Make the row-PR provenance visible to GitHub's synthetic merge check without changing the measured tree.

FOLLOWING_AGENTS_PROTOCOL

Assisted-by: Codex:gpt-5.6-sol [Codex]
@richiejp
richiejp force-pushed the row/KERNEL-SSM-MAMBA-EXACT-CHUNKS branch from 0f7efbb to ddefcb9 Compare August 8, 2026 08:30
mudler added a commit that referenced this pull request Aug 8, 2026
The at-a-glance row, the section heading and the closed-row table all
called the benchmarked model Laguna-XS-2.1. The measured checkpoint is
poolside/Laguna-S-2.1-NVFP4: 118B total / ~8B active MoE, 48 layers,
256 experts, ~67 GiB.

The label came from the local checkpoint directory being named
laguna-xs-nvfp4. Evidence that the two names are one benchmark: the
same 37.55 -> 44.46 vs vLLM 43.10 pair appears in this file under
"Laguna-XS NVFP4" and in the same document's row for "Laguna-S-2.1 MoE
(LagunaForCausalLM, 118B/8B)", both dated 2026-08-04; and the NVFP4 arm
spec pins the checkpoint at poolside/Laguna-S-2.1-NVFP4, ~67 GiB, with
layers 1..47 MoE.

The section now states the model geometry and says where the XS label
came from, so it cannot drift back. The reproduce row keeps the real
directory name with a note that it holds the S-2.1 checkpoint.

Numbers, ratios and evidence anchors are unchanged; this is a naming
correction only. FEATURES.md and README are untouched: they list
"Laguna-S / Laguna-XS 2.1" as a model family, which is a separate
question from which checkpoint was measured.

No open issue or PR covers this (searched issues and PRs for laguna
naming; open PRs are #127, #128, #140, #141, none related).

FOLLOWING_AGENTS_PROTOCOL
Assisted-by: Claude Code:claude-opus-5 [ClaudeCode]
@richiejp
richiejp marked this pull request as ready for review August 8, 2026 11:04
richiejp added a commit to richiejp/vllm.cpp that referenced this pull request Aug 8, 2026
Make the row-PR provenance visible to GitHub's synthetic merge check without changing the measured tree.

FOLLOWING_AGENTS_PROTOCOL

Assisted-by: Codex:gpt-5.6-sol [Codex]
@richiejp
richiejp force-pushed the row/KERNEL-SSM-MAMBA-EXACT-CHUNKS branch from ddefcb9 to 604a378 Compare August 8, 2026 11:38
Build and upload exact causal-convolution work descriptors once per step, reuse them across GDN layers, and make the exact register-kernel mapping the default. Keep the production AsyncLLM benchmark path in the same checkpoint so the measured scheduler and kernel improvement is reproducible on current upstream/main.

Row: row/KERNEL-SSM-MAMBA-EXACT-CHUNKS

FOLLOWING_AGENTS_PROTOCOL

Assisted-by: Codex:gpt-5.6-sol [Codex]
Canonicalize semantic consumer bodies without Python-version-only AST fields, and gate the representation under Python 3.12 and 3.13.

FOLLOWING_AGENTS_PROTOCOL

Assisted-by: Codex:gpt-5.6-sol [Codex]
Make the row-PR provenance visible to GitHub's synthetic merge check without changing the measured tree.

FOLLOWING_AGENTS_PROTOCOL

Assisted-by: Codex:gpt-5.6-sol [Codex]
Record the merged Gemma-4 MoE path as known merged-GEMM drift and close the stale embeddings claim after PR mudler#137 landed.

FOLLOWING_AGENTS_PROTOCOL

Assisted-by: Codex:gpt-5.6-sol [Codex]
@richiejp
richiejp force-pushed the row/KERNEL-SSM-MAMBA-EXACT-CHUNKS branch from 604a378 to 32eb2f0 Compare August 8, 2026 13:39
mudler added a commit that referenced this pull request Aug 8, 2026
…re-push sandbox (#159)

Two guards on main were RED and between them blocked every open external
contributor PR (#127, #154, #155) and every push. Both premises were verified in
the tree before changing anything.

1) check-device-leakage: src/vllm/v1/worker/gpu/runner.cpp named
   vt::DeviceType::kCUDA in the device-agnostic shared layer (DSR bucket 'kcuda'
   1 > baseline 0). It came in with the QueueSupportsAsyncInputCombine rescope
   during the PR #140 fix round - ours, not the contributors'; richiejp reported
   it in #127's honest gaps. Fixed the way the guard's own message prescribes,
   mirroring the SupportsAuxStream precedent: ask the backend, not the device.
   New vt::Backend::SupportsAsyncSampledTokenReadback() (base false) answers
   whether the host may validly read the sampled token id back between steps;
   CPU overrides true (host and device memory are one allocation) and CUDA
   overrides true (the id is device-mirrored). The runner asks
   vt::TryGetBackend(queue.device.type), whose nullptr for a device absent from
   the build also subsumes the old #ifdef VLLM_CPP_CUDA guard.
   SEMANTICS UNCHANGED: CPU async-ON, CUDA async-ON, discrete non-CUDA (ROCm
   gfx1201) async-OFF - the "!"-token hazard stays closed.

2) .githooks/pre-push ran check-policy.py inside a PARTIAL export
   (README.md docs scripts .agents), but policy_contract.py:428 asserts AGENTS.md
   is a non-symlink regular file and resolves its Markdown links against that
   sandbox. AGENTS.md and its .env.example link were both missing, so the hook
   failed closed on content that is fine in the real tree - every push refused.
   EXPORT_PATHS is now a superset of what the CHECKERS read.

Gates: check-device-leakage RED->GREEN (kcuda=0, DSR 32 == baseline 32); all four
hook checkers OK in the reproduced sandbox; test_async_llm 8/8-347,
test_engine_core 6/6-44, test_llm_engine 11/11-204 (CPU still resolves async-ON);
clean -Werror CPU build; full 11-gate record battery green.

FOLLOWING_AGENTS_PROTOCOL
Assisted-by: Claude (Opus 5) via Claude Code

@localai-bot localai-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Verified on the merge result against current main, not just on the branch.

What I ran (merge of this branch into 1f3b7148, conflicts resolved):

  • Every scripts/check-*.py: green, including device-leakage.
  • Clean CPU build: 1103/1103 targets.
  • ctest: 356/356. One failure under -j8 (test_engine_core_proc) passes serially — the known parallel-starvation flake, not a regression from this change.

On the code: the exact (sequence, 8-token chunk) program list is the right mirror of upstream compute_causal_conv1d_metadata, and I like that the descriptor is optional on CausalConv1dArgs with the pair validated in vt::CausalConv1dFwd — CPU keeps its scalar reference and no other backend has to care. Default-ON with VT_CONV_EXACT_CHUNKS=0 as the same-binary rollback matches our parity-enabler policy exactly.

On the CI that was red: device-leakage was our blocker, not yours. runner.cpp named DeviceType::kCUDA in the device-agnostic layer — my own regression, which you flagged in the honest-gaps section of this PR. Fixed on main in #159 via a Backend::SupportsAsyncSampledTokenReadback capability, in the shape of SupportsAuxStream. Thanks for reporting it rather than working around it.

Conflicts were records-only and resolved per our rules: .agents/state.md and .agents/benchmark-record.md unioned as append-logs; scripts/merged-gemm-consistency-allowlist.txt had a gemma4_moe key added independently on both sides, kept as one entry.

Merge is prepared and green locally. It is queued behind a repo-wide agent-record break (.agents/policy-cutover points at a pre-squash SHA that never landed on main), which I have raised with mudler — nothing for you to do.

mudler added a commit that referenced this pull request Aug 8, 2026
perf(gdn): dispatch exact causal-conv chunks

Contributed by Richard Palethorpe <io@richiejp.com>; merged with --no-ff so the
four authored commits land under their own authorship.

Mirrors upstream compute_causal_conv1d_metadata: grid.y becomes a flattened
list of (sequence, 8-token chunk) programs instead of a rectangular grid that
either padded or ran sequences serially. The descriptor is optional on
CausalConv1dArgs and validated as a pair in vt::CausalConv1dFwd; CUDA consumes
it, CPU keeps its scalar reference. Default ON per the parity-enabler policy,
with VT_CONV_EXACT_CHUNKS=0 as the same-binary rollback. Contributor measured
720.047 -> 234.607 ms (3.07x) on the causal-conv family, sm_120 Qwen3.5-4B c32,
byte-identical output tokens.

The branch's only red check was device-leakage, which was OUR blocker: runner.cpp
named DeviceType::kCUDA in the device-agnostic layer. Fixed on main in #159.

Verified on the merge result: every scripts/check-*.py green, clean CPU build
1103/1103, ctest 356/356 (test_engine_core_proc fails only under -j8 and passes
serially, the known parallel-starvation flake). CI on the #165 landing branch
also had build-test-cpu, build-test-vulkan and device-leakage green.

Conflicts, three files, all records: .agents/state.md and
.agents/benchmark-record.md unioned per the append-log rule;
scripts/merged-gemm-consistency-allowlist.txt had a gemma4_moe key added
independently on both sides, kept as one entry with main's text.

FOLLOWING_AGENTS_PROTOCOL
Assisted-by: Claude Opus 5 (1M context)
localai-bot added a commit that referenced this pull request Aug 8, 2026
…-merge

Merge #127 (richiejp): perf(gdn) dispatch exact causal-conv chunks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants