Skip to content

Cannot load the FA2 kernel #969

Description

@remi-or

Description

kernels fails to load the flash attention 2 kernel from the hub, seemingly because some metadata is missing.

Steps to reproduce

import kernels

print(f"{kernels.__version__ = }")


kwargs = {
    'repo_id': 'kernels-community/flash-attn2',
    'revision': None,
    'version': 1,
    'trust_remote_code': False,
}
print(f"{kwargs = }")

k = kernels.get_kernel(**kwargs)
print(f"{k = }")

The output is:

kernels.__version__ = '0.15.2'
kwargs = {'repo_id': 'kernels-community/flash-attn2', 'revision': None, 'version': 1, 'trust_remote_code': False}
Fetching ... files: 22it [00:00, 3862.16it/s]00, ?B/s]
Download complete: : 0.00B [00:00, ?B/s]              Traceback (most recent call last):
  File "/fsx/remi_ouazan/transformers/wip.py", line 14, in <module>
    k = kernels.get_kernel(**kwargs)
  File "/fsx/remi_ouazan/transformers/tcb/lib/python3.13/site-packages/kernels/utils.py", line 480, in get_kernel
    return _import_from_path(variant_path, repo_info=repo_info)
  File "/fsx/remi_ouazan/transformers/tcb/lib/python3.13/site-packages/kernels/utils.py", line 199, in _import_from_path
    metadata = Metadata.read_from_file(variant_path / "metadata.json")
ValueError: Cannot parse metadata from `"/fsx/remi_ouazan/.cache/kernels--kernels-community--flash-attn2/snapshots/fbb79e60c84ae9db159e5d0ea74e9724558361ae/build/torch29-cxx11-cu128-x86_64-linux/metadata.json"`: missing field `name` at line 14 column 1

Expected behavior

I would expect the kernel to load, maybe with a warning about the metadata.

Environment

  • kernels 0.15.2
  • Python 3.13.5
  • torch / cuda: '2.9.0+cu128'
  • os: linux

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions