目录
Cao Ying

[Fix][CI] Isolate dynamo state in torch.compile tests (#1743)

Closes #1741

Summary

  • Add a shared isolated_dynamo fixture in tests/conftest.py that runs torch._dynamo.reset() before and after every torch.compile test.
  • Request the fixture from all compile tests (test_compile.py, test_elementwise_compile.py, test_norm_ops.py, test_pool.py), replacing the module-local reset fixture in test_elementwise_compile.py.
  • Fixes FailOnRecompileLimitHit on all three test_mha_kernel_compile cases in the push-tier gpu-smoke run (cross-test dynamo cache pollution, not intrinsic guard churn).

Test plan

  • Modified files pass unit tests (297/297 nodes across the 4 touched test files at 8de7df1e; pre-commit green)
  • All three test_mha_kernel_compile parametrizations pass under the push-tier selection -m "smoke or full" -k compile with push-tier ordering on H200 (11/11; 3 failed pre-fix). CI push-tier confirmation lands on the post-merge run — PR-event gpu-smoke runs -m smoke only.
  • This PR documents the flip commit/mechanism and the layer choice (see Regression)
  • Subsequent push-to-main GPU Smoke run is green (verifiable only after merge)

Regression

  • Flip commit: c9229cab (#1731) added test_max_pool1d/3d_compile_fullgraph (2 params each, smoke tier), raising pre-MHA push-tier compiles from 4 (norm 2 + pool2d 2) to exactly

8.

  • Mechanism: dynamo’s recompile cache is keyed per code object. torch.compile of any plain callable (every TileOps Op instance via Op.__call__) shares torch’s single wrapper frame inner (torch/_dynamo/external_utils.py:66), so each compiled op instance in one pytest process consumes one of the 8 cache_size_limit slots of that shared frame. The first test_mha_kernel_compile case was the 9th entry → FailOnRecompileLimitHit under fullgraph=True; all three MHA parametrizations failed.
  • Reproduction: pytest tests/ops/test_norm_ops.py tests/ops/test_pool.py tests/test_compile.py -m "smoke or full" -k compile — 3 failed pre-fix, 11 passed post-fix on H200. tests/test_compile.py alone passed pre-fix, confirming cross-test cache pollution rather than intrinsic guard churn.
  • Why test-isolation layer (not op wrapper, not a limit raise): the exhausted code object is torch-owned and shared across ALL compiled plain callables, so no tileops/ops/ wrapper change can prevent distinct op instances consuming per-code-object cache slots; each individual compile is legitimate (one entry per instance, no intra-test recompilation). Fix: shared isolated_dynamo fixture in tests/conftest.py (torch._dynamo.reset() before/after) requested by every torch.compile test. Raising cache_size_limit was rejected — it would mask the next capacity flip instead of removing cross-test coupling.

Test node delta

File                                     Base    HEAD    Delta
--------------------------------------------------------------
tests/conftest.py                           0       0        0
tests/ops/test_elementwise_compile.py       0      84      +84
tests/ops/test_norm_ops.py                  5       5        0
tests/ops/test_pool.py                    205     205        0
tests/test_compile.py                       3       3        0
--------------------------------------------------------------
TOTAL                                     213     297      +84

Justification: no real growth. The +84 on tests/ops/test_elementwise_compile.py is a base-side pytest collection failure in the delta tool (warning emitted); the file has the same 84 nodes at base and HEAD — the diff only rewires an autouse fixture (2 insertions, 5 deletions, no test functions added).


Co-authored-by: Ibuki 🍃 — a wind born from GPTs Ibuki-wind@users.noreply.github.com

1天前767次提交

TileOPs

Spec-driven GPU operator library for LLMs — designed for AI agents to build, evaluate, and optimize

Built on TileLang

Spec coverage Bench coverage

Installation | Quick Start | Docs

Status: TileOPs is under active development. APIs may change.

Overview

TileOPs is a GPU operator library for LLM training and inference, built on TileLang. Beyond providing a growing collection of production-quality operators, TileOPs explores a spec-driven development model where AI agents can read declarative operator specifications, generate kernel implementations, and evaluate them against hardware-theoretical performance bounds — with minimal human scaffolding.

Architecture

Every operator is split into two layers with a strict boundary:

  • Op (L2) — stateless Python entry point. Handles validation, dtype casting, and memory layout. Compatible with CUDA-Graph and torch.compile.
  • Kernel (L1) — TileLang GPU implementation with hardware-specific optimizations (Ampere, Hopper).

This separation keeps user-facing behavior independent of GPU strategy, allowing agents and developers to modify either layer without side effects on the other.

Key Properties

  • Spec-driven — each operator is declared in a machine-readable manifest (tileops/manifest/) that specifies signatures, workloads, and roofline formulas, serving as the entry point for both agent code generation and automated validation
  • Roofline-evaluated — kernel performance is measured against Speed-of-Light hardware bounds, not relative baselines
  • Auto-tuning — built-in search over tile sizes, pipelines, and scheduling parameters
  • Lightweight — depends only on TileLang, PyTorch, and einops

Installation

TileOPs can be installed from PyPI or built from source. A CUDA-capable GPU is required.

Prerequisites

  • Python >= 3.10
  • PyTorch >= 2.1
  • CUDA Toolkit
  • NVIDIA GPU: Hopper (SM_90)
  • TileLang == 0.1.9

From PyPI

pip install tileops

From source

git clone https://github.com/tile-ai/TileOPs
cd TileOPs
make install    # dev dependencies + pre-commit hooks

[!NOTE] If CUDA and TileLang are already installed system-wide and you encounter build issues: PIP_NO_BUILD_ISOLATION=1 pip install -e '.[dev]' -v && pre-commit install

Verify:

python -m pytest tests/ -q    # requires a CUDA GPU

Quick Start

import torch
from tileops.ops import GemmOp

M, N, K = 1024, 1024, 512
dtype = torch.float16

gemm = GemmOp(M, N, K, dtype=dtype)

A = torch.randn(M, K, device="cuda", dtype=dtype)
B = torch.randn(K, N, device="cuda", dtype=dtype)

C = gemm(A, B)

Documentation

Design docs and development guides are in docs/. The full API reference and performance tables are published at TileOPs.github.io.

Contributing

See docs/ for design docs. Branch and commit conventions are in .claude/conventions/types.sh.

License

TileOPs is released under the MIT License.

关于

TileOPs 是一个基于 TileLang、面向大模型训练与推理的高性能 GPU 算子库。项目采用 Op 与 Kernel 分层架构,并通过算子 Manifest 描述工作负载和 Roofline 公式,支持对算子进行自动验证和硬件性能上限分析。 TileKernels-Metax 相当于是一个不错的算子清单,已包含 MoE Routing、Quantization、Transpose、Eng

12.0 MB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号