Source: github.com/wudixzy/competition (1527 files, BI-V100 competition reference)
Imported assets:
- 12 prebuilt CoreX .so extensions (corex-3.2.3-ivcore10):
corex_gdn_{beta_decay,causal_conv,gated_norm,packed_decode,qk_map}.so
corex_moe_{direct_routed,exact_reduce,weight_gather}.so
corex_attn_head_rms_norm.so, corex_paged_kv_gather.so
corex_block_major_kv_transfer.so, corex_fused_paged_prefill.so
- 13 CUDA kernel sources (.cu) for above extensions
- 11 build scripts (build_corex_*.sh)
- install_prebuilt_corex.sh (SHA256-verified .so deployment)
- qwen3_5.py (2615 lines) with FULL corex kernel integration
- 9 vllm vendor override files (block manager, sampler, etc)
- 19 patch scripts (model_runner, xformers, block_major, etc)
- Complete serving layer (serving_chat, protocol, api_server, etc)
- bi100_env.py, bi100_profile.py, gdn_prefix.py, block_major_kv_cache.py
- Dockerfile aligned with reference build chain
- computility-run.yaml with BI100_MOE_COREX_DIRECT_ROUTED=1
Call chain verified:
Dockerfile COPY → patch_ops.sh → install_prebuilt_corex.sh → 12 .so to $VLLM_ROOT
qwen3_5.py imports: from vllm import corex_gdn_* / corex_moe_* / corex_attn_*
82 lines
3.4 KiB
Python
82 lines
3.4 KiB
Python
from patch_utils import package_root, replace_one_of
|
|
|
|
WORKER = package_root("vllm") / "worker" / "worker.py"
|
|
|
|
CLEAN_BLOCK = """\
|
|
# Profile the memory usage of the model and get the maximum number of
|
|
# cache blocks that can be allocated with the remaining free memory.
|
|
torch.cuda.empty_cache()
|
|
|
|
# Execute a forward pass with dummy inputs to profile the memory usage
|
|
# of the model.
|
|
self.model_runner.profile_run()
|
|
"""
|
|
|
|
GUARDED_BLOCK = """\
|
|
# Profile the memory usage of the model and get the maximum number of
|
|
# cache blocks that can be allocated with the remaining free memory.
|
|
torch.cuda.empty_cache()
|
|
|
|
# Execute a forward pass with dummy inputs to profile the memory usage
|
|
# of the model. Mark this synthetic pass so BI100_PROFILE can skip
|
|
# timing it by default; profiling real requests is the useful signal.
|
|
_bi100_prev_startup_profile = os.environ.get("BI100_IN_STARTUP_PROFILE")
|
|
os.environ["BI100_IN_STARTUP_PROFILE"] = "1"
|
|
try:
|
|
self.model_runner.profile_run()
|
|
finally:
|
|
if _bi100_prev_startup_profile is None:
|
|
os.environ.pop("BI100_IN_STARTUP_PROFILE", None)
|
|
else:
|
|
os.environ["BI100_IN_STARTUP_PROFILE"] = _bi100_prev_startup_profile
|
|
"""
|
|
|
|
NEW_BLOCK = """\
|
|
# Profile the memory usage of the model and get the maximum number of
|
|
# cache blocks that can be allocated with the remaining free memory.
|
|
torch.cuda.empty_cache()
|
|
|
|
# BI100: Qwen3.6 batched dummy profile_run can trip GDN non-finite
|
|
# checks before the server starts. If the operator explicitly provides
|
|
# --num-gpu-blocks-override, trust that conservative capacity value and
|
|
# skip only the synthetic profile pass. Real inference still uses the
|
|
# normal GDN fail-fast path.
|
|
if self.cache_config.num_gpu_blocks_override is not None:
|
|
cache_block_size = self.get_cache_block_size_bytes()
|
|
if cache_block_size == 0:
|
|
num_cpu_blocks = 0
|
|
else:
|
|
num_cpu_blocks = int(self.cache_config.swap_space_bytes //
|
|
cache_block_size)
|
|
logger.warning(
|
|
"[BI100] skipping worker.profile_run because "
|
|
"num_gpu_blocks_override=%d was explicitly set",
|
|
self.cache_config.num_gpu_blocks_override)
|
|
gc.collect()
|
|
torch.cuda.empty_cache()
|
|
return self.cache_config.num_gpu_blocks_override, max(num_cpu_blocks, 0)
|
|
|
|
# Execute a forward pass with dummy inputs to profile the memory usage
|
|
# of the model. Mark this synthetic pass so BI100_PROFILE can skip
|
|
# timing it by default; profiling real requests is the useful signal.
|
|
_bi100_prev_startup_profile = os.environ.get("BI100_IN_STARTUP_PROFILE")
|
|
os.environ["BI100_IN_STARTUP_PROFILE"] = "1"
|
|
try:
|
|
self.model_runner.profile_run()
|
|
finally:
|
|
if _bi100_prev_startup_profile is None:
|
|
os.environ.pop("BI100_IN_STARTUP_PROFILE", None)
|
|
else:
|
|
os.environ["BI100_IN_STARTUP_PROFILE"] = _bi100_prev_startup_profile
|
|
"""
|
|
|
|
replace_one_of(
|
|
WORKER,
|
|
[
|
|
(GUARDED_BLOCK, NEW_BLOCK),
|
|
(CLEAN_BLOCK, NEW_BLOCK),
|
|
],
|
|
required=True,
|
|
already_contains="[BI100] skipping worker.profile_run",
|
|
)
|