aidevices commited on
Commit
e4d27af
·
verified ·
1 Parent(s): a98766b

Sync experiment for HF Jobs Docker image

Browse files
Files changed (2) hide show
  1. .hf_space_build_stamp +4 -4
  2. train.py +21 -2
.hf_space_build_stamp CHANGED
@@ -1,4 +1,4 @@
1
- utc=2026-08-03T06:14:58.933485+00:00
2
- github_sha=9307da75e8ce5535083e28732a01fb593aac35a8
3
- run_id=30789517905
4
- nonce=41c6cf606e4c4596a32c29d241aeba9b
 
1
+ utc=2026-08-03T07:26:13.440492+00:00
2
+ github_sha=21d4354ada3f3263c3e0c64120c98a0c39886bcc
3
+ run_id=30793571239
4
+ nonce=c3950d1e3a51495683e65df6cb2438ac
train.py CHANGED
@@ -105,7 +105,7 @@ def run_test_time_training(model, tokenizer, eval_set, fmt_opts, hp):
105
  The model never sees the answers — only the demo pairs and the input grids.
106
  """
107
  from datasets import Dataset
108
- from unsloth import FastLanguageModel, UnslothTrainer as Trainer, unsloth_train
109
  from unsloth import UnslothTrainingArguments as TrainingArguments
110
  from unsloth import is_bfloat16_supported
111
  from model_tools import InputMaskingDataCollator
@@ -160,7 +160,12 @@ def run_test_time_training(model, tokenizer, eval_set, fmt_opts, hp):
160
  report_to="none",
161
  ),
162
  )
163
- unsloth_train(trainer)
 
 
 
 
 
164
  return model
165
 
166
 
@@ -230,6 +235,20 @@ def main() -> None:
230
  print(f"Experiment: {os.environ.get('EXPERIMENT_ID', '<unset>')}", flush=True)
231
  print(f"Hyperparameters: {json.dumps(hp)}", flush=True)
232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  # Freeze the environment before anything heavy runs, so we capture it even if inference fails.
234
  lock_path = capture_lockfile()
235
 
 
105
  The model never sees the answers — only the demo pairs and the input grids.
106
  """
107
  from datasets import Dataset
108
+ from unsloth import FastLanguageModel, UnslothTrainer as Trainer
109
  from unsloth import UnslothTrainingArguments as TrainingArguments
110
  from unsloth import is_bfloat16_supported
111
  from model_tools import InputMaskingDataCollator
 
160
  report_to="none",
161
  ),
162
  )
163
+ # Upstream calls unsloth_train(trainer) here, but that symbol is absent from the
164
+ # unsloth version the authors themselves pin (2024.9.post4, installed from PyPI by their
165
+ # own download notebook) — their run_evaluation script imports a name its pinned unsloth
166
+ # never shipped. UnslothTrainer subclasses trl.SFTTrainer and does not override train(),
167
+ # so trainer.train() is the equivalent (and only available) training path.
168
+ trainer.train()
169
  return model
170
 
171
 
 
235
  print(f"Experiment: {os.environ.get('EXPERIMENT_ID', '<unset>')}", flush=True)
236
  print(f"Hyperparameters: {json.dumps(hp)}", flush=True)
237
 
238
+ # GPU-side preflight: the CPU Space-build guard can't import unsloth (it probes for a
239
+ # GPU), so unsloth's own API surface is unchecked until runtime. The TTT path imports
240
+ # several unsloth symbols lazily inside run_test_time_training(), and a missing one
241
+ # otherwise only surfaces after the model has already been downloaded and loaded (this is
242
+ # how the unsloth_train import mismatch first burned GPU setup time). Resolve those
243
+ # imports here, first thing, so a bad symbol fails in seconds rather than after minutes.
244
+ if hp["mode"] == "with_ttt":
245
+ import unsloth # GPU-only import; safe here because this is the GPU job
246
+ for _sym in ("FastLanguageModel", "UnslothTrainer", "UnslothTrainingArguments",
247
+ "is_bfloat16_supported"):
248
+ if not hasattr(unsloth, _sym):
249
+ raise SystemExit(f"TTT preflight: unsloth is missing '{_sym}'")
250
+ print("TTT preflight: unsloth trainer symbols present.", flush=True)
251
+
252
  # Freeze the environment before anything heavy runs, so we capture it even if inference fails.
253
  lock_path = capture_lockfile()
254