lukeleeai commited on
Commit
c96b15c
·
verified ·
1 Parent(s): 5d16046

Training in progress, step 250

Browse files
Files changed (5) hide show
  1. README.md +10 -64
  2. config.json +7 -8
  3. model.safetensors +3 -0
  4. sparsification_sftt.py +12 -5
  5. training_args.bin +2 -2
README.md CHANGED
@@ -1,21 +1,19 @@
1
  ---
2
- license: apache-2.0
3
- base_model: mistralai/Mistral-7B-v0.1
4
  tags:
5
  - generated_from_trainer
6
  model-index:
7
- - name: Mistral_Sparse_refined_web_50p_graceful_True
8
  results: []
9
  ---
10
 
11
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
12
  should probably proofread and complete it, then remove this comment. -->
13
 
14
- # Mistral_Sparse_refined_web_50p_graceful_True
15
 
16
- This model is a fine-tuned version of [mistralai/Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) on the None dataset.
17
  It achieves the following results on the evaluation set:
18
- - Loss: 2.3402
19
 
20
  ## Model description
21
 
@@ -35,72 +33,20 @@ More information needed
35
 
36
  The following hyperparameters were used during training:
37
  - learning_rate: 1e-05
38
- - train_batch_size: 1
39
- - eval_batch_size: 1
40
  - seed: 0
41
  - distributed_type: multi-GPU
42
- - num_devices: 4
43
  - gradient_accumulation_steps: 4
44
- - total_train_batch_size: 16
45
- - total_eval_batch_size: 4
46
  - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
47
  - lr_scheduler_type: linear
48
- - training_steps: 2500
49
 
50
  ### Training results
51
 
52
- | Training Loss | Epoch | Step | Validation Loss |
53
- |:-------------:|:-----:|:----:|:---------------:|
54
- | 3.7252 | 0.01 | 50 | 2.3893 |
55
- | 2.2531 | 0.02 | 100 | 2.4723 |
56
- | 2.32 | 0.02 | 150 | 2.4385 |
57
- | 2.2363 | 0.03 | 200 | 2.4210 |
58
- | 2.3078 | 0.04 | 250 | 2.4118 |
59
- | 2.2389 | 0.05 | 300 | 2.4025 |
60
- | 2.0902 | 0.06 | 350 | 2.3984 |
61
- | 2.2878 | 0.06 | 400 | 2.3965 |
62
- | 2.2485 | 0.07 | 450 | 2.3924 |
63
- | 2.2375 | 0.08 | 500 | 2.3895 |
64
- | 2.1901 | 0.09 | 550 | 2.3909 |
65
- | 2.1128 | 0.1 | 600 | 2.3886 |
66
- | 2.2983 | 0.1 | 650 | 2.3892 |
67
- | 2.2547 | 0.11 | 700 | 2.3873 |
68
- | 2.1322 | 0.12 | 750 | 2.3861 |
69
- | 2.2715 | 0.13 | 800 | 2.3827 |
70
- | 2.263 | 0.14 | 850 | 2.3845 |
71
- | 2.2066 | 0.14 | 900 | 2.3836 |
72
- | 2.2781 | 0.15 | 950 | 2.3837 |
73
- | 2.2597 | 0.16 | 1000 | 2.3778 |
74
- | 2.2642 | 0.17 | 1050 | 2.3764 |
75
- | 2.2296 | 0.18 | 1100 | 2.3805 |
76
- | 2.2289 | 0.18 | 1150 | 2.3784 |
77
- | 2.1372 | 0.19 | 1200 | 2.3773 |
78
- | 2.2059 | 0.2 | 1250 | 2.3732 |
79
- | 2.2847 | 0.21 | 1300 | 2.3719 |
80
- | 2.1404 | 0.22 | 1350 | 2.3739 |
81
- | 2.2261 | 0.22 | 1400 | 2.3752 |
82
- | 2.1713 | 0.23 | 1450 | 2.3750 |
83
- | 2.1787 | 0.24 | 1500 | 2.3732 |
84
- | 2.1866 | 0.25 | 1550 | 2.3759 |
85
- | 2.2471 | 0.26 | 1600 | 2.3760 |
86
- | 2.307 | 0.26 | 1650 | 2.3745 |
87
- | 2.2457 | 0.27 | 1700 | 2.3746 |
88
- | 2.2265 | 0.28 | 1750 | 2.3775 |
89
- | 2.163 | 0.29 | 1800 | 2.3797 |
90
- | 2.2411 | 0.3 | 1850 | 2.3760 |
91
- | 2.247 | 0.3 | 1900 | 2.3770 |
92
- | 2.2449 | 0.31 | 1950 | 2.3749 |
93
- | 2.1884 | 0.32 | 2000 | 2.3728 |
94
- | 2.1909 | 0.33 | 2050 | 2.3770 |
95
- | 2.2813 | 0.34 | 2100 | 2.3773 |
96
- | 2.2306 | 0.34 | 2150 | 2.3755 |
97
- | 2.2158 | 0.35 | 2200 | 2.3777 |
98
- | 2.1557 | 0.36 | 2250 | 2.3783 |
99
- | 2.2715 | 0.37 | 2300 | 2.3704 |
100
- | 2.2053 | 0.38 | 2350 | 2.3729 |
101
- | 2.2541 | 0.38 | 2400 | 2.3715 |
102
- | 2.0971 | 0.39 | 2450 | 2.3747 |
103
- | 2.2791 | 0.4 | 2500 | 2.3727 |
104
 
