Commit Graph

255 Commits

Author SHA1 Message Date
Claude
336f3349ca fix(submit): restore flash_attn prefill + all 38eca5c2 improvements
Keeps ALL infrastructure from the last 70 commits:
- paged_attn.py: ixformer native v1/v2 decode dispatch (Output TPS impact)
- protocol.py: extra='allow' (fixes ~180 rejected replay requests)
- qwen3_5.py: .float() router_logits, chunk_recurrent, index_combine
- 14 prebuilt .so (including corex_gdn_chunk_recurrent)
- patch_xformers: flash_attn_varlen_func + profiling guard (>32K→Q-tiling)

yaml: max-num-seqs=2, TOPK=1, gpu-mem=0.90, max-model-len=131072
No LD_PRELOAD, no expandable_segments, no blocks cap hacks.
2026-08-14 03:47:09 +00:00
Claude
67a5639c3c fix(submit): restore a3c45d3b-proven config + safe improvements
Based on a3c45d3b (last known working docker build):
- yaml: max-num-seqs=2 (fixes t2_n_2), TOPK_SOFTMAX=1 (use prebuilt .so)
- yaml: keep max-model-len=131072, gpu-mem=0.90 (prevents OOM)
- yaml: NO LD_PRELOAD (libcccl not built during docker build)
- xformers: revert to Q-tiling only (flash_attn caused OOM at profiling)
- .dockerignore: exclude all non-essential files from context
- remove libcccl_allocator.so from git tracking

What stays from recent work:
- 14 prebuilt .so (including corex_gdn_chunk_recurrent)
- qwen3_5.py with .float() fix and chunk_recurrent support
- All vendor_overrides and CCCL preload source (for future use)
2026-08-14 03:35:24 +00:00
Claude
bce79e44be perf(prefill): restore flash_attn_varlen_func with profiling safety guard
Restores ixformer flash_attn acceleration for prefill that was lost in
38eca5c2 revert. The OOM root cause was profiling-stage flash_attn on
131K dummy sequences, not flash_attn itself.

Fix: two-tier dispatch in _run_sdpa_fallback:
  1. flash_attn_varlen_func — real inference (verified 1.7x on BI-V100)
  2. Q-tiling fallback     — profiling stage (seq > 32K) or exception

Import path: ixformer.contrib.vllm_flash_attn.flash_attn_varlen_func
(canonical path matching ex_engine/python/corex_fa2.py Tier 1 and
ixformer_sdk/contrib/vllm_flash_attn/flash_attn_interface.py signature).

Reference sources:
  - ixformer_sdk/contrib/vllm_flash_attn/flash_attn_interface.py (API)
  - ex_engine/python/corex_fa2.py (dispatch pattern)
  - upstream_ref/xllm_latest/core/kernels/ilu/attention.cpp (C++ batch_prefill)
2026-08-14 02:51:47 +00:00
Claude
74ce61712b fix(build): update prebuilt CoreX artifact count 13→14 — SHA256SUMS has 14 entries after corex_gdn_chunk_recurrent.so was added
install_prebuilt_corex.sh asserted exactly 13 artifacts, but SHA256SUMS
now contains 14 (corex_gdn_chunk_recurrent.so was added in 9a52f057).
This mismatch causes Docker build to fail at:
  'expected 13 prebuilt CoreX artifacts, found 14'
2026-08-14 02:39:42 +00:00
Claude
38eca5c26a revert: restore a3c45d3b yaml + Q-tiling + remove all OOM hacks
Root cause of 10 consecutive OOM failures:
- 'return zeros during profiling' hack → vllm overestimates free memory
  → allocates 7942 blocks → first real request OOMs
- blocks cap 5000 → band-aid that masks profiling bug
- gpu-memory-utilization 0.80 → unnecessary reduction from working 0.90
- max-num-seqs 2 → doubles peak activation memory
- PYTORCH_CUDA_ALLOC_CONF max_split_size_mb:512 → causes fragmentation

