Views
No views yet
meta-llama/Llama-3.1-8B-Instruct. The model has been loaded using torch_dtype = bfloat16 and wrapped at once, also during forward/backward passes bfloat16 has been used for computations.1from torch.distributed._composable.fsdp import fully_shard
2
3mesh_device_type = "cuda" if use_cuda else "cpu"
4mesh = DeviceMesh(mesh_device_type, list(range(world_size)))
5fsdp_kwargs = {
6 "mesh": mesh,
7 "reshard_after_forward": True,
8}
9model = fully_shard(model, **fsdp_kwargs)num_attention_heads)num_key_value_heads)num_hidden_layers)hidden_size)llama3, factor = 8.0meta-llama/Llama-3.1-8B-Instructseq_len)CUDA_VISIBLE_DEVICES=0,1,2,3)bf16 && fp8=false
warmup_ratio=0.1) | also warmup_steps=100eval_steps=5, eval_samples=1000)eval_losstorch.distributed.run (single node, multi-GPU)
torchrun for distributed training.| package | Version |
|---|---|
| Transformers | 4.57.1 |
| torch | 2.9.0+cu128 |
| accelerate | 0.14.1 |
| datasets | 4.3.0 |
| huggingface-hub | 0.36.0 |
| tensorboard | 2.20.0 |
| tensorboard-data-server | 0.7.2 |
| wandb | 0.22.1 |
| model | Job ID | Runtime (mins) | Nodes | GPUs | Node-hour | GPU-hour | micro-batch | batch-size | gradient_accumulation | total_batch_size |
|---|---|---|---|---|---|---|---|---|---|---|
| Llama-3.1-8B-Instruct_w16a8_rw | 31768103 | 115.75 | 1 | 4 | 1.929 | 7.716 | 2 | 2 | 4 | 32 |
| Llama-3.1-8B-Instruct_w16a8_rw_with_gw_hp | 31837629 | 109.00 | 1 | 4 | 1.816 | 7.266 | 2 | 2 | 4 | 32 |
| Llama-3.1-8B-Instruct-w16a8-mxtw | 31768031 | 64.00 | 1 | 4 | 1.066 | 4.266 | 2 | 2 | 4 | 32 |
| Llama-3.1-8B-Instruct-w16a16-tw | 31768074 | 138.75 | 1 | 4 | 2,312 | 9,25 | 2 | 2 | 4 | 32 |
| Llama-3.1-8B-Instruct-w16a8-1node-bs8 | 31768093 | 123.75 | 1 | 4 | 2.062 | 8,250 | 2 | 2 | 4 | 32 |
| Llama-3.1-8B-Instruct-w16a16-4nodes-bs32 | 31478433 | 31.75 | 4 | 4 | 2.117 | 8.467 | 4 | 4 | 8 | 512 |
| Llama-3.1-8B-Instruct-w16a8-4nodes-bs32 | 31478468 | 39.75 | 4 | 4 | 2.650 | 10.600 | 4 | 4 | 8 | 512 |
| Llama-3.1-8B-Instruct-w16a16-8nodes-bs32 | 31476914 | 22.00 | 8 | 4 | 2.933 | 11.733 | 4 | 4 | 8 | 1024 |
| Llama-3.1-8B-Instruct-w16a8-8nodes-bs32 | 31476844 | 23.50 | 8 | 4 | 3.133 | 12.533 | 4 | 4 | 8 | 1024 |
| Llama-3.1-8B-Instruct-w16a16-8nodes-bs64 | 31476914 | 22.00 | 8 | 4 | 2.933 | 11.733 | 4 | 8 | 8 | 1024 |
| Llama-3.1-8B-Instruct-w16a8-8nodes-bs64 | 31476844 | 23.50 | 8 | 4 | 3.133 | 12.533 | 4 | 8 | 8 | 1024 |
| Llama-3.1-8B-Instruct-w16a8-rw_4nodes | 33477070 | 39.75 | 4 | 4 | 2.650 | 10.600 | 4 | 4 | 8 | 512 |
| Llama-3.1-8B-Instruct-w16a8-rw-8nodes | 33476690 | 23.50 | 8 | 4 | 3.133 | 12.533 | 4 | 4 | 8 | 1024 |
| Llama-3.1-8B-Instruct-w16a8-rw_with_gw_hp_4nodes | 33477179 | 37.43 | 4 | 4 | 2.495 | 9.982 | 4 | 4 | 8 | 512 |
| Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-8nodes | 33476618 | 22.13 | 8 | 4 | 2.951 | 11.802 | 4 | 4 | 8 | 1024 |
| Model | Training Time (mins) | Memory Allocated (avg %) | GPU Utilization (avg %) | Speed vs bf16 |
|---|---|---|---|---|
| Llama-3.1-8B-Instruct_w16a16-tw | 138.75267 | 74.4189 | 56.6059% | _ |
| Llama-3.1-8B-Instruct-w16a8-1node-bs8 | 123.75267 | 68.8982 | 97.5364% | 12.11% |
| Llama-3.1-8B-Instruct_w16a8_rw | 115.75364 | 69.6132 | 97.7689% | 19.87% |
| Llama-3.1-8B-Instruct_w16a8_rw_with_gw_hp | 109.00364 | 69.4806 | 97.3312% | 27.33% |
| Llama-3.1-8B-Instruct-w16a8-mxtw | 64.00328 | 68.8982 | 95.5661% | 116.82% |
| perplexity metric results for bfp16 && bfp16-fp8 configurations | Accuracy metric results for bfp16 && bfp16-fp8 configurations | Loss metric results for bfp16 && bfp16-fp8 configurations | Memory allocation for bfp16 && bfp16-fp8 configurations | Utilization for bfp16 && bfp16-fp8 configurations |
|---|---|---|---|---|
![]() | ![]() | ![]() | ![]() | ![]() |
| Model | Max Loss (train) | Min Loss (train) | Avg Loss (train) | Final Loss (train) | ± Std (train) | Max Loss (val) | Min Loss (val) | Avg Loss (val) | Final Loss (val) | ± Std (val) |
|---|---|---|---|---|---|---|---|---|---|---|
| Llama-3.1-8B-Instruct-w16a8-rw | 8 | 3.1682 | 0.5740 | 0.8118 | 0.6431 | 0.2746 | 1.0613 | 0.8394 | 0.8937 | 0.8394 |
| Llama-3.1-8B-Instruct_w16a8_rw_with_gw_hp | 8 | 3.1837 | 0.5763 | 0.8116 | 0.6420 | 0.2751 | 1.0599 | 0.8391 | 0.8933 | 0.8391 |
| Llama-3.1-8B-Instruct-w16a8-mxtw | 8 | 3.1983 | 0.5747 | 0.8115 | 0.6446 | 0.2758 | 1.0562 | 0.8384 | 0.8923 | 0.8384 |
| Llama-3.1-8B-Instruct-w16a16-tw | 8 | 3.1235 | 0.7203 | 0.9750 | 0.3344 | 0.7612 | 1.9113 | 0.8907 | 0.9831 | 0.1897 |
| Llama-3.1-8B-Instruct-w16a8-1node-bs8 | 8 | 3.1661 | 0.7261 | 0.9804 | 0.3374 | 0.7672 | 1.9230 | 0.8948 | 0.9867 | 0.1906 |
| Llama-3.1-8B-Instruct-w16a16-4nodes-bs32 | 32 | 3.2452 | 0.7414 | 0.9665 | 0.4844 | 0.7504 | 1.0538 | 0.8382 | 0.8844 | 0.0725 |
| Llama-3.1-8B-Instruct-w16a8-4nodes-bs32 | 32 | 3.2840 | 0.7478 | 0.9748 | 0.4905 | 0.7581 | 1.0701 | 0.8430 | 0.8922 | 0.0764 |
| Llama-3.1-8B-Instruct-w16a16-8nodes-bs32 | 32 | 3.2311 | 0.8448 | 1.1856 | 0.6434 | 0.8448 | 1.0257 | 0.8977 | 0.9460 | 0.0568 |
| Llama-3.1-8B-Instruct-w16a8-8nodes-bs32 | 32 | 3.3003 | 0.8473 | 1.1866 | 0.6481 | 0.8473 | 1.0203 | 0.8992 | 0.9445 | 0.0539 |
| Llama-3.1-8B-Instruct-w16a16-4nodes-bs64 | 64 | 3.2311 | 0.8448 | 1.1856 | 0.6434 | 0.8448 | 1.0257 | 0.8977 | 0.9460 | 0.0568 |
| Llama-3.1-8B-Instruct-w16a8-8nodes-bs64 | 64 | 3.3003 | 0.8473 | 1.1866 | 0.6481 | 0.8473 | 1.0203 | 0.8992 | 0.9445 | 0.0539 |
| Llama-3.1-8B-Instruct-w16a8-rw_4nodes | 64 | 3.4517 | 0.7624 | 1.1173 | 0.7624 | 0.6891 | 1.3225 | 0.8791 | 0.9732 | 0.8791 |
| Llama-3.1-8B-Instruct-w16a8-rw-8nodes | 64 | 3.8944 | 0.9583 | 1.6423 | 0.9583 | 1.0117 | 1.5384 | 1.0253 | 1.2103 | 1.0253 |
| Llama-3.1-8B-Instruct-w16a8-rw_with_gw_hp_4nodes | 64 | 3.4517 | 0.7481 | 1.1091 | 0.7481 | 0.7021 | 1.3393 | 0.8660 | 0.9641 | 0.8666 |
| Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-8nodes | 64 | 3.9289 | 0.9702 | 1.6514 | 0.9702 | 1.0127 | 1.5537 | 1.0377 | 1.2222 | 1.0377 |
tensorboard --logdir="./Llama-3.1-8B-Instruct_w16a16" --port="6006" 
nsys stats --report cuda_gpu_kern_sum /path/to/lama3.1_fp16_baseline.nsys-repnsys stats --report cuda_gpu_trace /path/to/lama3.1_fp16_baseline.nsys-rep nsys stats --report cuda_gpu_mem_size_sum /path/to/lama3.1_fp16_baseline.nsys-rep1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model_name = "newmindai/Llama-3.1-8B-Instruct-w16a16-1node"
5dtype = torch.bfloat16
6
7tok = AutoTokenizer.from_pretrained(model_name)
8model = AutoModelForCausalLM.from_pretrained(
9 model_name,
10 torch_dtype=dtype,
11 device_map="auto"
12)
13
14prompt = "Soru: Kişisel Verilerin Korunması Kanunu uyarınca hangi durumlarda açık rıza aranmaz? Cevap:"
15
16inputs = tok(prompt, return_tensors="pt").to(model.device)
17with torch.no_grad():
18 out = model.generate(
19 **inputs,
20 max_new_tokens=256,
21 do_sample=False
22 )
23
24print(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}