2026-08-06 06:44:31 +00:00
|
|
|
#!/bin/bash
|
2026-08-08 05:56:58 +00:00
|
|
|
# ==========================================================================
|
2026-08-11 01:35:20 +00:00
|
|
|
# PATCH_OPS.SH v2 — Align with comp 168 strategy
|
2026-08-08 05:56:58 +00:00
|
|
|
#
|
2026-08-11 01:35:20 +00:00
|
|
|
# COMP 168 PROOF (dockerrizhi.txt 07-23 lines 310-397):
|
|
|
|
|
# corex_gdn.py:56 → dlopen libcorex_gdn.so ✅
|
|
|
|
|
# corex_gdn.py:228 → GDN prefill fused ✅
|
|
|
|
|
# corex_gdn.py:138 → GDN decode fused ✅
|
|
|
|
|
# corex_moe.py:339 → MoE prefill: expert-grouped-wmma ✅
|
|
|
|
|
# corex_moe.py:249 → MoE decode fused ✅
|
|
|
|
|
# corex_fa2.py:333 → FA2 packed prefill ✅
|
|
|
|
|
# corex_fa2.py:507 → FA2 paged chunked prefill ✅
|
|
|
|
|
# corex_fa2.py:225 → FA2 paged decode ✅
|
2026-08-08 05:56:58 +00:00
|
|
|
#
|
2026-08-11 01:35:20 +00:00
|
|
|
# ALL 3 corex modules are IN THE BASE IMAGE and work correctly.
|
|
|
|
|
# Our Sub508 failed because we OVERWROTE qwen3_5.py, breaking the call chain.
|
|
|
|
|
#
|
|
|
|
|
# STRATEGY: DO NOT TOUCH model layer. Only deploy:
|
|
|
|
|
# 1. transformers config (Qwen3_5Config)
|
|
|
|
|
# 2. serving layer (protocol/serving_chat/api_server/chat_utils/tool_parser/reasoning)
|
|
|
|
|
# 3. ix_bridge.so (fills ixf_F.vllm_moe_topk_softmax gap if base _custom_ops hits it)
|
|
|
|
|
# 4. _custom_ops.py patch (make topk_softmax use ix_bridge instead of crashing)
|
2026-08-08 05:56:58 +00:00
|
|
|
# ==========================================================================
|
2026-08-05 08:24:38 +00:00
|
|
|
|
2026-08-07 06:20:02 +00:00
|
|
|
cd "$(dirname "$0")"
|
2026-08-11 01:35:20 +00:00
|
|
|
echo "[patch_ops.v2] START — comp 168 aligned strategy"
|
2026-08-07 06:20:02 +00:00
|
|
|
|
2026-08-07 10:37:41 +00:00
|
|
|
VLLM=""
|
|
|
|
|
for P in /usr/local/corex/lib/python3/dist-packages/vllm \
|
|
|
|
|
/usr/local/corex/lib64/python3/dist-packages/vllm; do
|
2026-08-11 01:35:20 +00:00
|
|
|
[ -d "$P" ] && VLLM="$P" && echo "[patch_ops] Found vllm at: $VLLM" && break
|
2026-08-07 10:37:41 +00:00
|
|
|
done
|
fix(CRITICAL): CoreXGDN interface mismatch + engine death protection
Three fixes for the three bugs in latest docker log:
1. corex_gdn.py REWRITTEN — interface now matches qwen3_5.py:
OLD: CoreXGDN(num_heads, head_dim, layer_idx, chunk_size, eps)
NEW: CoreXGDN(num_v_heads, num_k_heads, head_k_dim, head_v_dim, conv_kernel_size, layer_idx)
OLD forward: (q, k, v, gate, beta, conv_state, temporal_state, attn_metadata)
NEW forward: (hidden_states, attn_metadata, conv_state, temporal_state,
in_proj_qkv, in_proj_z, in_proj_b, in_proj_a,
conv1d_weight, A_log, dt_bias, norm, out_proj)
Fixes: 'CoreXGDN.__init__() got unexpected keyword argument num_v_heads'
2. serving_chat.py — engine death protection for multimodal:
When model has no multimodal_config, return 400 instead of passing image data
to engine (which causes permanent AsyncEngineDeadError).
Fixes: 'ValueError: You set image=0 but found 1 items'
3. patch_ops.sh — ALWAYS deploy our modules (base image has bugs):
- qwen3_5.py: ALWAYS deploy (base has NaN)
- corex_gdn/moe/fa2.py: ALWAYS deploy (base interface mismatch)
- corex_fa2.py was MISSING from base → now deployed
2026-08-10 09:51:58 +00:00
|
|
|
[ -z "$VLLM" ] && echo "[patch_ops] ERROR: vllm not found" && exit 1
|
|
|
|
|
|
|
|
|
|
# ---- PROBE ----
|
|
|
|
|
echo "[probe] === Base image state ==="
|
|
|
|
|
_QW="$VLLM/model_executor/models/qwen3_5.py"
|
2026-08-11 01:35:20 +00:00
|
|
|
[ -f "$_QW" ] && echo "[probe] qwen3_5.py: $(wc -c < "$_QW") bytes, $(wc -l < "$_QW") lines" || echo "[probe] qwen3_5.py: MISSING"
|
fix(CRITICAL): CoreXGDN interface mismatch + engine death protection
Three fixes for the three bugs in latest docker log:
1. corex_gdn.py REWRITTEN — interface now matches qwen3_5.py:
OLD: CoreXGDN(num_heads, head_dim, layer_idx, chunk_size, eps)
NEW: CoreXGDN(num_v_heads, num_k_heads, head_k_dim, head_v_dim, conv_kernel_size, layer_idx)
OLD forward: (q, k, v, gate, beta, conv_state, temporal_state, attn_metadata)
NEW forward: (hidden_states, attn_metadata, conv_state, temporal_state,
in_proj_qkv, in_proj_z, in_proj_b, in_proj_a,
conv1d_weight, A_log, dt_bias, norm, out_proj)
Fixes: 'CoreXGDN.__init__() got unexpected keyword argument num_v_heads'
2. serving_chat.py — engine death protection for multimodal:
When model has no multimodal_config, return 400 instead of passing image data
to engine (which causes permanent AsyncEngineDeadError).
Fixes: 'ValueError: You set image=0 but found 1 items'
3. patch_ops.sh — ALWAYS deploy our modules (base image has bugs):
- qwen3_5.py: ALWAYS deploy (base has NaN)
- corex_gdn/moe/fa2.py: ALWAYS deploy (base interface mismatch)
- corex_fa2.py was MISSING from base → now deployed
2026-08-10 09:51:58 +00:00
|
|
|
for m in corex_gdn.py corex_moe.py corex_fa2.py; do
|
|
|
|
|
_F="$VLLM/model_executor/models/$m"
|
|
|
|
|
[ -f "$_F" ] && echo "[probe] $m: $(wc -c < "$_F") bytes" || echo "[probe] $m: MISSING"
|
|
|
|
|
done
|
|
|
|
|
ls -la /usr/local/corex/lib64/libcorex_*.so 2>/dev/null || echo "[probe] no libcorex_*.so"
|
|
|
|
|
echo "[probe] ==========================="
|
2026-08-07 04:51:27 +00:00
|
|
|
|
2026-08-11 01:35:20 +00:00
|
|
|
# Find secondary vllm path for mirroring
|
|
|
|
|
VLLM2=""
|
|
|
|
|
for P in /usr/local/corex/lib/python3/dist-packages/vllm \
|
|
|
|
|
/usr/local/corex/lib64/python3/dist-packages/vllm; do
|
|
|
|
|
[ -d "$P" ] && [ "$P" != "$VLLM" ] && VLLM2="$P" && break
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Helper: deploy to both vllm paths
|
|
|
|
|
deploy_both() {
|
|
|
|
|
local src="$1" dst="$2"
|
|
|
|
|
cp "$src" "$VLLM/$dst" 2>/dev/null || true
|
|
|
|
|
[ -n "$VLLM2" ] && cp "$src" "$VLLM2/$dst" 2>/dev/null || true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ===========================================================
|
|
|
|
|
# 1. Transformers config (Qwen3_5Config support)
|
|
|
|
|
# ===========================================================
|
2026-08-07 10:37:41 +00:00
|
|
|
TMODELS=""
|
fix(critical): remove pip install transformers — was breaking corex kernel loading
ROOT CAUSE FOUND from competitor sub168 docker log comparison:
Sub168 (competitor, works):
- corex_gdn.py:56] Loaded fused CoreX GDN decode operator ✓
- corex_moe.py:339] Using CoreX fused MoE prefill operator ✓
- corex_fa2.py:333] Using CoreX FA2 packed prefill ✓
- NO NaN warnings, NO MoE fallback
- max_model_len=256000, gpu_mem=0.95, max_num_seqs=2 (yaml params work)
Sub509 (ours, broken):
- NaN in prefill GatedDeltaNet layer 0 (frac=0.9998) ✗
- FusedMoE native kernel failed, falling back to PyTorch ✗
- NO corex_gdn/corex_moe/corex_fa2 loading logs at all
- max_model_len=100000, gpu_mem=0.9, max_num_seqs=1 (yaml params ignored)
The pip install transformers==4.55.3 in patch_ops.sh was the likely cause:
it changed dependencies that broke corex kernel loading paths.
Without corex_gdn, GatedDeltaNet falls back to Python → NaN.
Without corex_moe, MoE falls back to PyTorch → 10x slower.
Fix: Remove pip install, use base image's transformers version.
Only register qwen3_5 config files without upgrading the package.
2026-08-07 10:02:09 +00:00
|
|
|
for P in /usr/local/lib/python3.10/site-packages/transformers/models \
|
fix(CRITICAL): CoreXGDN interface mismatch + engine death protection
Three fixes for the three bugs in latest docker log:
1. corex_gdn.py REWRITTEN — interface now matches qwen3_5.py:
OLD: CoreXGDN(num_heads, head_dim, layer_idx, chunk_size, eps)
NEW: CoreXGDN(num_v_heads, num_k_heads, head_k_dim, head_v_dim, conv_kernel_size, layer_idx)
OLD forward: (q, k, v, gate, beta, conv_state, temporal_state, attn_metadata)
NEW forward: (hidden_states, attn_metadata, conv_state, temporal_state,
in_proj_qkv, in_proj_z, in_proj_b, in_proj_a,
conv1d_weight, A_log, dt_bias, norm, out_proj)
Fixes: 'CoreXGDN.__init__() got unexpected keyword argument num_v_heads'
2. serving_chat.py — engine death protection for multimodal:
When model has no multimodal_config, return 400 instead of passing image data
to engine (which causes permanent AsyncEngineDeadError).
Fixes: 'ValueError: You set image=0 but found 1 items'
3. patch_ops.sh — ALWAYS deploy our modules (base image has bugs):
- qwen3_5.py: ALWAYS deploy (base has NaN)
- corex_gdn/moe/fa2.py: ALWAYS deploy (base interface mismatch)
- corex_fa2.py was MISSING from base → now deployed
2026-08-10 09:51:58 +00:00
|
|
|
/usr/local/corex/lib/python3/dist-packages/transformers/models; do
|
|
|
|
|
[ -d "$P" ] && TMODELS="$P" && break
|
fix(critical): remove pip install transformers — was breaking corex kernel loading
ROOT CAUSE FOUND from competitor sub168 docker log comparison:
Sub168 (competitor, works):
- corex_gdn.py:56] Loaded fused CoreX GDN decode operator ✓
- corex_moe.py:339] Using CoreX fused MoE prefill operator ✓
- corex_fa2.py:333] Using CoreX FA2 packed prefill ✓
- NO NaN warnings, NO MoE fallback
- max_model_len=256000, gpu_mem=0.95, max_num_seqs=2 (yaml params work)
Sub509 (ours, broken):
- NaN in prefill GatedDeltaNet layer 0 (frac=0.9998) ✗
- FusedMoE native kernel failed, falling back to PyTorch ✗
- NO corex_gdn/corex_moe/corex_fa2 loading logs at all
- max_model_len=100000, gpu_mem=0.9, max_num_seqs=1 (yaml params ignored)
The pip install transformers==4.55.3 in patch_ops.sh was the likely cause:
it changed dependencies that broke corex kernel loading paths.
Without corex_gdn, GatedDeltaNet falls back to Python → NaN.
Without corex_moe, MoE falls back to PyTorch → 10x slower.
Fix: Remove pip install, use base image's transformers version.
Only register qwen3_5 config files without upgrading the package.
2026-08-07 10:02:09 +00:00
|
|
|
done
|
2026-08-07 10:37:41 +00:00
|
|
|
if [ -n "$TMODELS" ]; then
|
fix(CRITICAL): CoreXGDN interface mismatch + engine death protection
Three fixes for the three bugs in latest docker log:
1. corex_gdn.py REWRITTEN — interface now matches qwen3_5.py:
OLD: CoreXGDN(num_heads, head_dim, layer_idx, chunk_size, eps)
NEW: CoreXGDN(num_v_heads, num_k_heads, head_k_dim, head_v_dim, conv_kernel_size, layer_idx)
OLD forward: (q, k, v, gate, beta, conv_state, temporal_state, attn_metadata)
NEW forward: (hidden_states, attn_metadata, conv_state, temporal_state,
in_proj_qkv, in_proj_z, in_proj_b, in_proj_a,
conv1d_weight, A_log, dt_bias, norm, out_proj)
Fixes: 'CoreXGDN.__init__() got unexpected keyword argument num_v_heads'
2. serving_chat.py — engine death protection for multimodal:
When model has no multimodal_config, return 400 instead of passing image data
to engine (which causes permanent AsyncEngineDeadError).
Fixes: 'ValueError: You set image=0 but found 1 items'
3. patch_ops.sh — ALWAYS deploy our modules (base image has bugs):
- qwen3_5.py: ALWAYS deploy (base has NaN)
- corex_gdn/moe/fa2.py: ALWAYS deploy (base interface mismatch)
- corex_fa2.py was MISSING from base → now deployed
2026-08-10 09:51:58 +00:00
|
|
|
pip install transformers==4.55.3 -i https://pypi.tuna.tsinghua.edu.cn/simple --timeout 30 2>&1 || true
|
|
|
|
|
apt-get update -qq && apt-get install -y -qq ninja-build 2>&1 || true
|
|
|
|
|
cp -r ./qwen3_5 "$TMODELS/" 2>/dev/null || true
|
|
|
|
|
cp -r ./qwen3_5_moe "$TMODELS/" 2>/dev/null || true
|
|
|
|
|
python3 ./patch_transformers_qwen3_5.py 2>&1 || true
|
|
|
|
|
echo "[patch_ops] transformers config deployed"
|
fix(critical): remove pip install transformers — was breaking corex kernel loading
ROOT CAUSE FOUND from competitor sub168 docker log comparison:
Sub168 (competitor, works):
- corex_gdn.py:56] Loaded fused CoreX GDN decode operator ✓
- corex_moe.py:339] Using CoreX fused MoE prefill operator ✓
- corex_fa2.py:333] Using CoreX FA2 packed prefill ✓
- NO NaN warnings, NO MoE fallback
- max_model_len=256000, gpu_mem=0.95, max_num_seqs=2 (yaml params work)
Sub509 (ours, broken):
- NaN in prefill GatedDeltaNet layer 0 (frac=0.9998) ✗
- FusedMoE native kernel failed, falling back to PyTorch ✗
- NO corex_gdn/corex_moe/corex_fa2 loading logs at all
- max_model_len=100000, gpu_mem=0.9, max_num_seqs=1 (yaml params ignored)
The pip install transformers==4.55.3 in patch_ops.sh was the likely cause:
it changed dependencies that broke corex kernel loading paths.
Without corex_gdn, GatedDeltaNet falls back to Python → NaN.
Without corex_moe, MoE falls back to PyTorch → 10x slower.
Fix: Remove pip install, use base image's transformers version.
Only register qwen3_5 config files without upgrading the package.
2026-08-07 10:02:09 +00:00
|
|
|
fi
|
2026-07-30 16:06:20 +00:00
|
|
|
|
2026-08-11 01:35:20 +00:00
|
|
|
# ===========================================================
|
|
|
|
|
# 2. MODEL LAYER — CONDITIONAL deployment
|
|
|
|
|
# If base has qwen3_5.py > 1000 bytes → DO NOT OVERWRITE
|
|
|
|
|
# This is the comp 168 strategy.
|
|
|
|
|
# ===========================================================
|
|
|
|
|
_QW_SIZE=0
|
|
|
|
|
[ -f "$_QW" ] && _QW_SIZE=$(wc -c < "$_QW")
|
|
|
|
|
|
|
|
|
|
if [ "$_QW_SIZE" -gt 1000 ]; then
|
|
|
|
|
echo "[patch_ops] *** BASE IMAGE HAS qwen3_5.py (${_QW_SIZE} bytes) — KEEPING IT ***"
|
|
|
|
|
echo "[patch_ops] *** This is the comp 168 strategy: don't break corex_* call chain ***"
|
|
|
|
|
|
|
|
|
|
# Only add registry entry if missing
|
|
|
|
|
if ! grep -q "Qwen3_5ForCausalLM" "$VLLM/model_executor/models/registry.py" 2>/dev/null; then
|
|
|
|
|
cp ./registry.py "$VLLM/model_executor/models/registry.py" 2>/dev/null && \
|
|
|
|
|
echo "[patch_ops] registry.py deployed (was missing Qwen3_5)"
|
|
|
|
|
[ -n "$VLLM2" ] && cp ./registry.py "$VLLM2/model_executor/models/registry.py" 2>/dev/null || true
|
|
|
|
|
fi
|
2026-08-08 05:56:58 +00:00
|
|
|
else
|
2026-08-11 01:35:20 +00:00
|
|
|
echo "[patch_ops] *** BASE IMAGE MISSING qwen3_5.py — deploying ours ***"
|
|
|
|
|
deploy_both ./qwen3_5.py "model_executor/models/qwen3_5.py"
|
|
|
|
|
deploy_both ./registry.py "model_executor/models/registry.py"
|
|
|
|
|
deploy_both ./mamba_cache.py "model_executor/models/mamba_cache.py"
|
|
|
|
|
|
|
|
|
|
# Only deploy corex modules if base doesn't have them
|
|
|
|
|
for m in corex_gdn.py corex_moe.py corex_fa2.py; do
|
|
|
|
|
if [ ! -f "$VLLM/model_executor/models/$m" ]; then
|
|
|
|
|
deploy_both "/workspace/ex_engine/python/$m" "model_executor/models/$m"
|
|
|
|
|
echo "[patch_ops] deployed $m (was MISSING)"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# flash_qla_sm70 (only if we deployed our qwen3_5.py)
|
|
|
|
|
_FLASH_SRC="/workspace/qwen3_6_scripts/flash_qla_sm70"
|
|
|
|
|
if [ -d "$_FLASH_SRC" ]; then
|
|
|
|
|
for _VPATH in "$VLLM" "$VLLM2"; do
|
|
|
|
|
[ -z "$_VPATH" ] && continue
|
|
|
|
|
cp -r "$_FLASH_SRC" "$_VPATH/model_executor/models/flash_qla_sm70" 2>/dev/null || true
|
|
|
|
|
done
|
|
|
|
|
echo "[patch_ops] flash_qla_sm70 deployed"
|
|
|
|
|
fi
|
2026-08-10 13:10:02 +00:00
|
|
|
fi
|
|
|
|
|
|
2026-08-11 01:35:20 +00:00
|
|
|
# ===========================================================
|
|
|
|
|
# 3. SERVING LAYER — always deploy (comp 168 also used custom serving)
|
|
|
|
|
# ===========================================================
|
2026-08-07 10:37:41 +00:00
|
|
|
mkdir -p "$VLLM/entrypoints/openai/tool_parsers" 2>/dev/null || true
|
2026-08-11 01:35:20 +00:00
|
|
|
[ -n "$VLLM2" ] && mkdir -p "$VLLM2/entrypoints/openai/tool_parsers" 2>/dev/null || true
|
|
|
|
|
|
|
|
|
|
deploy_both ./protocol.py "entrypoints/openai/protocol.py"
|
|
|
|
|
deploy_both ./cli_args.py "entrypoints/openai/cli_args.py"
|
|
|
|
|
deploy_both ./serving_chat.py "entrypoints/openai/serving_chat.py"
|
|
|
|
|
deploy_both ./api_server.py "entrypoints/openai/api_server.py"
|
|
|
|
|
deploy_both ./chat_utils.py "entrypoints/chat_utils.py"
|
|
|
|
|
deploy_both ./qwen3coder_tool_parser.py "entrypoints/openai/tool_parsers/qwen3coder_tool_parser.py"
|
|
|
|
|
deploy_both ./tool_parsers_init.py "entrypoints/openai/tool_parsers/__init__.py"
|
fix(CRITICAL): CoreXGDN interface mismatch + engine death protection
Three fixes for the three bugs in latest docker log:
1. corex_gdn.py REWRITTEN — interface now matches qwen3_5.py:
OLD: CoreXGDN(num_heads, head_dim, layer_idx, chunk_size, eps)
NEW: CoreXGDN(num_v_heads, num_k_heads, head_k_dim, head_v_dim, conv_kernel_size, layer_idx)
OLD forward: (q, k, v, gate, beta, conv_state, temporal_state, attn_metadata)
NEW forward: (hidden_states, attn_metadata, conv_state, temporal_state,
in_proj_qkv, in_proj_z, in_proj_b, in_proj_a,
conv1d_weight, A_log, dt_bias, norm, out_proj)
Fixes: 'CoreXGDN.__init__() got unexpected keyword argument num_v_heads'
2. serving_chat.py — engine death protection for multimodal:
When model has no multimodal_config, return 400 instead of passing image data
to engine (which causes permanent AsyncEngineDeadError).
Fixes: 'ValueError: You set image=0 but found 1 items'
3. patch_ops.sh — ALWAYS deploy our modules (base image has bugs):
- qwen3_5.py: ALWAYS deploy (base has NaN)
- corex_gdn/moe/fa2.py: ALWAYS deploy (base interface mismatch)
- corex_fa2.py was MISSING from base → now deployed
2026-08-10 09:51:58 +00:00
|
|
|
python3 ./patch_vllm_tool_parser.py 2>&1 || true
|
2026-08-07 10:37:41 +00:00
|
|
|
cp -r ./reasoning "$VLLM/" 2>/dev/null || true
|
2026-08-11 01:35:20 +00:00
|
|
|
[ -n "$VLLM2" ] && cp -r ./reasoning "$VLLM2/" 2>/dev/null || true
|
2026-08-07 10:37:41 +00:00
|
|
|
echo "[patch_ops] serving layer deployed"
|
fix(critical): stop replacing base image compute files — use corex native kernels
ROOT CAUSE OF ALL FAILURES:
patch_ops.sh was replacing qwen3_5.py, _custom_ops.py, model_runner.py,
xformers.py, paged_attn.py, prefix_prefill.py, logits_processor.py,
sampler.py, arg_utils.py — killing base image's CoreX fused kernels.
Evidence from competitor sub168 docker logs (d03 PASS in 2.12s):
- 'Using fused CoreX GDN decode operator' (DeltaNet)
- 'Using CoreX fused MoE prefill operator: tokens=4096, kernel=expert-grouped-wmma'
- 'Using CoreX FA2 packed prefill: B=2 Hq=4 Hkv=1 D=256'
- ZERO NaN warnings
- Model weights: 17.35GB (full)
Our sub509 (d03 FAIL in 49s):
- 'NaN in prefill GatedDeltaNet layer 0 (frac=0.9998)' — 99.98% NaN!
- 'FusedMoE native kernel failed, falling back to pure PyTorch'
- No CoreX FA2
- Model weights: 16.23GB (incomplete — 1.1GB missing)
CCCL design principle (dispatch_reduce_deterministic.cuh, transform.cu):
Let the framework's policy_selector choose optimal kernel config per
hardware — never hand-replace the dispatch layer.
Now patch_ops.sh ONLY patches serving layer:
- protocol.py, serving_chat.py, api_server.py, chat_utils.py, cli_args.py
- qwen3coder_tool_parser.py (tool call XML parsing)
- reasoning/ (think tag parsing)
- registry.py (register Qwen3_5 model type)
- transformers models (qwen3_5 config)
Base image compute files PRESERVED:
qwen3_5.py, _custom_ops.py, model_runner.py, xformers.py,
paged_attn.py, prefix_prefill.py, logits_processor.py, sampler.py,
arg_utils.py, sequence.py, scheduler.py
2026-08-07 09:21:43 +00:00
|
|
|
|
2026-08-11 01:35:20 +00:00
|
|
|
# ===========================================================
|
|
|
|
|
# 4. ix_bridge.so — ONLY PURPOSE: fill ixf_F.vllm_moe_topk_softmax gap
|
|
|
|
|
# Even comp 168 had this issue — the base _custom_ops.py tries to call
|
|
|
|
|
# ixf_F.vllm_moe_topk_softmax which doesn't exist.
|
|
|
|
|
# BUT comp 168's corex_moe.py bypasses _custom_ops entirely.
|
|
|
|
|
# So ix_bridge is only needed if base qwen3_5.py path hits _custom_ops.
|
|
|
|
|
# ===========================================================
|
2026-08-10 10:25:31 +00:00
|
|
|
_SITE="/usr/local/corex/lib/python3/dist-packages"
|
|
|
|
|
if [ -d "$_SITE" ]; then
|
|
|
|
|
_EX_DST="$_SITE/ex_engine"
|
|
|
|
|
mkdir -p "$_EX_DST/python" "$_EX_DST/build" "$_EX_DST/csrc"
|
|
|
|
|
cp /workspace/ex_engine/python/*.py "$_EX_DST/python/" 2>/dev/null || true
|
2026-08-11 01:35:20 +00:00
|
|
|
touch "$_EX_DST/__init__.py" "$_EX_DST/python/__init__.py"
|
2026-08-10 10:25:31 +00:00
|
|
|
|
2026-08-11 01:35:20 +00:00
|
|
|
# Deploy pre-built .so
|
2026-08-10 10:25:31 +00:00
|
|
|
if [ -d "/workspace/ex_engine/build" ]; then
|
|
|
|
|
cp /workspace/ex_engine/build/*.so "$_EX_DST/build/" 2>/dev/null || true
|
|
|
|
|
cp /workspace/ex_engine/build/*.so "$_EX_DST/" 2>/dev/null || true
|
2026-08-11 01:35:20 +00:00
|
|
|
echo "[patch_ops] ex_engine .so deployed: $(ls /workspace/ex_engine/build/*.so 2>/dev/null | wc -l) files"
|
2026-08-10 10:25:31 +00:00
|
|
|
fi
|
|
|
|
|
|
2026-08-11 01:35:20 +00:00
|
|
|
# C++ sources for JIT
|
2026-08-10 10:25:31 +00:00
|
|
|
cp /workspace/ex_engine/csrc/ix_full_bridge.cpp "$_EX_DST/csrc/" 2>/dev/null || true
|
2026-08-11 01:35:20 +00:00
|
|
|
cp /workspace/ex_engine/csrc/ix_moe_bridge.cpp "$_EX_DST/csrc/" 2>/dev/null || true
|
2026-08-10 10:25:31 +00:00
|
|
|
|
2026-08-11 01:35:20 +00:00
|
|
|
echo "[patch_ops] ex_engine package deployed to $_SITE"
|
2026-08-10 10:25:31 +00:00
|
|
|
fi
|
|
|
|
|
|
2026-08-11 01:35:20 +00:00
|
|
|
# ===========================================================
|
2026-08-11 02:33:45 +00:00
|
|
|
# 5. XFormers patches — head_dim=256 bypass for BI-V100
|
|
|
|
|
# Comp 168 also had xformers patches (base uses xformers for attention)
|
2026-08-11 01:35:20 +00:00
|
|
|
# ===========================================================
|
2026-08-11 02:33:45 +00:00
|
|
|
python3 ./patch_xformers_sdpa_seq.py 2>&1 || true
|
|
|
|
|
python3 ./patch_xformers_sdpa_batch.py 2>&1 || true
|
|
|
|
|
echo "[patch_ops] xformers patches applied"
|
2026-08-11 01:35:20 +00:00
|
|
|
|
|
|
|
|
# ===========================================================
|
|
|
|
|
# 6. model_runner patch (prefix_cache_hit fix)
|
|
|
|
|
# ===========================================================
|
|
|
|
|
python3 ./patch_model_runner.py 2>&1 || true
|
|
|
|
|
echo "[patch_ops] model_runner patched"
|
|
|
|
|
|
|
|
|
|
# ===========================================================
|
|
|
|
|
# 7. Deploy precompiled .so files
|
|
|
|
|
# ===========================================================
|
2026-08-10 10:25:31 +00:00
|
|
|
for _SO in /workspace/ex_engine/moe_topk_softmax_v3*.so /tmp/torch_extensions/*/moe_topk_softmax_v3*.so; do
|
2026-08-11 01:35:20 +00:00
|
|
|
[ -f "$_SO" ] && cp "$_SO" "$_SITE/" 2>/dev/null && echo "[patch_ops] MoE topk .so: $(basename $_SO)" && break
|
2026-08-10 10:25:31 +00:00
|
|
|
done
|
|
|
|
|
for _SO in /workspace/ex_engine/moe_ops_v055*.so /tmp/torch_extensions/*/moe_ops_v055*.so; do
|
2026-08-11 01:35:20 +00:00
|
|
|
[ -f "$_SO" ] && cp "$_SO" "$_SITE/" 2>/dev/null && echo "[patch_ops] MoE v055 .so: $(basename $_SO)" && break
|
2026-08-10 10:25:31 +00:00
|
|
|
done
|
|
|
|
|
|
2026-08-11 01:35:20 +00:00
|
|
|
echo "[patch_ops.v2] DONE — comp 168 aligned"
|
|
|
|
|
echo "[patch_ops.v2] KEY: base qwen3_5.py $([ "$_QW_SIZE" -gt 1000 ] && echo "KEPT" || echo "REPLACED"), serving layer deployed"
|