Skip to main content

Chalk

Custom Triton/CUDA kernels that complement Liger Kernel.

pip install freesolo-chalk

Liger fuses the cross-entropy, activation, and RMSNorm paths. Chalk fills the gaps that matter for Freesolo's Flash post-training stack — fused GEMMs, the LoRA-delta matmuls, the QKV norm+RoPE epilogue, embedding gather, and FP8 frozen-base GEMMs — each behind a documented, benchmarked, opt-in entry point.

Chalk's repository layout and conventions intentionally mirror Liger Kernel.

Layout

src/chalk/
  ops/           # raw Triton/CUDA kernels + autograd.Function wrappers
  transformers/  # model-level installers that monkeypatch kernels into HF modules
  utils.py       # device detection helpers
test/            # correctness + gating tests (mirrors test/ops, test/transformers)

Design principles

  • Worker-side kernel library. Like Liger, chalk depends on torch + triton — it is meant to be installed where kernels actually run (the GPU worker), so consumers should depend on it from a gpu extra rather than their base install. Importing the top-level chalk package is still cheap (kernels lazy-load), so probing chalk.utils.infer_device() never forces a heavy import.
  • Complements, not replaces, Liger. Liger fuses CE / activation / RMSNorm; chalk fuses the GEMMs, LoRA delta, QKV epilogue, embedding, and FP8 base.
  • Safe fallback. Every installer is arch-gated, runs a numeric self-test on install, and silently falls back to the eager / Liger path on any import / compile / self-test failure. All installers but one patch only frozen nn.Linear layers (never trainable / PEFT-wrapped layers). The exception is the LoRA-delta installer (install_fused_lora_delta), the one kernel that intentionally accelerates the trainable PEFT LoRA path: it monkeypatches PEFT's dense lora.Linear.forward to route the adapter delta through the fused kernel. Its self-test checks the fused forward and the x / A / B gradients against torch autograd (bf16 tolerance) before patching, and at runtime it falls back to stock PEFT per call for everything the kernel does not replicate exactly (merged / disabled adapters, mixed-adapter batches, LoRA variants, dropout, lora_bias, quantized / non-dense bases, and any non-CUDA tensor) — so a failed self-test or any unsupported layer leaves training numerics on the stock PEFT path.
  • Opt-in & evidence-based. Kernels are off unless explicitly enabled, and every kept kernel has end-to-end loss-curve evidence — not just a microbenchmark.

Development

pip install -e '.[dev]'
make checkstyle   # ruff check + format
make test         # pytest with coverage

Status

Intentionally minimal to start — kernels are landed one at a time under chalk/ops + chalk/transformers, each with correctness tests.

License

BSD-2-Clause. See LICENSE and NOTICE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

freesolo_chalk_dev-0.5.7.tar.gz (397.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

freesolo_chalk_dev-0.5.7-py3-none-any.whl (231.9 kB view details)

Uploaded Python 3

File details

Details for the file freesolo_chalk_dev-0.5.7.tar.gz.

File metadata

  • Download URL: freesolo_chalk_dev-0.5.7.tar.gz
  • Upload date:
  • Size: 397.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for freesolo_chalk_dev-0.5.7.tar.gz
Algorithm Hash digest
SHA256 4e32b9a8567c503259a80500b2f376389dff7df6626b479cab9d9673bf4b85a9
MD5 4b8a1e7a299ceffda20804c1cdf804da
BLAKE2b-256 cb726f063699d8ac7d22ef44131e60f154c6ac8502f4850fce3cb8ba5c786b00

See more details on using hashes here.

File details

Details for the file freesolo_chalk_dev-0.5.7-py3-none-any.whl.

File metadata

  • Download URL: freesolo_chalk_dev-0.5.7-py3-none-any.whl
  • Upload date:
  • Size: 231.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for freesolo_chalk_dev-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a79adb9d1dd79ea002323322b98e92f8df97780b0e971c2507982e119044857c
MD5 49b52122cbc54fe6140e2a7ba47ee16f
BLAKE2b-256 d05b70978cd561184514a94aa02aa0560bc73a3c72db48c305867da51a720532

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.7 This release

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page