Spaces:
Sleeping
Sleeping
Update training.py
Browse files1234567870 unmodified lines79808182838485250 unmodified lines336337338339340341342# training.py – Memory‑safe: Phi‑3‑mini + Expert Demos + Fast PPO (2 iterations)import osos.environ["TRITON_INTERPRET"] = "1" # force CPU interpretation, no ptxasos.environ["TRITON_CACHE_DIR"] = "/tmp/triton_cache"os.environ["TORCHINDUCTOR_CPP_WRAPPER"] = "0" # stay in Python # Issue #12: prevent OOM from parallel tokenizationimport torch._dynamotorch._dynamo.config.disable = True70 unmodified linesdef load_model():model, tokenizer = FastLanguageModel.from_pretrained(model_name="unsloth/Phi-3-mini-4k-instruct-bnb-4bit",max_seq_length=2048,load_in_4bit=True,)model = FastLanguageModel.get_peft_model(250 unmodified lineswith torch.no_grad():outputs = model.generate(**inputs,max_new_tokens=128,do_sample=(temperature > 0),temperature=max(temperature, 0.01) if temperature > 0 else 1.0,min_new_tokens=1,123456770 unmodified lines78798081828384250 unmodified lines335336337338339340341# training.py – Memory‑safe: Phi‑3‑mini + Expert Demos + Fast PPO (2 iterations)import osos.environ["TRITON_DISABLE"] = "1"os.environ["TOKENIZERS_PARALLELISM"] = "false"" # stay in Python # Issue #12: prevent OOM from parallel tokenizationimport torch._dynamotorch._dynamo.config.disable = True70 unmodified linesdef load_model():model, tokenizer = FastLanguageModel.from_pretrained(model_name="unsloth/Phi-3-mini-4k-instruct-bnb-4bit",max_seq_length=768,load_in_4bit=True,)model = FastLanguageModel.get_peft_model(250 unmodified lineswith torch.no_grad():outputs = model.generate(**inputs,max_new_tokens=64,do_sample=(temperature > 0),temperature=max(temperature, 0.01) if temperature > 0 else 1.0,min_new_tokens=1,
training.py+4-5