105
 
106
  ### Framework versions
 
1
  ---
 
 
2
  tags:
3
  - generated_from_trainer
4
  model-index:
5
+ - name: Mistral_Sparse_refined_web_50p_graceful_False
6
  results: []
7
  ---
8
 
9
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
10
  should probably proofread and complete it, then remove this comment. -->
11
 
12
+ # Mistral_Sparse_refined_web_50p_graceful_False
13
 
14
+ This model is a fine-tuned version of [](https://huggingface.co/) on the None dataset.
15
  It achieves the following results on the evaluation set:
16
+ - Loss: 10.3740
17
 
18
  ## Model description
19
 
 
33
 
34
  The following hyperparameters were used during training:
35
  - learning_rate: 1e-05
36
+ - train_batch_size: 8
37
+ - eval_batch_size: 16
38
  - seed: 0
39
  - distributed_type: multi-GPU
40
+ - num_devices: 2
41
  - gradient_accumulation_steps: 4
42
+ - total_train_batch_size: 64
43
+ - total_eval_batch_size: 32
44
  - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
45
  - lr_scheduler_type: linear
46
+ - training_steps: 200
47
 
48
  ### Training results
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
 
52
  ### Framework versions
config.json CHANGED
@@ -1,5 +1,4 @@
1
  {
2
- "_name_or_path": "mistralai/Mistral-7B-v0.1",
3
  "architectures": [
4
  "SparseMistralforCausalLM"
5
  ],
@@ -11,23 +10,23 @@
11
  "bos_token_id": 1,
12
  "eos_token_id": 2,
13
  "hidden_act": "silu",
14
- "hidden_size": 4096,
15
  "initializer_range": 0.02,
16
- "intermediate_size": 14336,
17
- "max_position_embeddings": 32768,
18
  "model_type": "sparse_mistral",
19
  "num_attention_heads": 32,
20
- "num_hidden_layers": 32,
21
  "num_key_value_heads": 8,
22
- "rms_norm_eps": 1e-05,
23
  "rope_theta": 10000.0,
24
  "sliding_window": 4096,
25
  "thresholds": null,
26
  "tie_word_embeddings": false,
27
- "torch_dtype": "bfloat16",
28
  "transformers_version": "4.37.2",
29
  "us_sparse_regularization": true,
30
- "use_cache": false,
31
  "use_sparse_model": true,
32
  "use_sparse_predictor": false,
33
  "use_sparse_regularization": false,
 
1
  {
 
2
  "architectures": [
3
  "SparseMistralforCausalLM"
4
  ],
 
10
  "bos_token_id": 1,
11
  "eos_token_id": 2,
12
  "hidden_act": "silu",
13
+ "hidden_size": 64,
14
  "initializer_range": 0.02,
15
+ "intermediate_size": 64,
16
+ "max_position_embeddings": 131072,
17
  "model_type": "sparse_mistral",
18
  "num_attention_heads": 32,
19
+ "num_hidden_layers": 2,
20
  "num_key_value_heads": 8,
21
+ "rms_norm_eps": 1e-06,
22
  "rope_theta": 10000.0,
23
  "sliding_window": 4096,
24
  "thresholds": null,
25
  "tie_word_embeddings": false,
26
+ "torch_dtype": "float32",
27
  "transformers_version": "4.37.2",
28
  "us_sparse_regularization": true,
29
+ "use_cache": true,
30
  "use_sparse_model": true,
31
  "use_sparse_predictor": false,
32
  "use_sparse_regularization": false,
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:58951f5db2bd738f8fb0a4e130aeca9b378176ee3d6b24bdfa9979b546866a9c
3
+ size 16567728
sparsification_sftt.py CHANGED
@@ -4,7 +4,6 @@ from peft import PeftModel
4
  from datasets import Dataset
5
  from typing import Any, Dict, Union, Optional, Tuple
6
  from torch.nn import MSELoss
7
-
8
  import warnings
9
  import torch
10
  import torch.nn as nn
@@ -14,6 +13,9 @@ import time
14
  import os
15
  import copy
16
 
 
 
 
17
  from transformers.models.mistral.modeling_mistral import (
18
  MistralMLP,
19
  MistralModel,
@@ -516,6 +518,7 @@ class GracefulRegularizationScheduler(TrainerCallback):
516
  test_dataset: Dataset = None,
517
  targeted_sparsity: float = 0.5,
518
  keep_regularization_with_kill: bool = False,
 
519
  ):
520
  """Scheduler for regularizing the model first before applying the dead threshold.
521
 
@@ -533,6 +536,7 @@ class GracefulRegularizationScheduler(TrainerCallback):
533
  if self.is_enabled:
534
  print("GracefulRegularizationScheduler is enabled.")
535
  self.trainer = None
 
536
 
537
  def set_trainer(self, trainer):
538
  self.trainer = trainer
@@ -563,14 +567,17 @@ class GracefulRegularizationScheduler(TrainerCallback):
563
  # set_layer_specific_regularization(model.get_base_model())
564
  print_dead_neuron_stats(model.get_base_model())
565
 
566
- if state.global_step % 2000 == 0:
567
  if is_mainprocess():
 
568
  ds_print(
569
- f"Saving to /scr/lukeai/{self.model_name}_{state.global_step}.pt",
570
  )
 
 
571
  torch.save(
572
  model.state_dict(),
573
- f"/scr/lukeai/{self.model_name}_{state.global_step}.pt",
574
  )
575
 
576
 
@@ -727,7 +734,7 @@ def print_dead_neuron_stats(model):
727
  if isinstance(layer.mlp, MistralSparseSiluMLP):
728
  dead_percentage = layer.mlp.dead_percentage * 100
729
  agg_sparsity = layer.mlp.agg_sparsity * 100
730
- ds_print(f"layer {i} threshold: {layer.mlp.dead_threshold:.3f}%")
731
  ds_print(f"layer {i} sparsity: {dead_percentage:.3f}%")
732
  ds_print(f"layer {i} agg sparsity: {agg_sparsity:.3f}%")
733
  total_sparsity += dead_percentage
 
4
  from datasets import Dataset
5
  from typing import Any, Dict, Union, Optional, Tuple
6
  from torch.nn import MSELoss
 
7
  import warnings
8
  import torch
9
  import torch.nn as nn
 
13
  import os
14
  import copy
15
 
16
+ # from deepspeed.utils import save_state_dict
17
+
18
+
19
  from transformers.models.mistral.modeling_mistral import (
20
  MistralMLP,
21
  MistralModel,
 
518
  test_dataset: Dataset = None,
519
  targeted_sparsity: float = 0.5,
520
  keep_regularization_with_kill: bool = False,
521
+ start_steps: int = 0,
522
  ):
523
  """Scheduler for regularizing the model first before applying the dead threshold.
524
 
 
536
  if self.is_enabled:
537
  print("GracefulRegularizationScheduler is enabled.")
538
  self.trainer = None
539
+ self.start_steps = start_steps
540
 
541
  def set_trainer(self, trainer):
542
  self.trainer = trainer
 
567
  # set_layer_specific_regularization(model.get_base_model())
568
  print_dead_neuron_stats(model.get_base_model())
569
 
570
+ if state.global_step % 10 == 0:
571
  if is_mainprocess():
572
+ current_steps = self.start_steps + state.global_step
573
  ds_print(
574
+ f"Saving to /scr/lukeai/{self.model_name}_{current_steps}.pt",
575
  )
576
+ # save_state_dict(model, f"/scr/lukeai/{self.model_name}_{state.global_step}.pt")
577
+ print("Saving a model...")
578
  torch.save(
579
  model.state_dict(),
580
+ f"/scr/lukeai/{self.model_name}_{current_steps}.pt",
581
  )
582
 
583
 
 
734
  if isinstance(layer.mlp, MistralSparseSiluMLP):
735
  dead_percentage = layer.mlp.dead_percentage * 100
736
  agg_sparsity = layer.mlp.agg_sparsity * 100
737
+ ds_print(f"layer {i} threshold: {layer.mlp.dead_threshold:.3f}")
738
  ds_print(f"layer {i} sparsity: {dead_percentage:.3f}%")
739
  ds_print(f"layer {i} agg sparsity: {agg_sparsity:.3f}%")
740
  total_sparsity += dead_percentage
training_args.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:cbe7af3ff5bd4495c979a876ffd09e2ba96df0dad9a03fb0cf367d0f5cf1da79
3
- size 6520
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4ab002fb28887f771d81428c91f67235593bf02bce49639941825db88db1c965
3
+ size 4728