Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Validate python_depends.json is up-to-date
run: diff kernels-data/src/python_dependencies.json kernels/src/kernels/python_depends.json
run: diff kernels-common/src/python_dependencies.json kernels/src/kernels/python_depends.json
12 changes: 6 additions & 6 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
- name: Cargo fmt (kernel-abi-check)
run: |
( cd kernel-abi-check && cargo fmt --all -- --check )
- name: Cargo fmt (kernels-data)
- name: Cargo fmt (kernels-common)
run: |
( cd kernels-data && cargo fmt --all -- --check )
( cd kernels-common && cargo fmt --all -- --check )
( cd kernels && cargo fmt --all -- --check )
- name: Cargo fmt (kernel-builder)
run: ( cd kernel-builder && cargo fmt --all -- --check )
Expand All @@ -50,9 +50,9 @@ jobs:
- name: Clippy (kernel-abi-check)
run: |
( cd kernel-abi-check && cargo clippy -- -D warnings )
- name: Clippy (kernels-data)
- name: Clippy (kernels-common)
run: |
( cd kernels-data && cargo clippy -- -D warnings )
( cd kernels-common && cargo clippy -- -D warnings )
( cd kernels && cargo clippy -- -D warnings )
- name: Clippy (kernel-builder)
run: ( cd kernel-builder && cargo clippy -- -D warnings )
Expand All @@ -74,7 +74,7 @@ jobs:
- uses: dtolnay/rust-toolchain@e081816240890017053eacbb1bdf337761dc5582 # 1.95.0
- name: Test (kernel-abi-check)
run: cargo test -p kernel-abi-check
- name: Test (kernels-data)
run: cargo test -p kernels-data
- name: Test (kernels-common)
run: cargo test -p kernels-common
- name: Test (kernel-builder)
run: cargo test -p hf-kernel-builder
2 changes: 1 addition & 1 deletion .github/workflows/security-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
* `kernel-builder`: this is the main user interface for building and uploading kernels,
though it also generates CMake/pyproject files which are used by the NIx builder.
* `kernels`: Python package that can download and load kernels from Hugging Face Hub.
* `kernels-data`: data structures shared by `kernel-builder` and `kernels`.
* `kernels-common`: data structures shared by `kernel-builder` and `kernels`.
* `nix-builder`: Nix code that drives kernel building, also contains Nix derivations for
some dependencies.

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- "kernels/src/**"
- "kernels/rust/**"
- "nix-builder/**"
- "kernels-data/**"
- "kernels-common/**"
- ".github/workflows/test_e2e.yaml"
workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_kernels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- name: Check type stubs match runtime
working-directory: ./kernels
run: uv run python -m mypy.stubtest kernels._data
run: uv run python -m mypy.stubtest kernels._rust

- name: Run tests
working-directory: ./kernels
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ members = [
"kernel-abi-check",
"kernel-builder",
"kernels",
"kernels-data",
"kernels-common",
]
resolver = "2"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export check_dirs := kernels/src kernels/tests

all: kernels/src/kernels/python_depends.json

kernels/src/kernels/python_depends.json: kernels-data/src/python_dependencies.json
kernels/src/kernels/python_depends.json: kernels-common/src/python_dependencies.json
cp $< $@

style:
Expand Down
2 changes: 1 addition & 1 deletion kernel-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/huggingface/kernels"
[dependencies]
base32 = "0.5"
kernel-abi-check = { path = "../kernel-abi-check", version = "0.17.0-dev1" }
kernels-data = { path = "../kernels-data", version = "0.17.0-dev1" }
kernels-common = { path = "../kernels-common", version = "0.17.0-dev1" }
object = "0.36.7"
clap = { version = "4", features = ["derive"] }
clap-markdown = "0.1.5"
Expand Down
2 changes: 1 addition & 1 deletion kernel-builder/src/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
};

use eyre::{bail, Context, Result};
use kernels_data::config::Build;
use kernels_common::config::Build;
use minijinja::{context, Environment};
use rustpython_parser::{ast, Parse};

Expand Down
4 changes: 2 additions & 2 deletions kernel-builder/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::{
};

use eyre::{Context, Result};
use kernels_data::digest::{Digest, DigestAlgorithm};
use kernels_data::metadata::Metadata;
use kernels_common::digest::{Digest, DigestAlgorithm};
use kernels_common::metadata::Metadata;

use crate::util::{check_or_infer_kernel_dir, discover_variants};

Expand Down
2 changes: 1 addition & 1 deletion kernel-builder/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use minijinja::{context, Environment};

use crate::hf;
use crate::pyproject::FileSet;
use kernels_data::config::Backend;
use kernels_common::config::Backend;

