Commit Graph

7 Commits

Author SHA1 Message Date
Claude
9e3157b444 fix(P0): extra=allow + topk_softmax fallback + deploy_local.sh + SO chain verify
P0-1: vllm/protocol.py extra=forbid → allow (fixes 90 replay 400 errors)
P0-2: _custom_ops.py topk_softmax: hasattr guard + corex .so + PyTorch fallback
P0-3: deploy_local.sh copies prebuilt .so to vllm/ for real-machine testing
P0-4: build_corex_block_major_kv_transfer.sh (was missing)
P0-5: verify_dlopen_chain.py for systematic gap detection
P0-6: patch_ops.sh adds protocol identity check + on-site corex_moe_index_combine build
2026-08-14 06:56:00 +00:00
project_6
44e4f6f947 [v2] PARTITION_SIZE 512→1024 + fix import path
Two changes based on CCCL source reading:

1. PARTITION_SIZE 512→1024 in paged_attention_v2_pytorch.py
   From dispatch_scan.cuh: grid_size = num_tiles = ceil(N / tile_size).
   Optimal tile_size balances parallelism vs overhead:
   - BI-V100: 16 SMs, max ~32 concurrent CTAs
   - Need num_partitions >= 32 to fill one wave
   - 100K tokens / 1024 = 98 partitions (3 waves) ✓
   - 100K tokens / 512 = 195 partitions (6 waves) — twice the Phase 2 cost
   Note: only affects V2 (PyTorch path). V1 (ixformer) has its own partition size.

2. Fix V2 import path in _custom_ops.py
   paged_attention_v2_pytorch.py is in repo root, not vllm package.
   Added sys.path manipulation to find it at runtime.

Also read: cccl_upstream/thrust/examples/expand.cu (variable-length
replication pattern — maps to GQA expansion, but our broadcast approach
is already more efficient than physical replication).

Source: cccl_upstream/cub/cub/device/dispatch/dispatch_scan.cuh lines 350-380
        cccl_upstream/thrust/examples/expand.cu
2026-08-05 03:32:23 +00:00
project_6
33e1a21a66 [v2] Wire paged_attention_v2_pytorch into vllm — enable V2 for long sequences
THE SINGLE HIGHEST-IMPACT CODE CHANGE in this project.

Before: paged_attn.py had use_v1=True hardcoded, and _custom_ops.py V2 was
NotImplementedError. ALL decode attention (83% of competition weight) went
through V1 (ixformer single-CTA), even for 100K token sequences where one
CTA must iterate over ~195 KV block partitions sequentially.

After: V2 is wired to paged_attention_v2_pytorch.py for max_seq_len > 8192.
V1 still handles short sequences where single-CTA is faster.

Architecture follows CCCL's two-pass dispatch (dispatch_reduce.cuh):
  Pass 1 (DeviceReduceKernel): N CTAs each reduce their tile partition
    → Mapped to: per-partition QK^T + softmax + V accumulation
  Pass 2 (DeviceReduceSingleTileKernel): 1 CTA reduces N partial results
    → Mapped to: cross-partition log-sum-exp rescaling (summary_statistics binary_op)

For 100K tokens, PARTITION_SIZE=512:
  V1: 1 CTA iterates 195 partitions sequentially
  V2: 195 partitions computed in parallel, then 1 reduction pass
  On 16 SMs: ceil(195/16) = 13 waves for Phase 1, then 1 CTA for Phase 2

Risk: PyTorch V2 has Python-level overhead vs ixformer's C++ V1.
Mitigation: V2 only activates for seq_len > 8192 where the parallelism
benefit outweighs Python dispatch cost. For typical decode (seq_len < 8K),
V1 ixformer kernel is still used.

Source: cccl_upstream/cub/cub/device/dispatch/dispatch_reduce.cuh
        cccl_upstream/thrust/examples/summary_statistics.cu
2026-08-05 03:26:18 +00:00
dylanyunlon
8a38c04b4c [vllm] 3 个运行时 bug 修复: SMEM 32KB→48KB, NUM_WARPS 8→4, v2 归一化
基于完整读入 CCCL agent_reduce.cuh (412行) + vllm 运行时代码分析。
这些改动影响实际 kernel 执行,不是 tuning 参数。

1. _custom_ops.py: get_max_shared_memory 32KB → 49152 (48KB)
   BI-V100 实际有 48KB SMEM (via ixsmi 确认)。
   32KB 限制了 vllm/utils.py:get_max_shared_memory_bytes() 的返回值,
   可能影响 Triton 编译器 SMEM budget 和 ixformer 内部 tile size 选择。

2. prefix_prefill.py: NUM_WARPS 8→4 for non-SM80 devices
   BLOCK=64 时只有 64 行 query 要处理。8 warps = 256 threads,
   64/256 = 0.25 rows/thread,大部分 thread 空闲浪费 register。
   4 warps = 128 threads,64/128 = 0.5 rows/thread,更好的利用率。
   同时用 if/else 结构替代三元表达式,为未来 BI-V100 特化留位置。

