Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1b2d8fb
working version --> need to fix upstream kernels to match signature a…
vasqu May 18, 2026
f9212eb
add swiglu mlp
vasqu May 18, 2026
dd1a67a
well well well, rms norm was the culprit all along...
vasqu May 29, 2026
1139b4e
fix mode logic and bump version (will need another bump)
vasqu Jun 1, 2026
b2dcc45
no longer maintained
vasqu Jun 1, 2026
cb0ef71
fix switching mode only on changing base flags (train<->eval)
vasqu Jun 1, 2026
4a04de2
new format to be used
vasqu Jun 4, 2026
9595dec
revert this one
vasqu Jun 4, 2026
2da8885
bump version
vasqu Jun 4, 2026
f5c00b0
update to newest state
vasqu Jun 11, 2026
25a43d5
revert actual usage on models
vasqu Jun 11, 2026
40d1389
sync all versions and fix kernels config
vasqu Jun 12, 2026
b91e19e
Merge branch 'main' into causallm-kernels
vasqu Jun 12, 2026
a33e778
current changes, only need to update the other kernels now
vasqu Jun 16, 2026
3e719ef
try this
vasqu Jun 16, 2026
e2da24f
oops
vasqu Jun 16, 2026
2fbdc55
last fixes
vasqu Jun 16, 2026
87c30c9
Merge branch 'main' into causallm-kernels
vasqu Jun 16, 2026
9dd63b1
also allow updating remote code trust
vasqu Jun 16, 2026
41651a8
Merge branch 'main' into causallm-kernels
vasqu Jun 17, 2026
e5de62d
small refinement to kernelize pattern through set use kernels always …
vasqu Jun 17, 2026
1ec50dc
oops
vasqu Jun 17, 2026
8597923
nit
vasqu Jun 17, 2026
9e4a2f4
less dirty
vasqu Jun 17, 2026
f2ecb90
make it a revision just to be sure
vasqu Jun 17, 2026
f1c52f6
Merge branch 'main' into causallm-kernels
vasqu Jun 17, 2026
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
3 changes: 1 addition & 2 deletions benchmark_v2/framework/benchmark_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def is_fa2_or_kernel_available() -> bool:
try:
from kernels import get_kernel

