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
| from unsloth import FastLanguageModel | |
| import torch | |
| from torchao.quantization import Int4WeightOnlyConfig | |
| from transformers import AutoModelForCausalLM, TextStreamer, TorchAoConfig | |
| qat_scheme = "int4" | |
| save_output_path = "/tmp/unsloth_model" | |
| max_seq_length = 2048 |
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
| class _UnslothGRPOTrainer(Trainer): | |
| ... | |
| def _sync_fsdp1_params_to_vllm(self, module: nn.Module, prefix: str = "", visited=None): | |
| """Memory-efficient post-order traversal of FSDP modules to extract full parameters and sync with vLLM.""" | |
| # For FSDP1, we need to recurse into children and also use summon_full_params | |
| if visited is None: | |
| visited = set() | |
| for child_name, child_module in module.named_children(): | |
| child_prefix = f"{prefix}.{child_name}" if prefix else child_name |
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
| [rank0]: Traceback (most recent call last): | |
| [rank0]: File "/home/andrewor/local/unsloth-zoo/unsloth_zoo/vllm_utils.py", line 884, in get_state_dict | |
| [rank0]: weight = qweight[dim_offsets[kk] : dim_offsets[kk + 1]] | |
| [rank0]: File "/home/andrewor/local/ao/torchao/utils.py", line 662, in _dispatch__torch_function__ | |
| [rank0]: raise e | |
| [rank0]: File "/home/andrewor/local/ao/torchao/utils.py", line 659, in _dispatch__torch_function__ | |
| [rank0]: return func(*args, **kwargs) | |
| [rank0]: RuntimeError: Cannot set version_counter for inference tensor | |
| [rank0]: Exception raised from set_version_counter at /pytorch/c10/core/TensorImpl.h:2117 (most recent call first): | |
| [rank0]: C++ CapturedTraceback: |
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
| # Modeled after https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_(4B)-GRPO.ipynb | |
| from unsloth import FastLanguageModel | |
| import gc | |
| import os | |
| import re | |
| from datasets import load_dataset, Dataset | |
| from trl import GRPOConfig, GRPOTrainer, SFTConfig, SFTTrainer |
OlderNewer