-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Gemma4 fixes and profiler #3591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,30 @@ Watch for: loss never decreasing (check `train_on_inputs`, dataset, LR), loss go | |
| | FSDP save hangs | Use `fsdp_state_dict_type: FULL_STATE_DICT` | | ||
| | DeepSpeed CheckpointError | Set `use_reentrant: true` in `gradient_checkpointing_kwargs` | | ||
|
|
||
| ## Profiling | ||
|
|
||
| To profile training and identify optimization opportunities: | ||
|
|
||
| ```yaml | ||
| # Profile steps 3-7 (after warmup/autotuning settles) | ||
| profiler_steps_start: 3 | ||
| profiler_steps: 5 | ||
| ``` | ||
|
|
||
| This produces `profiler_trace.json` (Chrome trace) and `snapshot.pickle` (memory snapshot) in `output_dir`. | ||
| View the Chrome trace at `chrome://tracing`. | ||
|
|
||
| To programmatically inspect the trace: | ||
| ```bash | ||
| python scripts/analyze_profile.py output_dir/ | ||
| ``` | ||
|
Comment on lines
+104
to
+110
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Point the example at the run directory if you want memory analysis too. Passing 🤖 Prompt for AI Agents |
||
|
|
||
| The trace shows per-kernel CUDA times, memory allocations, and operator-level breakdown. Look for: | ||
| - **Large matmul kernels**: candidates for fusion or quantization | ||
| - **Memory copies (H2D/D2H)**: unnecessary data movement | ||
| - **Small frequent kernels**: candidates for kernel fusion | ||
| - **Gaps between kernels**: pipeline bubbles from CPU overhead | ||
|
|
||
| Full troubleshooting: [training_stability.qmd](../training_stability.qmd), [debugging.qmd](../debugging.qmd) | ||
|
|
||
| ## File Map | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Gemma 4 E2B Vision LoRA | ||
| # | ||
| # Fine-tuning LM LoRA adapters on multimodal Gemma4 with vision/multimodal modules frozen. | ||
| # Uses the base ProcessingStrategy (auto-detects image_token from processor). | ||
|
|
||
| base_model: google/gemma-4-E2B-it | ||
| processor_type: AutoProcessor | ||
| freeze_mm_modules: true | ||
|
|
||
| plugins: | ||
| - axolotl.integrations.cut_cross_entropy.CutCrossEntropyPlugin | ||
| strict: false | ||
|
|
||
| # Required for vision/multimodal training | ||
| skip_prepare_dataset: true | ||
| remove_unused_columns: false | ||
| sample_packing: false | ||
|
|
||
| chat_template: gemma4 | ||
| datasets: | ||
| - path: HuggingFaceH4/llava-instruct-mix-vsft | ||
| type: chat_template | ||
| split: train[:100] | ||
|
|
||
| val_set_size: 0 | ||
| output_dir: ./outputs/gemma4-e2b-vision-lora | ||
|
|
||
| adapter: lora | ||
| sequence_len: 2048 | ||
| pad_to_sequence_len: false | ||
|
|
||
| lora_r: 16 | ||
| lora_alpha: 32 | ||
| lora_dropout: 0 | ||
| # Target language model only — vision encoder is frozen via freeze_mm_modules | ||
| lora_target_modules: 'model.language_model.layers.[\d]+.(_checkpoint_wrapped_module.)?(mlp|self_attn).(up|down|gate|q|k|v|o)_proj' | ||
|
|
||
| gradient_accumulation_steps: 4 | ||
| micro_batch_size: 1 | ||
| num_epochs: 1 | ||
| max_steps: 10 | ||
| optimizer: adamw_torch_8bit | ||
| lr_scheduler: cosine | ||
| learning_rate: 0.0002 | ||
|
|
||
| bf16: auto | ||
| tf32: true | ||
|
|
||
| gradient_checkpointing: true | ||
| gradient_checkpointing_kwargs: | ||
| use_reentrant: false | ||
| logging_steps: 1 | ||
| sdp_attention: true | ||
|
|
||
| warmup_ratio: 0.1 | ||
| weight_decay: 0.0 | ||
|
|
||
| wandb_project: | ||
| wandb_entity: | ||
| wandb_watch: | ||
| wandb_name: | ||
| wandb_log_model: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Qwen 3.5 35B-A3B MoE Vision LoRA | ||
| # | ||
| # Vision fine-tuning of the hybrid DeltaNet + Attention MoE model. | ||
| # 256 experts, 8 active per token, with early-fusion vision support. | ||
|
|
||
| base_model: Qwen/Qwen3.5-35B-A3B | ||
| processor_type: AutoProcessor | ||
|
|
||
| # Required for vision/multimodal training | ||
| skip_prepare_dataset: true | ||
| remove_unused_columns: false | ||
| sample_packing: false | ||
|
|
||
| chat_template: qwen3_5 | ||
| datasets: | ||
| - path: HuggingFaceH4/llava-instruct-mix-vsft | ||
| type: chat_template | ||
| split: train[:100] | ||
|
|
||
| val_set_size: 0 | ||
| output_dir: ./outputs/qwen35-35b-a3b-vision-lora | ||
|
|
||
| adapter: lora | ||
| sequence_len: 4096 | ||
| pad_to_sequence_len: false | ||
|
|
||
| lora_r: 16 | ||
| lora_alpha: 32 | ||
| lora_dropout: 0 | ||
| lora_target_modules: | ||
| - q_proj | ||
| - k_proj | ||
| - v_proj | ||
| - o_proj | ||
| - down_proj | ||
| - up_proj | ||
|
|
||
| gradient_accumulation_steps: 4 | ||
| micro_batch_size: 1 | ||
| num_epochs: 1 | ||
| max_steps: 10 | ||
| optimizer: adamw_torch_8bit | ||
| lr_scheduler: cosine | ||
| learning_rate: 0.0002 | ||
|
|
||
| bf16: auto | ||
| tf32: true | ||
|
|
||
| gradient_checkpointing: true | ||
| gradient_checkpointing_kwargs: | ||
| use_reentrant: false | ||
| logging_steps: 1 | ||
| flash_attention: true | ||
|
|
||
| warmup_ratio: 0.1 | ||
| weight_decay: 0.0 | ||
|
|
||
| wandb_project: | ||
| wandb_entity: | ||
| wandb_watch: | ||
| wandb_name: | ||
| wandb_log_model: |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the recommended Python version consistent with the quick-start requirements.
The prerequisites still say Python 3.11, but the new recommended path provisions 3.12 and hardcodes
uv run --python 3.12. Please clarify whether 3.12 is required or just preferred so readers don't set up the wrong interpreter.🤖 Prompt for AI Agents