# TODO: Pass the 'version' kwarg to specify the binary version once kernels >= 0.12.0 is supported.
get_kernel("kernels-community/flash-attn2")
get_kernel("kernels-community/flash-attn2", version=1)
except Exception as _:
logger.warning(
"flash_attention_2 is not available. kernels is installed, but the flash_attn kernel is not available."
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"jinja2>=3.1.0",
"jmespath>=1.0.1",
"kenlm",
"kernels>=0.12.0,<0.13",
"kernels>=0.15.2,<0.16",
"librosa",
"mistral-common[image]>=1.10.0",
"nltk<=3.8.1",
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/cli/serving/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ def _resolve_attn_implementation(cls, attn_implementation: str | None, device: s

import torch

from ...integrations.hub_kernels import _kernels_available
from ...utils.import_utils import is_kernels_available

is_mps_device = (
isinstance(device, str)
and device.startswith("mps")
or (device == "auto" and torch.backends.mps.is_available() and not torch.cuda.is_available())
)
if is_mps_device and _kernels_available:
if is_mps_device and is_kernels_available():
logger.warning_once(
"MPS detected and `kernels` is installed: defaulting attention to "
"`kernels-community/metal-flash-sdpa@223ca3350d7ba32ecf19341ff2cbb8c43fa47d62. "
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/dependency_versions_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"jinja2": "jinja2>=3.1.0",
"jmespath": "jmespath>=1.0.1",
"kenlm": "kenlm",
"kernels": "kernels>=0.12.0,<0.13",
"kernels": "kernels>=0.15.2,<0.16",
Comment thread
vasqu marked this conversation as resolved.
Resolved
"librosa": "librosa",
"mistral-common[image]": "mistral-common[image]>=1.10.0",
"nltk": "nltk<=3.8.1",
Expand Down
10 changes: 8 additions & 2 deletions src/transformers/integrations/deepgemm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

from ..utils import logging
from ..utils.import_utils import (
KERNELS_MAX_VERSION,
KERNELS_MIN_VERSION,
get_cuda_runtime_version,
is_kernels_available,
is_torchdynamo_compiling,
Expand Down Expand Up @@ -81,7 +83,9 @@ def _load_deepgemm_kernel(requires_sm100: bool = False) -> DeepGEMM:
if not is_torchdynamo_compiling():
if not is_kernels_available():
raise ImportError(
"DeepGEMM kernel requires the `kernels` package. Install it with `pip install -U kernels`."
"DeepGEMM kernel requires the `kernels` package. "
f"Please install a compatible version ({KERNELS_MIN_VERSION} <= version < {KERNELS_MAX_VERSION}), "
f"e.g. `pip install kernels=={KERNELS_MIN_VERSION}`"
Comment on lines +87 to +88

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also recommend pip install transformers[kernels] and remove the MIN/MAX_VERSION imports.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to keep, at some point we want to remove the dedicated kernels tbh so this seems more explicit

)
if not torch.cuda.is_available():
raise ImportError("DeepGEMM kernel requires CUDA, but CUDA is not available.")
Expand Down Expand Up @@ -140,7 +144,9 @@ def _load_deepgemm_kernel(requires_sm100: bool = False) -> DeepGEMM:
]
if missing:
raise ImportError(
f"DeepGEMM kernel is missing required symbols: {', '.join(missing)}. Update with `pip install -U kernels`."
f"DeepGEMM kernel is missing required symbols: {', '.join(missing)}. "
f"Please install a compatible version ({KERNELS_MIN_VERSION} <= version < {KERNELS_MAX_VERSION}), "
f"e.g. `pip install kernels=={KERNELS_MIN_VERSION}`"
)
return DeepGEMM(
fp8_fp4_matmul=fp8_fp4_matmul,
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/integrations/eetq.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def replace_with_eetq_linear(model, modules_to_not_convert: list[str] | None = N
from .hub_kernels import get_kernel

global eetq_kernels_hub
eetq_kernels_hub = get_kernel("kernels-community/quantization-eetq")
eetq_kernels_hub = get_kernel("kernels-community/quantization-eetq", version=1)

has_been_replaced = False
# we need this to correctly materialize the weights during quantization
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/integrations/fbgemm_fp8.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def get_quantize_fp8_per_row():
if _is_torch_xpu_available:
from .hub_kernels import get_kernel

return get_kernel("kernels-community/fp8-fbgemm").quantize_fp8_per_row
return get_kernel("kernels-community/fp8-fbgemm", version=1).quantize_fp8_per_row
return torch.ops.fbgemm.quantize_fp8_per_row


Expand Down
14 changes: 11 additions & 3 deletions src/transformers/integrations/finegrained_fp8.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
from ..core_model_loading import ConversionOps
from ..quantizers.quantizers_utils import get_module_from_name, should_convert_module
from ..utils import logging
from ..utils.import_utils import is_kernels_available, is_torchdynamo_compiling
from ..utils.import_utils import (
KERNELS_MAX_VERSION,
KERNELS_MIN_VERSION,
is_kernels_available,
is_torchdynamo_compiling,
)
from .deepgemm import (
deepgemm_fp8_fp4_experts_forward,
deepgemm_fp8_fp4_linear,
Expand Down Expand Up @@ -83,7 +88,9 @@ def _load_finegrained_fp8_kernel() -> FineGrainedFP8:
if not is_torchdynamo_compiling():
if not is_kernels_available():
raise ImportError(
"finegrained-fp8 kernel requires the `kernels` package. Install it with `pip install -U kernels`."
"finegrained-fp8 kernel requires the `kernels` package. "
f"Please install a compatible version ({KERNELS_MIN_VERSION} <= version < {KERNELS_MAX_VERSION}), "
f"e.g. `pip install kernels=={KERNELS_MIN_VERSION}`"
)

kernel = lazy_load_kernel("finegrained-fp8")
Comment on lines 89 to 96

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does lazy_load_kernel raise the error when kernels is not available or return None ? if it raises it maybe we don't need the check above

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it has a fallback mechanism so it's not as clear as doing it this way

Expand All @@ -109,7 +116,8 @@ def _load_finegrained_fp8_kernel() -> FineGrainedFP8:
if missing:
raise ImportError(
f"finegrained-fp8 kernel is missing required symbols: {', '.join(missing)}. "
"Please update the `kernels` package (`pip install -U kernels`)."
f"Please install a compatible version ({KERNELS_MIN_VERSION} <= version < {KERNELS_MAX_VERSION}), "
f"e.g. `pip install kernels=={KERNELS_MIN_VERSION}`"
)

return FineGrainedFP8(
Expand Down
Loading
Loading