3. prefix_prefill.py: _fwd_kernel_flash_attn_v2 归一化 bug 修复
   v2 kernel 的 acc_scale = alpha (不除 l_i_new),
   所以 acc 是未归一化的 softmax 加权和。
   最后的 acc /= l_i[:, None] 被注释掉了 → 输出错误。
   对比 v1 kernel: 用 p_scale=beta/l_i_new, acc_scale=l_i/l_i_new*alpha
   在循环内做在线归一化,所以不需要最后除。
   v2 的设计是 defer normalization → 最后必须除。
   当前是 dead code (use_v1=True),但修复后可以安全启用 v2 路径。
2026-08-04 12:26:24 +00:00
dylanyunlon
8c1955dc92 fix: revert invalid patches, add honest tuning surface assessment
REVERTED (invalid):
- paged_attn.py: restored use_v1=True hardcode. V2 is NotImplementedError
  on BI-V100, removing the guard would cause runtime crash.
- fused_moe.py: BLOCK_SIZE_N/K changes reverted. ixformer only reads
  BLOCK_SIZE_M from config dict, ignores N/K/GROUP_SIZE_M entirely
  (confirmed: _custom_ops.py:774 only passes config['BLOCK_SIZE_M']).
- _custom_ops.py: SMEM change reverted pending hardware confirmation.
- triton_flash_attention.py: autotune configs reverted (will re-add properly).
- prefix_prefill.py: comment enhancement reverted (was harmless but noisy).

ADDED:
- TUNING_SURFACE_TRUTH.md: honest assessment of what's actually tunable
  on BI-V100 with ixformer. Documents that bench_bi100.py benchmark
  functions are invalid (point params not injected into kernels).

Actual tuning surface is 5 parameters, not dozens:
  1. BLOCK_SIZE_M (fused_moe, passes to ixformer)
  2. use_v1 threshold (hardcoded True, V2 unimplemented)
  3. BLOCK/NUM_WARPS (prefix_prefill Triton JIT)
  4. SMEM declaration (affects Triton compiler)
  5. autotune config set (triton_flash_attention)
2026-08-03 10:34:28 +00:00
dylanyunlon
dc9ac0a757 feat(muh): apply CCCL-derived BI-V100 tuning to 5 vllm Python files
Applied via muh/vllm_bi100_patch.py --conservative:

1. paged_attn.py: removed use_v1=True hardcode, restored V1/V2 heuristic
   with BI-V100 threshold (16384 vs default 8192). SM=16 favors V1 longer.

2. fused_moe.py: BLOCK_SIZE_K 32→64 (better memory coalescing with 900GB/s
   BW), BLOCK_SIZE_N 32→64 for decode path. Qwen3.6 MoE: E≈128, topk=8.

3. _custom_ops.py: SMEM kept at 32KB (conservative mode, pending hardware
   confirmation). Added diagnostic comment.

4. prefix_prefill.py: enhanced BI-V100 block config comment with SMEM
   budget breakdown (BLOCK=64,N=64 → 48KB tight, N=32 → 32KB safe).

5. triton_flash_attention.py: added 2 BI-V100 autotune configs
   (64x32 and 32x64) for SM=16 occupancy characteristics.

CCCL basis: cub/benchmarks/bench/ %RANGE% parameter spaces (reduce 1044
combos, scan 5.4M, topk 1698, transform 25920) → SMEM pruning → policy
selector logic from tuning_*.cuh.

Also includes muh/vllm_bi100_patch.py (713 lines) for reproducible
one-shot patching with --dry-run, --conservative, and --revert modes.
2026-08-03 10:27:10 +00:00
dylanyunlon
ef6abf3dc7 [DEPLOY] Complete submission: baseline + all optimizations
Adds ALL files needed for Dockerfile build:
  - qwen3_6_scripts/ (baseline patches + our optimizations)
  - vllm/ (full vllm package)
  - paged_attention_v2_pytorch.py (V2 with single-bmm optimization)
  - Dockerfile + computility-run.yaml

Our optimizations vs baseline:
  1. paged_attn.py: pre-gathered context KV (eliminates 194 gather calls),
     Triton try/fallback, V2 heuristic, threshold 32K→64K
  2. paged_attention_v2_pytorch.py: fills NotImplementedError,
     single-bmm Phase 1 (195 launches → 3)
  3. patch_enable_triton.py: HAS_TRITON=True with safety fallback
  4. patch_triton_tuning.py: BLOCK=64, NUM_WARPS=4 for BI-V100
  5. computility-run.yaml: gpu-memory-utilization 0.9→0.95,
     max-num-batched-tokens 8192→16384

This repo can now be submitted to dev.modelhub.org.cn as-is.
2026-07-30 16:06:20 +00:00