corex_moe.py: moe_forward now accepts both formats:
Format A: w1(E,I,H) + w2(E,H,I) + w3(E,I,H) — xllm style, separate gate/up
Format B: w13(E,2*I,H) + w2(E,H,I) + w3=None — vllm style, merged gate_up
Auto-detects by checking if w3 is None, splits w13 internally.
qwen3_5.py:
- Fix corex_moe call: use keyword args (w3=None, topk=self.top_k)
prevents topk integer going to w3 tensor position
- Remove silent fallback on corex_moe failure — raise RuntimeError
with full shape info for diagnosis. Zero score with no error log
is worse than a crash.
moe_topk_softmax_v3.cu: BI-V100 verified (2026-08-10)
- 64 experts, topk=8, warp shuffle, zero shared memory
- renormalize: sum=1.0 ✓, no NaN ✓, no duplicate ids ✓
- 881 token batch ✓
- Compiler: corex clang/16, --cuda-gpu-arch=ivcore10
- Stream: c10::cuda::getCurrentCUDAStream()
corex_moe.py: loads CUDA kernel, NO Python fallback
- Searches pre-compiled .so → JIT compile from source → error
- MoE pipeline: CUDA topk → cublas expert GEMM → ixformer silu_and_mul
precompile_moe_topk.py: Docker build-time compilation + verification
Key finding from real machine probing:
ixformer::infer::topk_softmax is DECLARED in ixformer.h but
NOT IMPLEMENTED in any .so in the base image (nm -D scan: zero hits).
Must compile our own kernel.
Root cause from real machine test: gdn_forward.cu output abs mean = inf
- gate_raw can be positive → exp(gate) > 1 → state grows exponentially
- Over 64 tokens: exp(2.0)^64 = inf
- PyTorch ref clamps g ∈ [-5, 2] but CUDA kernel did not
Fix:
gdn_forward.cu: clamp gate_raw ∈ [-5, 2] before exp (both kernel variants)
gdn_forward.cu: clamp state ∈ [-65504, 65504] after update (fp16 safe range)
qwen3_5.py: clamp g_3d before passing to SM70 kernel (belt + suspenders)
qwen3_5.py: clamp temporal_state after decode update
1. ix_bridge.py: RuntimeError instead of silent PyTorch fallback
If JIT compile fails, crash immediately with diagnostic message.
0 score with no error log is worse than a visible crash.
2. qwen3_5.py: explicit WARNING log on import failure (not silent)
Shows exact error so we can diagnose from docker log.
3. probe_ixformer_symbols.py: definitive test for real machine
- Finds all ixformer .so files
- nm/objdump for topk_softmax C++ symbol
- Checks Python bindings
- Attempts JIT compile + link (the real test)
- Prints PASS/FAIL with next-step instructions
Run on real machine: python3 probe_ixformer_symbols.py
precompile_gdn.py: calls torch.utils.cpp_extension.load with build_directory
to produce .so at build time. If build env has no GPU/compiler, fails
gracefully — kernel JIT compiles at runtime instead.
fused_fwd.py: _load_ext() now checks build/ dir for precompiled .so first,
skips 2-minute JIT compilation if found.
Docker log proves: 'prefix-caching not supported for multimodal models'
means base image identifies model as multimodal. Our serving_chat.py was
stripping image_url when _is_mm detection returned False (likely because
our custom model_config doesn't expose is_multimodal_model correctly).
Sub168 d05 PASSED with content[374] — they didn't strip images.
Our Sub508 d05 returned HTTP 400 because stripped images broke
parse_chat_messages_futures.
Fix: remove the strip logic entirely. Let images flow through.
Direct translation of CCCL dispatch_scan.cuh (1469 lines) architecture:
CCCL dispatch_scan has two kernels:
1. DeviceScanInitKernel — initializes tile_state (parallelizable)
2. DeviceScanKernel — sequential scan using tile_state propagation
Our _torch_chunk_gated_delta_rule now separates:
Phase 1 (init, parallelizable): pre-compute ALL chunk-local attn matrices
attn_i[c] = q[c] @ k[c].T * decay[c] — does NOT depend on state
Also pre-compute g.exp() and clamped g once, outside loop
Phase 2 (scan, sequential): only state-dependent ops in the loop
v_prime, v_new, attn_inter, core_out, state update
This matches CCCL's insight: everything that doesn't need tile_state
should be computed before the scan kernel, not interleaved with it.
6 non-crash FAILs traced to root cause:
- 5 are NaN-induced model quality issues (will self-heal with clamp fix)
- 1 is multimodal HTTP 400 (needs separate debug)
- 25 are crash cascade (will self-heal with max-num-seqs=2)
Expected after deployment: 45/51 PASS (88%)
Raw find/ls/python output from real machine. No analysis.
Zero libcorex_*.so. Zero corex_gdn.py. Zero qwen3_5.py in base image.
ixformer available with full API. Clang/16 compiler present.
Python probe may have been silently swallowed by build system.
Shell commands (ls, find, wc, grep) always print to stdout.
Probes:
- ls /usr/local/corex/lib64/libcorex_*.so → do .so files exist?
- ls $VLLM/model_executor/models/corex_*.py → do wrappers exist?
- find $VLLM -name '*corex*' → any corex files anywhere?
- wc/grep native qwen3_5.py → does it reference corex?
Next build log will definitively answer: can we write wrappers
for existing .so files, or must we optimize pure PyTorch?
Docker log proves two fatal issues:
1. max_model_len=100000 > KV cache capacity 88112 → ValueError crash
'max seq len (100000) is larger than maximum number of tokens
that can be stored in KV cache (88112)'
Fix: set max_model_len=80000 (safe margin below 88112)
2. NaN in GatedDeltaNet layers 34,36,37,38 (frac=1.0000)
Root cause: g.cumsum() → g.exp() overflow to inf → inf*0 = NaN
Fix: clamp all g values to [-80,80] before exp() calls
(max safe float32 exp input ~88, use 80 for margin)
Applied to: cumsum result, k_cumdecay, attn_inter, last_state update
3. CoreX modules confirmed NOT in base image:
'CoreX GDN module not found'
'CoreX MoE module not found'
→ pure PyTorch is the only path, must be numerically stable
Build was failing, likely due to:
1. 165MB build context (no .dockerignore) — cccl_upstream/ 53MB, zip 97MB
2. probe_corex_api.py used importlib.import_module which may init CUDA
3. pip install without --timeout could hang on unreachable mirror
Fixes:
- .dockerignore: excludes cccl_upstream/, vllm/, *.zip, docs/ etc
Build context: ~2MB instead of 165MB
- probe_corex_api.py: rewritten to use ONLY ast.parse, zero runtime imports
- pip install: added --timeout 30
probe_corex_api.py runs during docker build BEFORE qwen3_5.py deployment:
1. Lists ALL .py files in base image's vllm/model_executor/models/
2. For each corex_gdn/corex_moe/corex_fa2: import → inspect signatures
3. If import fails: AST parse the .py file directly for class/method defs
4. Checks native qwen3_5.py for corex references before we overwrite it
5. Checks .so files exist (libcorex_gdn.so etc)
6. Dumps everything to /workspace/corex_probe_result.json
Next deploy's build log will show EXACTLY what the corex API looks like.
Then we write real dispatch code against real signatures, not guesses.
Both base engine yaml and Sub168 use max-seq-len-to-capture=32768.
We were missing it.
Also fixed patch_ops.sh ending comments that claimed files were NOT
deployed when they actually ARE deployed.
CCCL segmented_sort.cu AST chain → traced back to base engine zip →
discovered base patch_ops.sh deploys 10+ files we were missing.
Missing patches that caused real failures:
1. paged_attn.py — Triton context_attention_fwd HANGS BI-V100 GPUs permanently.
Base engine replaces it with _forward_prefix_pytorch pure-PyTorch fallback.
WITHOUT THIS: GPU hang on any prefix-cached request → timeout → 0 score.
2. patch_xformers_sdpa_seq.py — head_dim=256 > cudnnFlashAttn 128 limit.
Qwen3.5 uses head_dim=256. Without this bypass, attention crashes.
3. sequence.py — completion_tokens inflation under chunked prefill.
Bug: get_output_token_ids_to_return(delta=True) with num_new_tokens=0
returns the ENTIRE prompt. 10K prompt × 3 chunks = 30K false tokens.
4. scheduler.py — num_cached_tokens tracking for prefix caching.
5. mamba_cache.py — GatedDeltaNet state management.
6. patch_model_runner.py — prefix_cache_hit stays True in chunked-prefill
chunk 2+, causing undersized block_tables and crash.
Also: conditional qwen3_5.py deployment (CCCL JIT pattern) — if Docker
image already has a working qwen3_5.py (with corex integration), don't
overwrite it. Only deploy ours if the image version is missing.
CCCL tuning_rle_encode.cuh AST chain led to reading the base engine zip:
enginex-vllm-bi100-qwen36-main.zip → qwen3_6_scripts/qwen3_5.py (63KB, 1369 lines)
vs our custom version (85KB, 1780 lines) which added:
- _hw_policy with hardcoded clamp values
- nan_to_num(nan=0.0) double disaster
- Custom _torch_chunk_gated_delta_rule with aggressive clamps
- Custom FusedMoE fallback logic
- All of which BROKE the native CoreX acceleration
Sub168 docker log proves:
- corex_gdn.py:56 loads libcorex_gdn.so (fused GDN decode)
- corex_gdn.py:228 uses fused GDN prefill
- corex_moe.py:339 uses CoreX fused MoE (expert-grouped-wmma)
These are Docker image-internal modules that our custom code never called.
Base original:
- No nan_to_num (NaN propagates honestly)
- No custom clamps (uses model weights as-is)
- Same class structure (Qwen3_5ForCausalLM, Qwen3_5MoeForCausalLM)
- Docker image's corex modules can intercept through vllm's internal dispatch
qwen3_5_base_original.py kept as reference.
CCCL source: kernel_segmented_scan.cuh (675 lines)
Core design: segmented scan with three-way dispatch:
1. Fixed-size segments → direct division (fast path)
2. Variable-size → branchless search
3. Fallback → basic scan
Applied to qwen3_5.py — three critical fixes:
FIX#1: Remove nan_to_num(nan=0.0) from both prefill and decode paths.
This was the double disaster: it hid NaN (making model look alive while
outputting garbage) AND filled all outputs with zeros (making every
layer's input all-zeros → semantically dead model → 0 points).
Now: NaN is logged but propagated for honest failure detection.
FIX#2: Add corex_gdn native dispatch in GatedDeltaNet.forward.
Sub168 docker log proves: corex_gdn.py:56 loads libcorex_gdn.so,
corex_gdn.py:228 uses fused prefill operator → zero NaN, 17.35GB weights.
Our code never called this module. Now we try to import and use it.
FIX#3: Add corex_moe native dispatch in MoeSparseBlock.forward.
Sub168 docker log: corex_moe.py:339 Using CoreX fused MoE prefill
operator: expert-grouped-wmma. Our code only tried ixformer.functions
which lacks MoE kernels. Now we also check for corex_moe.py.
FIX#4: MoE native retry instead of permanent abandon after first failure.
Fallback analysis:
#3 (ixformer import → all-False) + #4 (nan_to_num) + #5 (permanent MoE abandon)
= the exact combination that produced Sub508's 0 score.
CCCL source: cub/device/dispatch/dispatch_segmented_sort.cuh (1544 lines)
Core design: three-way partition → specialized kernels per size group.
- Large segments → full-block radix sort kernel
- Medium segments → sub-warp merge sort
- Small segments → compact sub-warp
- Below threshold → fallback kernel (no partitioning)
Applied to qwen3_5.py:
At module bottom, try to import base image's native CoreX-accelerated
Qwen3_5ForCausalLM from corex_gdn or qwen3_5_native modules. If found,
replace our PyTorch classes with the native ones.
This is the dispatch_segmented_sort pattern: if a specialized kernel
exists for this hardware (corex_gdn.so), use it. Only fall back to
the generic implementation (our pure-PyTorch code) when the specialized
path is unavailable.
Sub168 used the native CoreX path (zero NaN, 8.49s d01, 17.35GB weights).
Our PyTorch fallback has 99.98% NaN. The dispatch ensures we automatically
use the best available path.