Research Papers 论文研究 4h ago Updated 2h ago 更新于 2小时前 49

Cross-Dialect Generalization Without Retraining: Benchmarks and Evaluation of Schema-Derived Constrained Decoding for MLIR 无需重新训练的跨方言泛化:基于模式推导的约束解码用于MLIR的基准与评估

Introduces schema-derived constrained decoding for MLIR, allowing small language models to generate valid code without fine-tuning by using mechanical priors from Operation Definition Specifications. Releases four new benchmarks (MLIR-Spec-150, Linalg-Spec-30, StableHLO-Spec-30, StableHLO-Held-Out-200) totaling 410 natural-language-to-MLIR pairs, addressing the scarcity of MLIR data in pretraining corpora. Demonstrates that SmolLM2-1.7B matches or exceeds larger 15B-34B code LMs on structural di 提出无需重新训练即可实现跨MLIR方言泛化的推理时约束解码方案,利用操作定义规范(ODS)生成先验。 发布四个自然语言到MLIR的基准测试套件,涵盖Linalg和StableHLO等方言,包含410个有效配对及压力测试集。 构建三层架构的约束栈(CFG签名、类型域分割、SSA作用域验证器),支持通过拒绝采样提高代码正确性。 在结构主导的方言中,1.7B参数的SmolLM2模型在验证通过率上超越15B-34B的大模型,且生成速度快8-25倍。

65
Hot 热度
75
Quality 质量
70
Impact 影响力

Analysis 深度分析

TL;DR

  • Introduces schema-derived constrained decoding for MLIR, allowing small language models to generate valid code without fine-tuning by using mechanical priors from Operation Definition Specifications.
  • Releases four new benchmarks (MLIR-Spec-150, Linalg-Spec-30, StableHLO-Spec-30, StableHLO-Held-Out-200) totaling 410 natural-language-to-MLIR pairs, addressing the scarcity of MLIR data in pretraining corpora.
  • Demonstrates that SmolLM2-1.7B matches or exceeds larger 15B-34B code LMs on structural dialects like Linalg, achieving 80% verification validity at 8-25x faster generation speeds.
  • Proposes a three-layer constraint stack (CFG, type-domain splits, SSA-scope validator) that generalizes across dialects without requiring new code for porting, such as moving from arith+func+memref+linalg to StableHLO.

Why It Matters

This research addresses a critical bottleneck in ML compiler infrastructure: the lack of high-quality MLIR data in code LLM training sets and the impracticality of fine-tuning separate models for every new dialect. By shifting adaptation from training time to inference time via schema constraints, it enables scalable, zero-shot cross-dialect generalization. This approach significantly reduces computational costs while improving code validity, making it highly relevant for developers building ML compilers and tools that rely on intermediate representations.

Technical Details

  • Constraint Stack Architecture: Implements a three-layer system: (C1) Context-Free Grammar (CFG) over operation signatures, (C2) Type-domain splits extracted from an ODS-extracted type lattice, and (C3) an SSA-scope validator that drives a five-retry rejection sampling mechanism.
  • Benchmark Suite: Provides Apache-2.0 licensed datasets including MLIR-Spec-150, Linalg-Spec-30, StableHLO-Spec-30, and StableHLO-Held-Out-200, along with out-of-grammar stress tests and functional reference sets, accompanied by Gebru datasheets and Croissant 1.0 metadata.
  • Performance Metrics: On the Linalg dialect, SmolLM2-1.7B achieved an 80.0% verify-valid rate (mean over three seeds, n=125), outperforming CodeLlama-34B, Granite-Code-34B, and StarCoder2-15B by 21-44 percentage points.
  • Generalization Capability: The method requires no new constraint-layer code to port between dialects, successfully applying constraints derived from arith+func+memref+linalg to StableHLO without modification.
  • Limitations: The approach is less effective on dialects where verifier semantics depend on specific attribute values rather than structural constraints, such as arith+func and templated parametric StableHLO, where larger baselines performed better.

Industry Insight

  • Cost-Efficient Model Deployment: Organizations can leverage smaller, faster models for complex compiler tasks by integrating schema constraints, reducing inference latency and hardware requirements compared to deploying massive 30B+ parameter models.
  • Scalable Compiler Tooling: As MLIR dialects proliferate across different hardware accelerators and frameworks, this zero-shot generalization strategy offers a sustainable path for maintaining code generation tools without the overhead of continuous fine-tuning for each new domain.
  • Data Scarcity Mitigation: For domains with limited training data like specialized IRs, combining lightweight models with rigorous syntactic/semantic constraints at inference time provides a viable alternative to data-hungry deep learning approaches.

TL;DR

  • 提出无需重新训练即可实现跨MLIR方言泛化的推理时约束解码方案,利用操作定义规范(ODS)生成先验。
  • 发布四个自然语言到MLIR的基准测试套件,涵盖Linalg和StableHLO等方言,包含410个有效配对及压力测试集。
  • 构建三层架构的约束栈(CFG签名、类型域分割、SSA作用域验证器),支持通过拒绝采样提高代码正确性。
  • 在结构主导的方言中,1.7B参数的SmolLM2模型在验证通过率上超越15B-34B的大模型,且生成速度快8-25倍。

为什么值得看

对于致力于优化ML编译器前端或开发专用代码大模型的研究者而言,该工作证明了通过结构化约束而非大规模微调即可显著提升小模型的代码生成能力。它为降低MLIR相关AI应用的计算成本和部署门槛提供了极具参考价值的新范式。

技术解析

  • 基准测试发布:构建了MLIR-Spec-150、Linalg-Spec-30、StableHLO-Spec-30及StableHLO-Held-Out-200四个基准,总计410个自然语言到MLIR的代码对,并附带Apache-2.0许可的数据集元数据。
  • 三层约束架构:设计了基于ODS的约束栈,包括基于操作签名的上下文无关文法(CFG)、从类型格中提取的类型域分割,以及驱动五重试拒绝采样的SSA作用域验证器。
  • 零代码迁移泛化:约束层设计具有通用性,从基础方言(arith+func+memref+linalg)迁移到StableHLO时,无需编写新的约束层代码即可适配新方言的结构要求。
  • 性能对比优势:在Linalg方言上,SmolLM2-1.7B达到80.0%的验证通过率,显著优于CodeLlama-34B、Granite-Code-34B和StarCoder2-15B,且在属性值敏感的场景下表现持平。

行业启示

  • 小模型的高效替代路径:在特定领域(如MLIR编译),结合强结构约束的小参数模型可媲美甚至超越超大参数模型,应优先考虑“小模型+强规则”的架构以平衡成本与性能。
  • 标准化评估的重要性:随着MLIR在AI基础设施中的普及,建立标准化的NL-to-MLIR基准测试对于客观评估编译器辅助工具的能力至关重要,有助于推动行业基准统一。
  • 推理时优化的潜力:利用领域知识(如ODS规范)在推理阶段注入先验信息,是一种可扩展的适应新方言的策略,避免了为每个新应用域进行昂贵的梯度微调。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Code Generation 代码生成 Benchmark 基准测试 Research 科学研究 Fine-tuning 微调 LLM 大模型