Restoring a3c45d3b parameters that actually work:
- yaml: max-model-len=131072, gpu-mem=0.90, max-num-seqs=1, batched-tokens=8192
- patch_xformers_sdpa_seq.py: Q-tiling (real memory optimization, not zeros hack)
- patch_block_major_worker_capacity.py: no blocks cap, just reserve_block_major
- patch_ops.sh: remove all docker-build-time compilation (all .so are prebuilt)

Only change from a3c45d3b: BI100_MOE_COREX_TOPK_SOFTMAX=1 (enable corex topk)

Kept fixes:
- protocol.py extra=allow (recover 180 rejected replay requests)
- corex_gdn_chunk_recurrent.so pybind kwargs (prebuilt with fixed signature)
2026-08-14 02:28:48 +00:00
root
9a52f05783 prebuilt: add corex_gdn_chunk_recurrent.so with fixed pybind kwargs 2026-08-14 02:10:54 +00:00
Claude
bb0de83d45 fix(pybind): c10::optional<Tensor>() default — c10::nullopt not registered in pybind 2026-08-14 02:05:30 +00:00
Claude
768d89c31a fix(pybind): add py::arg + defaults to corex_gdn_chunk_recurrent
Python calls: _chunk_fn(q,k,v,g,beta, initial_state=, output_final_state=, use_qk_l2norm_in_kernel=)
C++ had: positional-only (query,key,value,g,beta,chunk_size,initial_state,output_final_state,use_qk_l2norm)

Fix: py::arg() naming + chunk_size=64 default (matches Python fallback).
Re-enable _HAS_COREX_GDN_CHUNK flag.

Rebuild on real machine:
  VLLM_ROOT=/usr/local/corex/lib64/python3/dist-packages/vllm
  bash build_corex_gdn_chunk_recurrent.sh $VLLM_ROOT
Then copy .so to prebuilt/
2026-08-14 02:02:51 +00:00
Claude
a4d16d36b8 fix(build): std::nullopt → c10::nullopt for CoreX c10::optional 2026-08-14 01:50:47 +00:00
Claude
56fe58ada3 fix(build): c10::optional for CoreX CUDA 10.2 — std::optional incompatible
CoreX PyTorch uses c10::optional, not std::optional. The forward-declared
ixformer::infer signatures must match the actual .so ABI.
2026-08-14 01:49:25 +00:00
Claude
1d9b620416 fix(crash): disable corex_gdn_chunk_recurrent — pybind signature mismatch
The .so's torch_chunk_gated_delta_rule() only accepts positional args:
  (Tensor, Tensor, Tensor, Tensor, Tensor, int, Optional[Tensor], bool, bool)
But Python calls it with keyword args:
  (q, k, v, g, beta, initial_state=, output_final_state=, use_qk_l2norm_in_kernel=)

This causes 'incompatible function arguments' crash during profiling
(determine_num_available_blocks), killing the engine before it starts.

