Skip to content

tests: port upstream kernel tests and adapt test infrastructure for MACA compat#255

Open
Dayuxiaoshui wants to merge 1 commit into
MetaX-MACA:masterfrom
Dayuxiaoshui:master
Open

tests: port upstream kernel tests and adapt test infrastructure for MACA compat#255
Dayuxiaoshui wants to merge 1 commit into
MetaX-MACA:masterfrom
Dayuxiaoshui:master

Conversation

@Dayuxiaoshui

Copy link
Copy Markdown
  1. Port missing upstream vLLM kernel tests to tests/kernels/core/:

    • test_apply_rotary_emb.py
    • test_cpu_activation.py
    • test_fused_qk_norm_rope.py
    • test_fused_rms_norm_gated.py
    • test_fused_silu_mul_block_quant.py
    • test_fused_q_kv_rmsnorm.py
    • test_minimax_reduce_rms.py
    • test_rotary_embedding_mla_cache_fused.py
    • test_vit_bilinear_pos_embed.py
    • test_vit_fp8_attn.py
    • test_vit_fp8_quant.py
    • test_vit_fp8_scaling.py
  2. Adapt test infrastructure for upstream API changes:

    • tests/conftest.py: add default_vllm_config fixture; compat imports for ModelDType, RunnerOption, ConvertOption, Logprob, InputContext, etc.; inject infer_schema monkey-patch for PyTorch 2.6+ list[int] compat
    • tests/utils.py: compat imports for FlexibleArgumentParser, GB_bytes, cuda_device_count_stateless, get_open_port; add ensure_current_vllm_config
    • tests/kernels/utils.py: compat imports for AttentionBackend, AttentionMetadata, AttentionType; fallback constants for _Backend, STR_BACKEND_ENV_VAR, etc.
    • tests/kernels/quant_utils.py: compat import for round_up
    • tests/models/utils.py: compat imports for InputContext, Logprob
    • tests/models/registry.py: compat imports for ModelDType, TokenizerMode

PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS (AT THE BOTTOM) HAVE BEEN CONSIDERED.

Purpose

Test Plan

Test Result

(Optional) Documentation Update


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

…ACA compat

1. Port missing upstream vLLM kernel tests to tests/kernels/core/:
   - test_apply_rotary_emb.py
   - test_cpu_activation.py
   - test_fused_qk_norm_rope.py
   - test_fused_rms_norm_gated.py
   - test_fused_silu_mul_block_quant.py
   - test_fused_q_kv_rmsnorm.py
   - test_minimax_reduce_rms.py
   - test_rotary_embedding_mla_cache_fused.py
   - test_vit_bilinear_pos_embed.py
   - test_vit_fp8_attn.py
   - test_vit_fp8_quant.py
   - test_vit_fp8_scaling.py

2. Adapt test infrastructure for upstream API changes:
   - tests/conftest.py: add default_vllm_config fixture; compat imports for
     ModelDType, RunnerOption, ConvertOption, Logprob, InputContext, etc.;
     inject infer_schema monkey-patch for PyTorch 2.6+ list[int] compat
   - tests/utils.py: compat imports for FlexibleArgumentParser, GB_bytes,
     cuda_device_count_stateless, get_open_port; add ensure_current_vllm_config
   - tests/kernels/utils.py: compat imports for AttentionBackend,
     AttentionMetadata, AttentionType; fallback constants for _Backend,
     STR_BACKEND_ENV_VAR, etc.
   - tests/kernels/quant_utils.py: compat import for round_up
   - tests/models/utils.py: compat imports for InputContext, Logprob
   - tests/models/registry.py: compat imports for ModelDType, TokenizerMode
@Dayuxiaoshui

Copy link
Copy Markdown
Author

cc @ILikeIneine

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive set of new kernel tests covering CPU activations, rotary embeddings, fused RMS norms, block quantization, and Vision Transformer (ViT) specific kernels like bilinear position embedding and FP8 attention. It also updates test configurations and utilities with compatibility shims and robust import handling to ensure the test suite works across different vLLM versions. A critical security vulnerability was noted in tests/conftest.py due to the inclusion of /tmp in the system path, which could lead to arbitrary code execution.

Comment thread tests/conftest.py
Comment on lines +1 to +3
import sys
sys.path.insert(0, '/tmp')
import patch_infer_schema

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-critical critical

Modifying sys.path to include a world-writable directory like /tmp is a critical security vulnerability. This allows for arbitrary code execution if a malicious patch_infer_schema.py file is placed in /tmp. The test suite would then import and execute this malicious code, potentially compromising the execution environment.

Instead of modifying sys.path with a hardcoded, insecure path, consider placing the patch_infer_schema.py file within the test directory structure and importing it using a relative path. For example, if it's a test utility, it could live in a tests/utils directory.

@ILikeIneine

ILikeIneine commented May 6, 2026

Copy link
Copy Markdown
Member

@Dayuxiaoshui Have you ever run pytest on metax backend devices?

@Dayuxiaoshui

Copy link
Copy Markdown
Author

@ILikeIneine We have run pytest on the MetaX C500 backend. The test environment was MACA SDK 3.3.0.2 with PyTorch 2.6.0+metax3.3.0.2, using upstream vLLM source via PYTHONPATH. Among the 12 ported kernel test files, 8 execute normally (pass/skip). Two files have substantive failures: test_fused_silu_mul_block_quant.py fails 178 cases due to numerical mismatch in the silu_and_mul_per_block_quant kernel output against the CPU reference, and test_rotary_embedding_mla_cache_fused.py fails 322 cases because the concat_and_cache_mla_rope_fused op is not registered in the current MACA environment. The remaining 4 files are skipped entirely as they depend on upstream modules (e.g., deepseek_v4_ops, qwen3_vl, triton fp8) not available in this environment.

@Dayuxiaoshui

Copy link
Copy Markdown
Author

cc @ILikeIneine

@ILikeIneine

Copy link
Copy Markdown
Member

What your vllm-metax version? We'd like to re-run it with the latest vllm-metax release v0.18.0 in this docker image. Or following the build guild with the latest v0.20.0-dev.

@Dayuxiaoshui

Copy link
Copy Markdown
Author

What your vllm-metax version? We'd like to re-run it with the latest vllm-metax release v0.18.0 in this docker image. Or following the build guild with the latest v0.20.0-dev.

no problem,I will do this work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants