Skip to content

feat: ROCm flash-attn varlen, triton layer norm, and AMD Dockerfile#860

Open
Abdennacer-Badaoui wants to merge 10 commits into
huggingface:mainfrom
Abdennacer-Badaoui:fa-varlen
Open

feat: ROCm flash-attn varlen, triton layer norm, and AMD Dockerfile#860
Abdennacer-Badaoui wants to merge 10 commits into
huggingface:mainfrom
Abdennacer-Badaoui:fa-varlen

Conversation

@Abdennacer-Badaoui

Copy link
Copy Markdown
Member

Adds flash attention varlen, triton-based layer norm/rms norm via kernels-community/triton-layer-norm, and a dedicated Dockerfile-amd with CI matrix entry for MI300/MI325 GPUs.

@Abdennacer-Badaoui Abdennacer-Badaoui marked this pull request as draft April 9, 2026 10:05
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Abdennacer-Badaoui Abdennacer-Badaoui marked this pull request as ready for review April 9, 2026 13:25
alvarobartt
alvarobartt previously approved these changes Jul 8, 2026

@alvarobartt alvarobartt left a comment

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.

Hey @Abdennacer-Badaoui, thanks a lot, left some comments / thoughts, feel free to apply or discard where applicable 🤗

if is_rocm():
try:
from kernels import get_kernel as _get_kernel
_triton_layer_norm = _get_kernel("kernels-community/triton-layer-norm")

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.

Can we specify the revision / version here?

if is_rocm():
try:
from kernels import get_kernel as _get_kernel
_triton_layer_norm = _get_kernel("kernels-community/triton-layer-norm")

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.

Same here with the revision / version

Comment thread docs/source/en/amd_gpu.md
-v $volume:/data \
--pull always \
ghcr.io/huggingface/text-embeddings-inference:rocm-latest \
--model-id $model --dtype bfloat16

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.

Since it just supports at most a single accelerator, could you instead specify the --device /dev/dri/renderD128 instead of --device /dev/dri or rather using the environment variable ROCR_VISIBLE_DEVICES (as per https://rocm.docs.amd.com/en/latest/conceptual/gpu-isolation.html#rocr-visible-devices)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes I agree. Let me change this

Comment thread docs/source/en/amd_gpu.md Outdated
Comment on lines +47 to +50
curl http://localhost:8080/embed \
-X POST \
-H 'Content-Type: application/json' \
-d '{"inputs": "What is Deep Learning?"}'

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.

Might be better to use the OpenAI-compatible API at /v1/embeddings instead

Comment thread Dockerfile-amd Outdated
Comment thread Dockerfile-amd Outdated
Comment thread Dockerfile-amd Outdated
Comment thread .github/workflows/matrix.json Outdated
"imageNamePrefix": "rocm-",
"runOn": "always",
"sccache": true,
"extraBuildArgs": "GPU_ARCHS=gfx942",

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.

Should we also build with GPU_ARCHS=gfx950, or does this image works for those too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, gfx950 already works, no separate build needed

Comment thread .github/workflows/matrix.json Outdated
"dockerfile": "Dockerfile-intel"
},
{
"name": "rocm-mi300-mi325",

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.

Maybe this fits better here?

Suggested change
"name": "rocm-mi300-mi325",
"name": "rocm-gfx942",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I went with rocm-gfx942-gfx950 rather than just rocm-gfx942, since the prebuilt flash-attn wheel (whl/gfx942-gfx950/...) covers both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants