{"id":18495933,"url":"https://github.com/leanprover/KLR","last_synced_at":"2025-08-28T11:31:53.325Z","repository":{"id":259057226,"uuid":"859347567","full_name":"leanprover/KLR","owner":"leanprover","description":"A formalization of ML kernel languages","archived":false,"fork":false,"pushed_at":"2025-08-23T03:17:47.000Z","size":1776,"stargazers_count":24,"open_issues_count":14,"forks_count":7,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-08-24T06:42:47.482Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leanprover.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-18T14:06:55.000Z","updated_at":"2025-08-22T20:34:12.000Z","dependencies_parsed_at":"2024-11-14T20:23:23.902Z","dependency_job_id":"4ed267c1-cdbb-43fb-935e-1bb71cda73cc","html_url":"https://github.com/leanprover/KLR","commit_stats":null,"previous_names":["leanprover/nkl","leanprover/klr"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/leanprover/KLR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2FKLR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2FKLR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2FKLR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2FKLR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leanprover","download_url":"https://codeload.github.com/leanprover/KLR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2FKLR/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272491353,"owners_count":24943644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T13:26:52.559Z","updated_at":"2025-08-28T11:31:53.310Z","avatar_url":"https://github.com/leanprover.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kernel Language Representation (KLR)\n\nThis repository contains an implementation of KLR, a core language and\nelaborators for machine learning kernels. The goal of KLR is to define a common\nrepresentation for kernel functions with a precise formal semantics along with\ntranslations from common kernel languages to the KLR core language. The initial\nfocus of KLR is the\n[Neuron Kernel Interface](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/nki/index.html),\nand the [Trainium](https://aws.amazon.com/ai/machine-learning/trainium/) hardware.\n\n# Building on Amazon Linux 2023\n\nTo build the FFI utilities like Archive, please use\n\nLIBRARY_PATH=/usr/lib64 lake build\n\n(or export the path) to get linking to work correctly.\n\n# Quick Start\n\nThe easiest way to get started using KLR is to install the python package\nusing `pip`:\n\n```\n# pip install klr-lang\n# klr gather test.py test_kernel -o test_kernel.klr\n# klr trace test_kernel.klr\n```\n\nFor more information see the [Getting Started Guide](docs/getting_started.md)\n\n# Interop with Python\n\nThe KLR compiler starts with Python code (e.g. NKI kernels), and converts this\ninto an instance of the abstract syntax tree found in `KLR/Python.lean`. The\ncurrent version of KLR uses the CPython parser to do this conversion. The\nparsing processes is called \"gather\" and involves the following steps:\n\n  1. Load the Python interpreter with our custom CPython extension module\n  2. Find the kernel function and extract its source code\n  3. Run the CPython parser\n  4. Transform the CPython AST to our Python AST\n  5. Repeat steps 2-5 for all found references\n  6. Serialize the AST to the KLR on-disk format\n  7. From Lean, deserialize the Python AST from the on-disk format\n\nThis process is complex and brittle, and will be replaced by a proper (pure\nLean) parser in future versions of KLR.\n\n# Steps to make a new version/wheel\n\n1. Bump the build or minor version in\n- interop/pyproject.toml (Deployment to PyPI will fail if you forget this.)\n- Main.klrCmd (Nothing will break if you don't, but we'd like to be consistent)\n2. Create a git tag of the form v1.2.3 and push it to KLR repo\n\nThis should trigger a build that uploads the artifacts to pypi.\n\n# Adding a new Lake package\n\nIf you want to add a new directory with its own lakefile,\nplease ensure you (relative) symlink lean-toolchain to that directory.\nOtherwise the VSCode plugin will use the top level directory\nlakefile.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleanprover%2FKLR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleanprover%2FKLR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleanprover%2FKLR/lists"}