Run this model with HF Jobs

Run google/gemma-4-31B-it on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/google/gemma-4-31B-it. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/google/gemma-4-31B-it on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/google/gemma-4-31B-it. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/google/gemma-4-31B-it. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

RuntimeError: FlashAttention forward only supports head dimension at most 256

#30
by badhon1512 - opened

Getting this error when using Gemma 4 32B with flash_attention_2:

RuntimeError: FlashAttention forward only supports head dimension at most 256

Seems like the model has head_dim > 256. Switching to attn_implementation="sdpa" works.

Is FlashAttention not supported for this model?

Sounds like it isnt to me

I went through the torture of trying to get FA to work, so that you don’t have to:

FA4 (SM100/Blackwell-native): max head_dim 128. Dead on arrival for Gemma 4.

FA3 (Hopper-native): max head_dim 256. Covers sliding layers, not global (512). May underperform on B200 since it targets SM90.

FA2: max head_dim 256. Same story, sliding only.

SDPA (cuDNN backend): handles both 256 and 512. Works everywhere.

it is this line: self.head_dim = config.global_head_dim if not self.is_sliding and config.global_head_dim else config.head_dim
global_head_dim is 512.

@zhangtemplar Did you manage to bypass the error?

is the error solved?

Sign up or log in to comment