Compare commits
12 Commits
kernelize-
...
feat/glm45
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be1f8db913 | ||
|
|
a526647b31 | ||
|
|
8069177284 | ||
|
|
a28eb600e9 | ||
|
|
4b16f363bc | ||
|
|
272a456ec0 | ||
|
|
7e83268662 | ||
|
|
b2a8c37a27 | ||
|
|
603166d9c5 | ||
|
|
e8c9517ac8 | ||
|
|
0bbad9202c | ||
|
|
cb042e9775 |
48
examples/glm45/README.md
Normal file
48
examples/glm45/README.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Finetune GLM4.5 with Axolotl
|
||||||
|
|
||||||
|
[UNSTABLE]
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# LoRA SFT (4xH200 @ 84GB/GPU)
|
||||||
|
axolotl train examples/glm45/glm4.5-lora-fsdp2.yaml
|
||||||
|
|
||||||
|
# FFT SFT (4xH200)
|
||||||
|
# Checkpointing error on backward pass
|
||||||
|
# Without checkpointing => OOM
|
||||||
|
axolotl train examples/glm45/glm4.5-fft-fsdp2.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dataset
|
||||||
|
|
||||||
|
In addition to normal OpenAI Messages format, GLM4.5 support an extra parameter for thinking in assistant section.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"role": "assistant",
|
||||||
|
"reasoning_content": "...", // or have </think>...</think> in `content`
|
||||||
|
"content": "...",
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Note:
|
||||||
|
- The role name for tools in this template is `tool`.
|
||||||
|
- You will see this Axolotl WARNING. This is to be as expected as the template does not use EOS.
|
||||||
|
```bash
|
||||||
|
EOS token '<|endoftext|>' not found in chat_template. Please check if your template/EOS token is correct.
|
||||||
|
```
|
||||||
|
- Make sure you set the below extra attributes if needed
|
||||||
|
```yaml
|
||||||
|
datasets:
|
||||||
|
- path: ...
|
||||||
|
type: chat_template
|
||||||
|
message_property_mappings:
|
||||||
|
role: role
|
||||||
|
content: content
|
||||||
|
|
||||||
|
# tool_calls: tool_calls # uncomment if using tools
|
||||||
|
# reasoning_content: reasoning_content # uncomment if have reasoning
|
||||||
|
|
||||||
|
# Uncomment if training on tool role (you would rarely if ever need this)
|
||||||
|
# eot_tokens:
|
||||||
|
# - <|observation|>
|
||||||
|
```
|
||||||
59
examples/glm45/glm4.5-fft-fsdp2.yaml
Normal file
59
examples/glm45/glm4.5-fft-fsdp2.yaml
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
base_model: zai-org/GLM-4.5-Air
|
||||||
|
# Automatically upload checkpoint and final model to HF
|
||||||
|
# hub_model_id: username/custom_model_name
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
- axolotl.integrations.cut_cross_entropy.CutCrossEntropyPlugin
|
||||||
|
|
||||||
|
experimental_skip_move_to_device: true # prevent OOM by NOT putting model to GPU before sharding
|
||||||
|
|
||||||
|
datasets:
|
||||||
|
- path: winglian/pirate-ultrachat-10k
|
||||||
|
type: chat_template
|
||||||
|
dataset_prepared_path: last_run_prepared
|
||||||
|
val_set_size: 0
|
||||||
|
output_dir: ./outputs/qlora-out
|
||||||
|
|
||||||
|
sequence_len: 2048
|
||||||
|
sample_packing: true
|
||||||
|
eval_sample_packing: true
|
||||||
|
|
||||||
|
wandb_project:
|
||||||
|
wandb_entity:
|
||||||
|
wandb_watch:
|
||||||
|
wandb_name:
|
||||||
|
wandb_log_model:
|
||||||
|
|
||||||
|
gradient_accumulation_steps: 1
|
||||||
|
micro_batch_size: 1
|
||||||
|
num_epochs: 1
|
||||||
|
optimizer: adamw_torch_4bit
|
||||||
|
lr_scheduler: cosine
|
||||||
|
learning_rate: 0.0002
|
||||||
|
|
||||||
|
bf16: auto
|
||||||
|
tf32: false
|
||||||
|
|
||||||
|
# gradient_checkpointing: true
|
||||||
|
resume_from_checkpoint:
|
||||||
|
logging_steps: 1
|
||||||
|
flash_attention: true
|
||||||
|
|
||||||
|
loss_watchdog_threshold: 5.0
|
||||||
|
loss_watchdog_patience: 3
|
||||||
|
|
||||||
|
warmup_ratio: 0.1
|
||||||
|
evals_per_epoch: 1
|
||||||
|
saves_per_epoch: 1
|
||||||
|
weight_decay: 0.0
|
||||||
|
special_tokens:
|
||||||
|
|
||||||
|
fsdp_version: 2
|
||||||
|
fsdp_config:
|
||||||
|
offload_params: false
|
||||||
|
cpu_ram_efficient_loading: true
|
||||||
|
auto_wrap_policy: TRANSFORMER_BASED_WRAP
|
||||||
|
transformer_layer_cls_to_wrap: Glm4MoeDecoderLayer
|
||||||
|
state_dict_type: SHARDED_STATE_DICT
|
||||||
|
reshard_after_forward: true
|
||||||
|
activation_checkpointing: true
|
||||||
74
examples/glm45/glm4.5-lora-fsdp2.yaml
Normal file
74
examples/glm45/glm4.5-lora-fsdp2.yaml
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
base_model: zai-org/GLM-4.5-Air
|
||||||
|
# Automatically upload checkpoint and final model to HF
|
||||||
|
# hub_model_id: username/custom_model_name
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
- axolotl.integrations.cut_cross_entropy.CutCrossEntropyPlugin
|
||||||
|
|
||||||
|
experimental_skip_move_to_device: true # prevent OOM by NOT putting model to GPU before sharding
|
||||||
|
|
||||||
|
datasets:
|
||||||
|
- path: winglian/pirate-ultrachat-10k
|
||||||
|
type: chat_template
|
||||||
|
dataset_prepared_path: last_run_prepared
|
||||||
|
val_set_size: 0
|
||||||
|
output_dir: ./outputs/qlora-out
|
||||||
|
|
||||||
|
adapter: lora
|
||||||
|
lora_model_dir:
|
||||||
|
|
||||||
|
lora_r: 16
|
||||||
|
lora_alpha: 32
|
||||||
|
lora_dropout: 0.05
|
||||||
|
lora_target_modules:
|
||||||
|
- gate_proj
|
||||||
|
- down_proj
|
||||||
|
- up_proj
|
||||||
|
- q_proj
|
||||||
|
- v_proj
|
||||||
|
- k_proj
|
||||||
|
- o_proj
|
||||||
|
|
||||||
|
sequence_len: 2048
|
||||||
|
sample_packing: true
|
||||||
|
eval_sample_packing: true
|
||||||
|
|
||||||
|
wandb_project:
|
||||||
|
wandb_entity:
|
||||||
|
wandb_watch:
|
||||||
|
wandb_name:
|
||||||
|
wandb_log_model:
|
||||||
|
|
||||||
|
gradient_accumulation_steps: 1
|
||||||
|
micro_batch_size: 1
|
||||||
|
num_epochs: 1
|
||||||
|
optimizer: adamw_torch_4bit
|
||||||
|
lr_scheduler: cosine
|
||||||
|
learning_rate: 0.0002
|
||||||
|
|
||||||
|
bf16: auto
|
||||||
|
tf32: false
|
||||||
|
|
||||||
|
# gradient_checkpointing: true
|
||||||
|
resume_from_checkpoint:
|
||||||
|
logging_steps: 1
|
||||||
|
flash_attention: true
|
||||||
|
|
||||||
|
loss_watchdog_threshold: 5.0
|
||||||
|
loss_watchdog_patience: 3
|
||||||
|
|
||||||
|
warmup_ratio: 0.1
|
||||||
|
evals_per_epoch: 1
|
||||||
|
saves_per_epoch: 1
|
||||||
|
weight_decay: 0.0
|
||||||
|
special_tokens:
|
||||||
|
|
||||||
|
fsdp_version: 2
|
||||||
|
fsdp_config:
|
||||||
|
offload_params: false
|
||||||
|
cpu_ram_efficient_loading: true
|
||||||
|
auto_wrap_policy: TRANSFORMER_BASED_WRAP
|
||||||
|
transformer_layer_cls_to_wrap: Glm4MoeDecoderLayer
|
||||||
|
state_dict_type: SHARDED_STATE_DICT
|
||||||
|
reshard_after_forward: true
|
||||||
|
# activation_checkpointing: false
|
||||||
@@ -14,6 +14,7 @@ MOE_ARCH_BLOCK = {
|
|||||||
"qwen3_moe": "Qwen3MoeSparseMoeBlock",
|
"qwen3_moe": "Qwen3MoeSparseMoeBlock",
|
||||||
"qwen3_vl_moe": "Qwen3VLMoeTextSparseMoeBlock",
|
"qwen3_vl_moe": "Qwen3VLMoeTextSparseMoeBlock",
|
||||||
"deepseek_v2": "DeepseekV2MoE",
|
"deepseek_v2": "DeepseekV2MoE",
|
||||||
|
"glm4_moe": "Glm4MoeMoE",
|
||||||
"deepseek_v3": "DeepseekV3MoE",
|
"deepseek_v3": "DeepseekV3MoE",
|
||||||
"gpt_oss": "GptOssDecoderLayer",
|
"gpt_oss": "GptOssDecoderLayer",
|
||||||
"lfm2_moe": "Lfm2MoeSparseMoeBlock",
|
"lfm2_moe": "Lfm2MoeSparseMoeBlock",
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ plugins:
|
|||||||
- gemma3n_text
|
- gemma3n_text
|
||||||
- glm
|
- glm
|
||||||
- glm4
|
- glm4
|
||||||
|
- glm_moe
|
||||||
- glm4_moe
|
- glm4_moe
|
||||||
- glm4v
|
- glm4v
|
||||||
- glm4v_moe
|
- glm4v_moe
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ SUPPORTED_MULTIPACK_MODEL_TYPES = [
|
|||||||
"deepseek_v3",
|
"deepseek_v3",
|
||||||
"glm",
|
"glm",
|
||||||
"glm4",
|
"glm4",
|
||||||
|
"glm4_moe",
|
||||||
"smollm3",
|
"smollm3",
|
||||||
"granite",
|
"granite",
|
||||||
"granitemoe",
|
"granitemoe",
|
||||||
|
|||||||
Reference in New Issue
Block a user