fn to_camel_case(s: &str) -> String {
let mut result = String::with_capacity(s.len());
Expand Down
4 changes: 2 additions & 2 deletions kernel-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::path::PathBuf;
use clap::{Args, CommandFactory, Parser, Subcommand};
use clap_complete::Shell;
use eyre::{Context, Result};
use kernels_data::config::{v5, Build, BuildCompat};
use kernels_data::git::Oid;
use kernels_common::config::{v5, Build, BuildCompat};
use kernels_common::git::Oid;

mod card;
mod check_abi;
Expand Down
6 changes: 3 additions & 3 deletions kernel-builder/src/pyproject/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::str::FromStr;
use eyre::Result;
use itertools::Itertools;

use kernels_data::config::{Backend, Build};
use kernels_data::git::{GitStatus, Oid};
use kernels_data::metadata::{KernelBuilderVersion, Metadata, Provenance};
use kernels_common::config::{Backend, Build};
use kernels_common::git::{GitStatus, Oid};
use kernels_common::metadata::{KernelBuilderVersion, Metadata, Provenance};

use crate::pyproject::ops_identifier::KernelIdentifier;
use crate::pyproject::FileSet;
Expand Down
2 changes: 1 addition & 1 deletion kernel-builder/src/pyproject/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io::Write;
use eyre::{Context, Result};
use minijinja::{context, Environment};

use kernels_data::config::{Build, Dependency};
use kernels_common::config::{Build, Dependency};

pub fn render_deps(env: &Environment, build: &Build, write: &mut impl Write) -> Result<()> {
// Collect all dependencies.
Expand Down
2 changes: 1 addition & 1 deletion kernel-builder/src/pyproject/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::io::Write;

use eyre::{Context, Result};
use itertools::Itertools;
use kernels_data::config::{Build, Kernel};
use kernels_common::config::{Build, Kernel};
use minijinja::{context, Environment};

use crate::pyproject::common::prefix_and_join_includes;
Expand Down
6 changes: 3 additions & 3 deletions kernel-builder/src/pyproject/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use std::{
};

use eyre::{bail, Result};
use kernels_data::config::{Build, Framework};
use kernels_data::git::{GitStatus, Oid};
use kernels_data::metadata::Provenance;
use kernels_common::config::{Build, Framework};
use kernels_common::git::{GitStatus, Oid};
use kernels_common::metadata::Provenance;
use minijinja::Environment;

use crate::{
Expand Down
4 changes: 2 additions & 2 deletions kernel-builder/src/pyproject/ops_identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::str::FromStr;

use eyre::{Result, WrapErr};
use git2::Repository;
use kernels_data::config::Backend;
use kernels_data::git::{GitStatus, Oid};
use kernels_common::config::Backend;
use kernels_common::git::{GitStatus, Oid};
use rand::Rng;

pub fn random_identifier() -> String {
Expand Down
4 changes: 2 additions & 2 deletions kernel-builder/src/pyproject/torch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::path::PathBuf;

use eyre::{bail, Context, Result};
use itertools::Itertools;
use kernels_data::config::{Backend, Build, General, Torch};
use kernels_data::metadata::Provenance;
use kernels_common::config::{Backend, Build, General, Torch};
use kernels_common::metadata::Provenance;
use minijinja::context;

use crate::pyproject::common::{
Expand Down
6 changes: 3 additions & 3 deletions kernel-builder/src/pyproject/torch/noarch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use std::path::PathBuf;

use eyre::{Context, Result};
use itertools::Itertools;
use kernels_data::config::TorchNoarch;
use kernels_data::config::{Backend, Build, General};
use kernels_data::metadata::Provenance;
use kernels_common::config::TorchNoarch;
use kernels_common::config::{Backend, Build, General};
use kernels_common::metadata::Provenance;
use minijinja::{context, Environment};

use crate::pyproject::common::write_metadata;
Expand Down
4 changes: 2 additions & 2 deletions kernel-builder/src/pyproject/tvm_ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::io::Write;

use eyre::{bail, Context, Result};
use itertools::Itertools;
use kernels_data::config::{Backend, Build, General, TvmFfi};
use kernels_data::metadata::Provenance;
use kernels_common::config::{Backend, Build, General, TvmFfi};
use kernels_common::metadata::Provenance;
use minijinja::{context, Environment};

use crate::pyproject::common::{
Expand Down
4 changes: 2 additions & 2 deletions kernel-builder/src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use hf_hub::{
HFError, HFRepositorySync, RepoType, RepoTypeKernel, RepoTypeModel,
};
use indicatif::{ProgressBar, ProgressStyle};
use kernels_data::config::Build;
use kernels_data::metadata::Metadata;
use kernels_common::config::Build;
use kernels_common::metadata::Metadata;
use serde::Serialize;
use walkdir::WalkDir;

Expand Down
2 changes: 1 addition & 1 deletion kernel-builder/src/validate_builds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::PathBuf;
use std::{fs::File, io::BufReader};

use eyre::{Context, Result};
use kernels_data::metadata::Metadata;
use kernels_common::metadata::Metadata;

use crate::util::{check_or_infer_kernel_dir, discover_variants};

Expand Down
4 changes: 2 additions & 2 deletions kernels-data/Cargo.toml → kernels-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "kernels-data"
name = "kernels-common"
version = "0.17.0-dev1"
edition = "2024"
description = "Kernels data structures"
description = "Code shared by kernel-builder and kernels"
homepage = "https://github.com/huggingface/kernels"
license = "Apache-2.0"
repository = "https://github.com/huggingface/kernels"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions kernels/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ license = "Apache-2.0"
repository = "https://github.com/huggingface/kernels"

[lib]
name = "_data"
name = "_rust"
path = "rust/lib.rs"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.26", features = ["abi3", "abi3-py38"] }
serde_json = "1"

[dependencies.kernels-data]
path = "../kernels-data"
[dependencies.kernels-common]
path = "../kernels-common"
version = "0.17.0-dev1"
2 changes: 1 addition & 1 deletion kernels/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ kernels = "kernels.cli:main"
"kernels.lock" = "kernels.lockfile:write_egg_lockfile"

[tool.maturin]
module-name = "kernels._data"
module-name = "kernels._rust"
python-source = "src"
bindings = 'pyo3'
features = ["pyo3/extension-module"]
Expand Down
2 changes: 1 addition & 1 deletion kernels/rust/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::PathBuf;

use kernels_data::config::{Build, General};
use kernels_common::config::{Build, General};
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;

Expand Down
12 changes: 6 additions & 6 deletions kernels/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use std::io::BufReader;
use std::path::PathBuf;
use std::str::FromStr;

use kernels_data::config::{Backend, KernelDependency, KernelName, KernelVersion};
use kernels_data::digest::{Digest, DigestAlgorithm, DigestViolation};
use kernels_data::git::{GitStatus, Oid};
use kernels_data::metadata::{BackendInfo, KernelBuilderVersion, Metadata, Provenance};
use kernels_common::config::{Backend, KernelDependency, KernelName, KernelVersion};
use kernels_common::digest::{Digest, DigestAlgorithm, DigestViolation};
use kernels_common::git::{GitStatus, Oid};
use kernels_common::metadata::{BackendInfo, KernelBuilderVersion, Metadata, Provenance};
use pyo3::Bound as PyBound;
use pyo3::exceptions::{PyException, PyOSError, PyRuntimeError, PyValueError};
use pyo3::prelude::*;
Expand Down Expand Up @@ -658,7 +658,7 @@ impl PyDigestViolation {
}

pyo3::create_exception!(
_data,
_rust,
DigestValidationError,
PyException,
"Raised by `Digest.validate` when the actual digest does not match the \
Expand Down Expand Up @@ -750,7 +750,7 @@ impl PyDigest {
}
}

#[pyo3::pymodule(name = "_data")]
#[pyo3::pymodule(name = "_rust")]
fn data_py(m: &PyBound<'_, PyModule>) -> PyResult<()> {
m.add_class::<PyBackend>()?;
m.add_class::<PyBackendInfo>()?;
Expand Down
4 changes: 2 additions & 2 deletions kernels/rust/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::collections::BTreeMap;
use std::path::PathBuf;
use std::str::FromStr;

use kernels_data::git::Oid;
use kernels_data::lock::{KernelLock, KernelLocks, KernelPaths, NixKernelLock, NixKernelLocks};
use kernels_common::git::Oid;
use kernels_common::lock::{KernelLock, KernelLocks, KernelPaths, NixKernelLock, NixKernelLocks};
use pyo3::Bound as PyBound;
use pyo3::exceptions::{PyKeyError, PyValueError};
use pyo3::prelude::*;
Expand Down
4 changes: 2 additions & 2 deletions kernels/rust/version.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::cmp::Ordering;
use std::hash::{Hash, Hasher};

use kernels_data::version::Version;
use kernels_common::version::Version;
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;

Expand All @@ -10,7 +10,7 @@ use pyo3::prelude::*;
#[pyclass(name = "Version", frozen, eq, ord, hash)]
#[derive(Clone, Debug)]
pub(crate) struct PyVersion {
// We are storing this as a `Box<[usize]>` to allow storing kernels-data
// We are storing this as a `Box<[usize]>` to allow storing kernels-common
// `Version` in directly in `PyVersion` as well.
inner: Box<[usize]>,
}
Expand Down
2 changes: 1 addition & 1 deletion kernels/src/kernels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__version__ = importlib.metadata.version("kernels")

from kernels._data import Metadata
from kernels._rust import Metadata
from kernels._windows import _add_additional_dll_paths
from kernels.benchmark import Benchmark
from kernels.deps import get_kernel_dep
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Type stubs for the `kernels._data` module."""
"""Type stubs for the `kernels._rust` module."""

import os
from collections.abc import Iterator
Expand Down
Loading
Loading