본문으로 건너뛰기
cccskills
무료GitHub에 공개

add-pallas-kernel

Add or update Pallas/Mosaic kernels, specialized computation routines for JAX. The skill covers reference implementations, output and gradient checks, public wrappers, fallback behavior, performance benchmarks, and hardware-specific tuning when requested.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

Add or change a named Pallas/Mosaic kernel, including its reference implementation, correctness tests, wrapper, or requested tuning.

설치 방법 보기

이럴 때 유용합니다

  • Adding a Pallas kernel for a JAX computation
  • Checking outputs and gradients against a reference
  • Maintaining backend selection and fallback behavior
  • Benchmarking and tuning kernels for target hardware

포함된 파일(8)

  • SKILL.md6.1 KB
  • docs/api-patterns.md3.5 KB
  • docs/gpu-tips.md586 B
  • docs/kernel-sources.md2.9 KB
  • docs/performance-workflow.md5.4 KB
  • docs/reference/llo.md4.5 KB
  • docs/reference/profiling.md3.4 KB
  • docs/tpu-tips.md1.9 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Add or update a Pallas kernel

How to apply this skill

Load only the detail files needed for the requested work:

  • Kernel sources: read when choosing an in-repo or external kernel to imitate.
  • Performance workflow: read before benchmarking, profiling, roofline analysis, or autotuning.
  • API patterns: read before adding or changing a public kernel wrapper, fallback order, or block-size config.
  • TPU tips: read for TPU Pallas/Mosaic kernels, TPU-specific lowering failures, scoped VMEM, or TPU compiler dumps.
  • GPU tips: read for GPU Pallas/Mosaic work.
  • Deep references live under docs/reference/; read them only when the routed detail files point there.

Use research only when the user explicitly requests a multi-session research workflow.

Kernel Deliverables

For a kernel K, produce:

  • Vanilla JAX reference and Pallas wrapper with the same public API.
  • Value, gradient, CPU, and applicable accelerator parity harness.
  • Explicit backend and shape validation, with tests for ordered implementation selection and each fallback path.
  • Roofline estimate and steady-state benchmark on representative shapes/dtypes.
  • When tuning is requested, bounded autotuning, a checked-in tuned table, explicit fallback, and cached autotune-on-miss results.

Correctness Workflow

1. Start from a reference

Use an existing in-repo implementation, pseudocode, a PyTorch reference, or a JAX baseline. The baseline must be obvious and stable, not clever. If the naive baseline would materialize huge intermediates, use a streaming/blockwise baseline with identical math.

2. Write a value and gradient harness

Minimum checks:

  • Value parity over a shape/dtype grid.
  • Gradient parity on small shapes.
  • Backend numerics on CPU and accelerator backends as applicable.
  • Pointwise deviation metrics such as max/mean absolute diff, not only allclose.

Use explicit shape/dtype annotations for public APIs and references, such as jaxtyping, where available.

3. Promote long-lived checks to pytest

For in-tree kernels, add or extend tests under lib/levanter/tests/kernels/. Compare the default implementation against the reference on small CPU shapes and accelerator-aligned shapes for fast paths. Read TESTING.md and the nearest module AGENTS.md before writing or changing tests.

Pallas Kernel Workflow

Once the reference is correct, design the Pallas implementation. Use the reference as both a correctness oracle and a performance baseline.

Use existing kernels for structure and API inspiration. Read Kernel sources unless the user already named the specific kernel to follow. Unless there is a stronger local pattern, start by reimplementing the reference in Pallas.

Wrap accelerator kernel boundaries in an explicit jax.shard_map by default. This applies to pl.pallas_call, Mosaic GPU kernels, and custom FFI calls. Reshard inputs to the intended local PartitionSpec before the shard_map, keep the sequence or other nonlocal dimensions unsharded unless the kernel is explicitly written for them, and add a regression check that the lowered JAXPR or HLO contains the expected shard_map. Do not rely on XLA to infer a good sharding for an opaque kernel call boundary. Exceptions are limited to wrappers whose inputs are explicitly documented and tested as fully local or replicated.

Check correctness against the harness and reference implementation before tuning. Once the kernel is correct, run a performance harness on representative shapes/dtypes and compare against the roofline. If performance is not near the expected roofline, read Performance workflow and investigate compiler dumps, pressure signals, and tile choices before broad rewrites.

