The Llama-3.1-8B-Instruct-w16a8-rw model is a domain-adapted Turkish legal instruction-tuned variant of Meta’s Llama-3.1-8B-Instruct, trained using the Float8 Rowwise quantization recipe. This model was developed within the “FSDP2 with Float8 Precision for Faster Training” project to evaluate how fine-grained FP8 scaling affects both training efficiency and downstream legal reasoning performance.
During training, model weights were kept in BF16, while the inputs, weights, and gradient outputs were dynamically quantized to FP8-E4M3 using TorchAO’s rowwise configuration, where each row receives its own scaling factor. This finer granularity enabled higher GPU utilization and reduced training time, achieving ~19.87% speedup over the BF16 baseline on H100 GPUs while maintaining stable convergence.
The model was trained on the newmindai/EuroHPC-Legal dataset (multi-domain Q/A format) to improve reasoning quality across various subfields of Turkish law.
This model was trained with the finer grained resolution for Float8 Rowwise recipe. The recipe sets scaling_granularity to AXISWISE for each of input, weight and gradient output cast configurations and ScalingType to DYNAMIC where each row of a weight matrix gets its own scaling factor, instead of one scaling factor for the entire tensor. and the dtype to float8_e4m3, basically it points that the bites be distributed with 4 exponents and 3 mantissas and the first bit is signal bit.
1from torchao.float8 import (
2 convert_to_float8_training,
3 Float8LinearConfig)
4config = Float8LinearConfig.from_recipe_name("rowwise")
5model = convert_to_float8_training(model, config=config)
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3model_name = "newmindai/Llama-3.1-8B-Instruct-w16a8-rw-8nodes"
4dtype = torch.bfloat16
5tok = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForCausalLM.from_pretrained(
7 model_name,
8 torch_dtype=dtype,
9 device_map="auto"
10)
11prompt = "Soru: Kişisel Verilerin Korunması Kanunu uyarınca hangi durumlarda açık rıza aranmaz? Cevap:"
12inputs = tok(prompt, return_tensors="pt").to(model.device)
13with torch.no_grad():
14 out = model.generate(
15 **inputs,
16 max_new_tokens=256,
17 do_sample=False
18 )
19
20print(tok.decode(out[0], skip_special_tokens=True))
1@misc{meta_llama31_8b_instruct,
2 title={Llama 3.1 8B Instruct},
3 author={Meta AI},
4 year={2024},
5 howpublished={\url{https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct}}
6}
1@misc{euro_hpc_legal,
2 title={EuroHPC-Legal},
3 author={newmindai},
4 year={2025},
5 howpublished={\url{https://huggingface.co/datasets/newmindai/EuroHPC-Legal}}
6}