Fix: _HAS_COREX_GDN_CHUNK = False, forcing Python _torch_chunk_gated_delta_rule.
This is what a3c45d3b effectively did (its .so wasn't compiled), explaining
why a3c45d3b works but aa4b4992 crashes.
2026-08-14 01:36:18 +00:00
project6-dev
716034bdd0 fix(OOM): lower blocks cap 5000→3000 — flash_attn needs ~4GB temp buffer
5000 blocks KV cache fills GPU memory, flash_attn_varlen_func OOMs
allocating temp attention buffer on first real request.
3000 blocks × 16 = 48K tokens capacity, leaves room for attention.
2026-08-14 01:33:06 +00:00
Claude
c8a982c4e8 feat: ix_full_bridge.so — dlopen bridge for ixformer::infer C++ API
Ported from ex_engine/csrc/ix_full_bridge_v2.cpp + ix_moe_bridge.cpp.
Source: upstream_ref/xllm_latest/core/kernels/ilu/ixformer.h

Exposes 14 ixformer::infer functions as Python-callable torch extension:
  Attention: paged_attention, flash_attn_prefill, reshape_and_cache
  MoE: topk_softmax, moe_gen_idx, moe_expand_input, group_gemm,
       moe_combine_result, fused_moe_forward
  Activation: silu_and_mul
  Norm: rms_norm, fused_add_rms_norm
  Linear: linear
  RoPE: rotary_embedding

Build: torch.utils.cpp_extension.load() in docker build (patch_ops.sh)
Links against libixformer.so from base image at runtime.

This replaces PyTorch MoE fallback (the #1 performance bottleneck).
Without bridge: MoE loops over experts in Python → ~3 TPS decode
With bridge: fused 7-step pipeline in C++ → ~16 TPS decode (sub168 level)
2026-08-14 01:25:16 +00:00
Claude
872be0effa fix(build): strip \r\n from all .py files — CRLF breaks patch_ops.sh text matching
31 files had Windows line endings (\r\n) from merge commit. This causes
patch_ops.sh replace_once() to fail: anchor strings use \n but file
content has \r\n, so no match → patch fails → docker build fails.

Also added .gitattributes to force LF for all text files going forward.
2026-08-14 01:06:49 +00:00
project6-dev
aa4b4992d1 fix(build): hardcode blocks cap 5000 in .py — remove yaml env var
yaml changes cause build failure. Cap hardcoded in
patch_block_major_worker_capacity.py instead. yaml unchanged.
2026-08-14 01:00:09 +00:00
project6-dev
456380eed0 fix(OOM): cap GPU blocks at 5000 via BI100_MAX_GPU_BLOCKS env var
Profiling zeros-out attention → vllm overestimates free memory → 7942 blocks
→ first real request OOMs. Cap at 5000 (80K tokens / 16 block_size).

patch_block_major_worker_capacity.py reads BI100_MAX_GPU_BLOCKS from env,
caps num_gpu_blocks after reserve_block_major_gpu_blocks.
2026-08-14 00:12:39 +00:00
Claude
c6aa1b9c62 fix(P0): protocol.py extra=allow — recover 180 rejected replay requests
Sub655 root cause: OpenAIBaseModel had extra='forbid', rejecting
max_completion_tokens and reasoning_effort as 'Extra inputs not permitted'.
180/881 replay requests returned HTTP 400 instead of being processed.

Fix: extra='allow'. The fold_max_completion_tokens validator already
converts max_completion_tokens→max_tokens correctly. Unknown fields
like reasoning_effort are now silently accepted instead of 400'd.

Also resolved yaml merge conflict (keep upstream 0.80 gpu-mem, no LD_PRELOAD).
2026-08-14 00:10:54 +00:00
project6-dev
20aac5b212 fix(OOM): return zeros during profiling — skip both flash_attn AND Q-tiling
flash_attn_varlen OOMs at 4096 tokens, Q-tiling also OOMs (K tensor too large).
During profiling (BI100_IN_STARTUP_PROFILE=1), return zeros immediately.
Profiling only measures memory footprint, not output correctness.

Restore: chunked_prefill=on, max_num_batched_tokens=4096.
2026-08-13 16:36:17 +00:00
project6-dev
2717bafc30 fix(OOM): skip flash_attn_varlen during profiling
Only patch_xformers_sdpa_seq.py changed. No yaml changes.
2026-08-13 15:30:25 +00:00
project6-dev
aebc660a10 revert: restore to 8c8c0286 (last confirmed build success)
Revert LD_PRELOAD addition and patch_xformers profiling skip.
Need to identify which change caused build failure before re-adding.
2026-08-13 15:08:40 +00:00
project6-dev
bed1fc4d54 fix(OOM): skip flash_attn_varlen during profiling — use Q-tiling fallback
flash_attn_varlen_func allocates O(n²) temp memory for 4096 dummy tokens
during profile_run, causing OOM at gpu_memory_utilization=0.80.

BI100_IN_STARTUP_PROFILE=1 env var is already set by
patch_worker_startup_profile_guard.py during the synthetic forward pass.
Real inference requests still use flash_attn_varlen (much faster).
2026-08-13 14:41:40 +00:00
project6-dev
8c8c0286c9 Revert "fix(build): revert patch_ops.sh to a3c45d3b — remove cccl_preload + corex extension compile steps"
This reverts commit 14d1725cdd.
2026-08-13 13:56:13 +00:00
project6-dev
14d1725cdd fix(build): revert patch_ops.sh to a3c45d3b — remove cccl_preload + corex extension compile steps
These 14 lines were added after a3c45d3b (last confirmed working build).
The cccl_preload build and corex extension compile steps may cause
docker build failure on the competition platform even with || fallback.

Reverting to the exact patch_ops.sh from a3c45d3b.
.cu and .sh source files remain in the repo for future use.
2026-08-13 13:53:21 +00:00
project6-dev
09d92dce5d fix(build): remove 1106 extra CCCL headers — keep only 288 needed by allocator
commit 4c365b8c added 1106 CCCL device-level headers (294K lines) to
qwen3_6_scripts/cccl_preload/include/. These are NOT used by the allocator
preload (which only needs cub/util_allocator.cuh + 288 transitive deps)
and cannot compile on corex CUDA 10.2 anyway.

The extra headers doubled docker context from 15MB to 31MB, likely
causing platform build timeout or size limit failure.

Restoring to the original 288-header set that is proven to compile and run.
2026-08-13 13:40:17 +00:00
project6-dev
6092edebde fix: import torch.utils.cpp_extension explicitly in build script 2026-08-13 11:37:10 +00:00
project6-dev
f6cf9d662e fix(CCCL): split compilation to isolate CCCL headers from torch/corex
Two problems from real BI-V100 build:

1. 'CUDA versions below 12 are not supported'
   → Add CCCL_IGNORE_DEPRECATED_CUDA_BELOW_12 (official suppress macro)

2. corex thrust/complex.h conflicts with CCCL thrust headers
   → Split into two compilation units:
     - cccl_moe_sort_scatter.cu: CCCL headers only, C API, no torch
     - cccl_moe_sort_scatter_pybind.cpp: torch headers only, no CCCL
   Same pattern as proven cccl_allocator_preload.cu

3. Variadic device functions rejected by corex clang:
   → is_referenceable.h: __test(...) → __test(long)
   → invoke.h: __any(...) → template __any(_T)
   → conjunction.h: __and_helper(...) → __and_helper(long)
   SFINAE still works: int overload wins, long is fallback.
2026-08-13 11:35:43 +00:00
project6-dev
05706f0d60 fix(build): use block-level CUB only — device-level API conflicts with corex CUDA 10.2
CCCL latest requires CUDA 12+, corex is 10.2. Device-level CUB headers
(DeviceRadixSort etc) pull in thrust/detail/type_traits.h which conflicts
with corex's thrust/complex.h namespace.

Rewrite to use block-level CUB BlockScan only (same pattern as the proven
corex_moe_index_combine.cu): histogram + prefix_sum + scatter.
No extra_include_paths needed — uses corex's built-in cub/block/block_scan.cuh.
2026-08-13 11:25:37 +00:00
project6-dev
4c365b8c03 feat(CCCL): device-level CUB algorithms for MoE dispatch
Add complete CCCL CUB header tree (1394 files) to cccl_preload/include/:
- cub/device/ — DeviceRadixSort, DeviceScan, DeviceHistogram, DeviceReduce, DeviceSelect
- cub/agent/ — all agent implementations (sort, scan, reduce, histogram, etc)
- cub/block/ — BlockScan, BlockReduce, BlockExchange, BlockLoad, BlockStore, etc
- cub/warp/ — WarpScan, WarpReduce, WarpExchange, WarpMergeSort
- cub/thread/ — thread-level operators
- thrust/ — sort_by_key, iterator utilities
- cuda/ — execution, stream, memory_resource, functional

New kernel: cccl_moe_sort_scatter.cu
- Uses CUB DeviceRadixSort::SortPairs to sort (expert_id, token_idx) pairs
- O(n) radix sort replaces O(n log n) torch.argsort in MoE prefill path
- Boundary detection + fill for expert offsets/sizes
- Compiled against CCCL upstream headers (not corex CUB) to avoid BI-V100 bugs

Previously only 288 CCCL headers (CachingDeviceAllocator only).
Now 1394 headers — full CUB device-level algorithm stack available for
all future kernels.
2026-08-13 11:18:52 +00:00
Claude
45161610f0 fix: thread_local reentrant guard — prevent cudaMalloc infinite recursion
CUB CachingDeviceAllocator::DeviceAllocate calls cudaMalloc internally
on cache miss. Without a guard, our intercepted cudaMalloc recurses
into DeviceAllocate → cudaMalloc → DeviceAllocate → segfault.

thread_local g_in_allocator flag detects reentrant calls and forwards
them directly to the real cudaMalloc/cudaFree via dlsym(RTLD_NEXT).
2026-08-13 10:37:32 +00:00
Claude
3ce5bff10f fix: use cccl_preload::cub namespace — CUB_WRAPPED_NAMESPACE requires it
CUB_DISABLE_NAMESPACE_MAGIC requires CUB_WRAPPED_NAMESPACE.
CUB_WRAPPED_NAMESPACE=cccl_preload wraps cub into cccl_preload::cub.
Source must use cccl_preload::cub::CachingDeviceAllocator.
2026-08-13 10:36:27 +00:00
Claude
c1e23615b5 fix: remove CUB_WRAPPED_NAMESPACE and _CCCL_COMPILER_GCC from build flags
CUB_WRAPPED_NAMESPACE=cccl_preload wraps cub into cccl_preload::cub
but cccl_allocator_preload.cu uses bare cub:: — compilation fails.
_CCCL_COMPILER_GCC=1 conflicts with CCCL auto-detection (redefined warning).

Drop both. CUB_DISABLE_NAMESPACE_MAGIC alone is sufficient.
2026-08-13 10:35:11 +00:00
dylanyunlon
32325f9624 build: wire CCCL preload into competition pipeline
computility-run.yaml:
  PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
  LD_PRELOAD=/workspace/qwen3_6_scripts/cccl_preload/libcccl_allocator.so

patch_ops.sh:
  调用 cccl_preload/build_cccl_preload.sh 编译 .so

真机验证: ALL TESTS PASSED on BI-V100 32GB
2026-08-13 10:31:33 +00:00
Claude
9ef5af3bda fix: wire CCCL preload into build+launch chain + pre-submission verification
- patch_ops.sh: call cccl_preload/build_cccl_preload.sh (new CCCL deps)
  instead of old build_cccl_preload_allocator.sh (mock)
- computility-run.yaml: add LD_PRELOAD + CCCL_ALLOC_DISABLE env vars
- Remove old mock files: cccl_preload_allocator.cu, build script, test
- .dockerignore: exclude cccl_upstream/ upstream_ref/ vllm/ *.zip
- verify_submission.sh: 31-point pre-submission check
  (file structure, CCCL chain, path matching, prebuilt integrity,
   corex imports, docker context, GPU smoke test)
2026-08-13 10:00:26 +00:00
dylanyunlon
a6b5891bfc feat: CCCL CachingDeviceAllocator preload — 完整依赖链 288 files
从 cccl_upstream 递归追踪 cub/util_allocator.cuh 的全部 include 依赖:
  cub/         9 files (config, util_*, version, detect_cuda_runtime)
  cuda/        libcudacxx type_traits, concepts, algorithm, iterator...
  nv/          target macros, preprocessor

总计 288 个头文件 (1.4MB),打包到 include/ 目录,编译时 -I include
即可完全脱离 CCCL 原始目录结构。

.cu 文件直接 #include <cub/util_allocator.cuh>,
走原版 CUB CachingDeviceAllocator,零 mock。

BI-V100 参数: growth=2 bins=[8..32] max_cached=8GB/device
2026-08-13 09:53:42 +00:00
dylanyunlon
8dc6462a2b feat: CCCL CachingDeviceAllocator LD_PRELOAD — bypass CoreX expandable_segments ASSERT
从 CCCL upstream cub/cub/util_allocator.cuh 提取 CachingDeviceAllocator
核心算法,去掉所有 CUB/CCCL 宏依赖,编译为独立 .so。

用 LD_PRELOAD 拦截 cudaMalloc/cudaFree,路由到 CUB 的 geometric-bin
缓存分配器。同时在 constructor 中 strip PYTORCH_CUDA_ALLOC_CONF 里的
expandable_segments 配置,避免 CoreX CUDACachingAllocator.cpp:545 ASSERT。

BI-V100 调优参数:
  bin_growth=8, min_bin=3 (512B), max_bin=13 (~550MB)
  max_cached_bytes=4GB per device (32GB卡的合理上限)

真机测试步骤:
  1. bash build_cccl_preload.sh
  2. LD_PRELOAD=./libcccl_allocator.so CCCL_ALLOC_DEBUG=1 \
     PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True \
     python3 verify_preload.py
2026-08-13 09:53:42 +00:00
dylanyunlon
089e810984 feat: CCCL CachingDeviceAllocator preload — 完整依赖链 288 files
从 cccl_upstream 递归追踪 cub/util_allocator.cuh 的全部 include 依赖:
  cub/         9 files (config, util_*, version, detect_cuda_runtime)
  cuda/        libcudacxx type_traits, concepts, algorithm, iterator...
  nv/          target macros, preprocessor

总计 288 个头文件 (1.4MB),打包到 include/ 目录,编译时 -I include
即可完全脱离 CCCL 原始目录结构。

.cu 文件直接 #include <cub/util_allocator.cuh>,
走原版 CUB CachingDeviceAllocator,零 mock。

BI-V100 参数: growth=2 bins=[8..32] max_cached=8GB/device
2026-08-13 09:53:19 +00:00
dylanyunlon
e7c703ef94 feat: CCCL CachingDeviceAllocator LD_PRELOAD — bypass CoreX expandable_segments ASSERT
从 CCCL upstream cub/cub/util_allocator.cuh 提取 CachingDeviceAllocator
核心算法,去掉所有 CUB/CCCL 宏依赖,编译为独立 .so。

用 LD_PRELOAD 拦截 cudaMalloc/cudaFree,路由到 CUB 的 geometric-bin
缓存分配器。同时在 constructor 中 strip PYTORCH_CUDA_ALLOC_CONF 里的
expandable_segments 配置,避免 CoreX CUDACachingAllocator.cpp:545 ASSERT。

BI-V100 调优参数:
  bin_growth=8, min_bin=3 (512B), max_bin=13 (~550MB)
  max_cached_bytes=4GB per device (32GB卡的合理上限)

真机测试步骤:
  1. bash build_cccl_preload.sh
  2. LD_PRELOAD=./libcccl_allocator.so CCCL_ALLOC_DEBUG=1 \
     PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True \
     python3 verify_preload.py
2026-08-13 09:53:19 +00:00
dylanyunlon
ddfd24da27 fix: sync to real-machine verified version — ALL TESTS PASSED
真机验证通过的精确版本:
- CUB_NS_QUALIFIER (不是 cub::)
- thread_local inside_cub reentrant guard
- 去掉 -D_CCCL_COMPILER_GCC=1
- total_mem → total_memory

BI-V100 32GB × Iluvatar, CoreX clang++ 编译 51864 bytes .so
expandable_segments:True 被 strip, CUB allocator 接管, 缓存复用确认
2026-08-13 09:52:15 +00:00
dylanyunlon
93e498197a fix: thread_local reentrant guard — prevent cudaMalloc infinite recursion
CUB CachingDeviceAllocator 内部在 cache miss 时调 cudaMalloc,
被我们的 LD_PRELOAD 再次拦截 → DeviceAllocate → cudaMalloc → 无限递归 → segfault。

加 thread_local bool inside_cub 标志:
  外部调用 → CUB allocator (带缓存)
  CUB 内部调用 → 直接走 dlsym(RTLD_NEXT) 的真实 cudaMalloc
2026-08-13 09:42:26 +00:00
dylanyunlon
0ac118911d fix: CUB_NS_QUALIFIER for wrapped namespace + drop _CCCL_COMPILER_GCC
CoreX clang++ 不是 GCC,-D_CCCL_COMPILER_GCC=1 和 CCCL 自己的
compiler detection 冲突。

CUB_WRAPPED_NAMESPACE=cccl_preload 使得命名空间变成 cccl_preload::cub,
用 CUB_NS_QUALIFIER 宏自动解析正确的命名空间。
2026-08-13 09:31:45 +00:00
dylanyunlon
8d6f9eaeb0 feat: CCCL CachingDeviceAllocator preload — 完整依赖链 288 files
从 cccl_upstream 递归追踪 cub/util_allocator.cuh 的全部 include 依赖:
  cub/         9 files (config, util_*, version, detect_cuda_runtime)
  cuda/        libcudacxx type_traits, concepts, algorithm, iterator...
  nv/          target macros, preprocessor

总计 288 个头文件 (1.4MB),打包到 include/ 目录,编译时 -I include
即可完全脱离 CCCL 原始目录结构。

.cu 文件直接 #include <cub/util_allocator.cuh>,
走原版 CUB CachingDeviceAllocator,零 mock。

BI-V100 参数: growth=2 bins=[8..32] max_cached=8GB/device
2026-08-13 09:26:41 +00:00
dylanyunlon
967d572073 feat: CCCL CachingDeviceAllocator LD_PRELOAD — bypass CoreX expandable_segments ASSERT
从 CCCL upstream cub/cub/util_allocator.cuh 提取 CachingDeviceAllocator
核心算法,去掉所有 CUB/CCCL 宏依赖,编译为独立 .so。

用 LD_PRELOAD 拦截 cudaMalloc/cudaFree,路由到 CUB 的 geometric-bin
缓存分配器。同时在 constructor 中 strip PYTORCH_CUDA_ALLOC_CONF 里的
expandable_segments 配置,避免 CoreX CUDACachingAllocator.cpp:545 ASSERT。

BI-V100 调优参数:
  bin_growth=8, min_bin=3 (512B), max_bin=13 (~550MB)
  max_cached_bytes=4GB per device (32GB卡的合理上限)

真机测试步骤:
  1. bash build_cccl_preload.sh
  2. LD_PRELOAD=./libcccl_allocator.so CCCL_ALLOC_DEBUG=1 \
     PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True \
     python3 verify_preload.py
2026-08-13 09:26:41 +00:00
Claude
327c2c9044 feat(CCCL): LD_PRELOAD CachingDeviceAllocator — intercept cudaMalloc/cudaFree
Route C: replace PyTorch's cudaMalloc/cudaFree with CCCL CUB's
CachingDeviceAllocator via LD_PRELOAD. Eliminates driver-level allocation
overhead by reusing freed GPU memory from a bin-based cache.

Based on cccl_upstream/cub/cub/util_allocator.cuh (901 lines).
Self-contained .so with no CCCL header dependencies at compile time.

Files:
- cccl_preload_allocator.cu: the allocator (405 lines)
- build_cccl_preload_allocator.sh: build script (corex clang++ or g++ fallback)
- test_cccl_preload.sh: smoke test suite for BI-V100
- patch_ops.sh: build during docker build
- computility-run.yaml: LD_PRELOAD env var for runtime

Config via env:
  CCCL_ALLOC_BIN_GROWTH=8, MIN_BIN=3, MAX_BIN=13, MAX_CACHED_MB=4096

Test on real machine:
  cd qwen3_6_scripts && bash test_cccl_preload.sh
2026-08-13 09:21:52 +00:00
project6-dev
d2b4df54ff perf: native ixformer decode — v1 ≤32K, v2 >32K (no Python fallback)
Decode path:
- ≤32K: paged_attention_v1 (5D KV layout, x=8) — verified on real BI-V100
- >32K: paged_attention_v2 (5D→4D permute) — verified 65K on real BI-V100
- Removes _forward_decode_pytorch Python fallback entirely

Verified: v1 passes ctx=1024..32768, v2 passes ctx=32768..65536+
flash_attn_varlen_func prefill already merged in prior commit (ad6863ed).
2026-08-13 07:09:50 +00:00
Claude
e78fa560c8 feat: wire corex_gdn_chunk_recurrent C++ kernel into GDN prefill path
- patch_ops.sh: build corex_gdn_chunk_recurrent.so alongside moe_index_combine
- qwen3_5.py: import corex_gdn_chunk_recurrent, use C++ version for prefill
  chunks instead of Python _torch_chunk_gated_delta_rule
- C++ version from xllm upstream avoids Python loop overhead and has proper
  fp32 accumulation (key for NaN prevention on BI-V100)
- Falls back to Python version if .so not available
2026-08-13 06:25:09 +00:00
project6-dev
ad6863ed84 perf: replace Python Q-tiling fallback with ixformer.flash_attn_varlen_func
Verified on real BI-V100:
  flash_attn_func works with head_dim=256 (diff < 0.004, no NaN)
  flash_attn_varlen_func works for variable-length batching
  seq=1024: 1.7x faster than PyTorch matmul

The profiling-stage _run_sdpa_fallback now tries flash_attn_varlen_func
first, falls back to Python Q-tiling only on exception.

This addresses the 10-50x attention slowdown identified in the analysis:
  Python Q-tiling: O(L^2) per-tile matmul in Python loop
  flash_attn: fused kernel, O(L) memory, hardware-optimized
2026-08-13 05:14:08 +00:00
project6-dev
0861de65d0 feat: C++ GDN chunk+recurrent from xllm upstream + verification script
Extracted torch_chunk_gated_delta_rule and torch_recurrent_gated_delta_rule
from xllm_latest/core/layers/npu_torch/qwen3_gated_delta_net_base.cpp.

Pure PyTorch C++ — no NPU/ACL deps, no custom CUDA kernels.
Same algorithm as our Python _torch_chunk_gated_delta_rule but
avoids Python interpreter overhead in the chunk loop.

Verify on real BI-V100: python3 verify_gdn_cpp.py
2026-08-13 04:01:59 +00:00
project6-dev
796b09952c feat: integrate moe_compute_index kernel into MoE prefill path
Verified on real BI-V100:
  moe_compute_index: 11.48x speedup (0.035ms vs 0.397ms)
  moe_combine_result: 2.66x speedup (0.022ms vs 0.059ms)

Integration:
- qwen3_5.py: import corex_moe_index_combine, use in prefill path
  with _USE_COREX_MOE_INDEX_COMBINE flag (env BI100_MOE_COREX_INDEX_COMBINE)
  Falls back to PyTorch argsort+bincount if .so unavailable
- patch_ops.sh: compile corex_moe_index_combine.cu during docker build
2026-08-13 03:52:35 +00:00
project6-dev
71d39a1c7e feat: moe_compute_index + moe_combine_result CUDA kernels from xllm upstream
Two fused kernels to replace Python loops in MoE prefill path:
1. moe_compute_index: histogram + CUB BlockScan prefix_sum + place
   replaces: argsort + bincount + CPU sync
2. moe_combine_result: fused weighted sum of expert outputs
   replaces: view + multiply + sum

Source: xllm_latest/core/kernels/cuda/moe/{moe_compute_index.cu, moe_combine.cu}
Adapted: removed xllm framework deps, added pybind11 wrapper

Verify on real BI-V100: python3 verify_moe_index_combine.py
2026-08-13 03:48:12 +00:00
project6-dev
0b0c47fddd fix(critical): fold max_completion_tokens + max_num_seqs=2 + max_model_len=80000 + xllm_latest layer import
Sub 655 root causes (confirmed from log analysis):
1. protocol.py: max_completion_tokens never folded into max_tokens
   → 162/881 replay requests rejected 400 (extra_forbidden)
2. max_num_seqs=1 → t2_n_2 test fails (needs n=2)
3. max_model_len=131072 → OOM crash at 62% replay, opencompass all 0

Fixes:
- protocol.py: model_validator fold_max_completion_tokens
- yaml: max_num_seqs=2, max_model_len=80000, PYTORCH_CUDA_ALLOC_CONF
- topk_softmax stays =0 (corex CUB BlockReduce incompatible on BI-V100)

xllm_latest import to ex_engine/:
- npu_torch layers: GDN(1164L), Qwen3.5 GDN, attention, fused_moe
- cuda/moe kernels: topk_softmax_kernels.cuh, moe_combine, moe_compute_index
- npu kernels: causal_conv1d, recurrent_gated_delta_rule
- model headers: qwen3_5.h, qwen3_next.h
2026-08-13 03:19:39 +00:00