API Conventions

Read API patterns before adding or changing the public wrapper, backend selection, block-size config, or input normalization contract. Keep the reference/XLA path usable even when accelerator-specific constraints are not met. Keep backend-specific validation in backend-specific modules.

Cost Estimate Requirement

Add cost_estimate= to each pl.pallas_call:

  • Use pl.estimate_cost on a body-equivalent JAX function, not a kernel body with pl.program_id.
  • Include IO bytes from call inputs/outputs.
from levanter.kernels.pallas.cost_estimate_utils import with_io_bytes_accessed


def _cost_estimate(
    q: jax.Array,
    k: jax.Array,
    v: jax.Array,
    *,
    kernel_inputs_specs,
    kernel_outputs_specs,
) -> pl.CostEstimate | None:
    body_cost = pl.estimate_cost(reference_impl, q, k, v)
    return with_io_bytes_accessed(
        body_cost,
        kernel_inputs_specs=kernel_inputs_specs,
        kernel_outputs_specs=kernel_outputs_specs,
    )

Definition of Done

  • Values match reference within tolerance on the tested grid.
  • Gradients match reference on small shapes.
  • CPU/reference and accelerator fast paths are covered by tests where applicable.
  • Public API, fallback semantics, block-size config, and tuned table behavior match API patterns.
  • Every Pallas, Mosaic, or FFI kernel call is inside an explicit shard_map, or its wrapper documents and tests why the inputs are fully local or replicated. Tests or profile evidence show it did not lower through unintended all-gathers.
  • Each pl.pallas_call has a reviewed cost_estimate=.
  • Benchmark/tuning artifacts include the required schema from Performance workflow.
  • Roofline performance is within expected bounds, or limitations are explicitly documented.
  • Performance improves on at least one realistic target shape, or limitations are explicitly documented.
  • Tuned table is checked in for requested hardware/shape regimes.
  • Long-running research records follow the research workflow.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Compare Zephyr changes using the same prepared dataset and matching execution settings. Analyze Finelog metrics for each processing stage to distinguish CPU efficiency, elapsed time, and peak memory changes, then report improvements, regressions, or tradeoffs.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Compare Zephyr performance before and after a PR
  • Assess speed gains against additional CPU usage
  • Check peak memory and out-of-memory regressions
marin-community/marin4천2026년 10월 22일 업데이트

Register Hugging Face datasets for Marin by inspecting their structure without downloading the full dataset. Identify text fields, configurations, and data splits, then add a dataset module and validate the mapping with a sample.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Registering a Hugging Face dataset for Marin
  • Inspecting text fields without a full dataset download
  • Checking configurations and data splits
marin-community/marin4천2026년 10월 22일 업데이트

add-grant

무료

Turn a specified GCP access request into a reviewable Pulumi change and pull request. Select the narrowest suitable role and encrypt personal email identities, covering resource permissions and Cloud Run viewer access through IAP, an access gateway.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Prepare a request for GCS bucket read access
  • Add a viewer to a Cloud Run service protected by IAP
  • Prepare service account impersonation permissions
marin-community/marin4천2026년 10월 22일 업데이트

Preserve old experiment scripts with a dated Git tag, a named snapshot of the code, and add comments linking related GitHub issues to the archived files and cleanup pull request.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Preserving a snapshot of old experiment scripts
  • Linking experiment issues to archived files
  • Updating archive notices after a tag changes
marin-community/marin4천2026년 10월 22일 업데이트

Launch and continuously monitor a specified Zephyr pipeline on Iris when asked. It checks coordinator and worker health, tracks stage progress, identifies stalled or repeated failures, and requires explicit approval before stopping or restarting jobs.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Launch a specified Zephyr pipeline and check startup
  • Monitor stage progress and worker health over time
  • Investigate stalled stages or repeated worker failures
marin-community/marin4천2026년 10월 22일 업데이트

Try model or training changes in a copied Grug or Grugformer experiment, document the differences, and bring successful changes back into the base template while removing superseded experiment code and checking behavior.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Try changes to attention or masking
  • Experiment with optimizers or training loops
  • Bring successful changes into the base template
marin-community/marin4천2026년 10월 22일 업데이트

marin-community의 스킬 모두 보기

이 스킬의 문제 신고