Pratyush-01 commited on
Commit
d2261e4
·
verified ·
1 Parent(s): b99b9ee

resume: --lora-adapter-repo support in loop.py

Browse files
Files changed (33) hide show
  1. physix/__pycache__/__init__.cpython-311.pyc +0 -0
  2. physix/__pycache__/adapters.cpython-311.pyc +0 -0
  3. physix/__pycache__/client.cpython-311.pyc +0 -0
  4. physix/__pycache__/models.cpython-311.pyc +0 -0
  5. physix/server/__pycache__/__init__.cpython-311.pyc +0 -0
  6. physix/server/__pycache__/app.cpython-311.pyc +0 -0
  7. physix/server/__pycache__/environment.cpython-311.pyc +0 -0
  8. physix/server/__pycache__/interactive.cpython-311.pyc +0 -0
  9. physix/systems/__pycache__/__init__.cpython-311.pyc +0 -0
  10. physix/systems/__pycache__/base.cpython-311.pyc +0 -0
  11. physix/systems/__pycache__/registry.cpython-311.pyc +0 -0
  12. physix/systems/__pycache__/tier1.cpython-311.pyc +0 -0
  13. physix/systems/__pycache__/tier2.cpython-311.pyc +0 -0
  14. physix/systems/__pycache__/tier3.cpython-311.pyc +0 -0
  15. physix/training/__pycache__/__init__.cpython-311.pyc +0 -0
  16. physix/training/__pycache__/dataset.cpython-311.pyc +0 -0
  17. physix/training/__pycache__/prompt.cpython-311.pyc +0 -0
  18. physix/training/__pycache__/scorer.cpython-311.pyc +0 -0
  19. physix/training/__pycache__/sft.cpython-311.pyc +0 -0
  20. physix/training/loop.py +41 -1
  21. physix/verifier/__pycache__/__init__.cpython-311.pyc +0 -0
  22. physix/verifier/__pycache__/metrics.cpython-311.pyc +0 -0
  23. physix/verifier/__pycache__/mismatch.cpython-311.pyc +0 -0
  24. physix/verifier/__pycache__/parser.cpython-311.pyc +0 -0
  25. physix/verifier/__pycache__/reward.cpython-311.pyc +0 -0
  26. physix/verifier/__pycache__/simulator.cpython-311.pyc +0 -0
  27. tests/__pycache__/__init__.cpython-311.pyc +0 -0
  28. tests/__pycache__/test_client_ws.cpython-311-pytest-9.0.3.pyc +0 -0
  29. tests/__pycache__/test_dataset.cpython-311-pytest-9.0.3.pyc +0 -0
  30. tests/__pycache__/test_environment.cpython-311-pytest-9.0.3.pyc +0 -0
  31. tests/__pycache__/test_interactive_api.cpython-311-pytest-9.0.3.pyc +0 -0
  32. tests/__pycache__/test_prompt.cpython-311-pytest-9.0.3.pyc +0 -0
  33. tests/__pycache__/test_scorer.cpython-311-pytest-9.0.3.pyc +0 -0
physix/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (1.08 kB). View file
 
physix/__pycache__/adapters.cpython-311.pyc ADDED
Binary file (7.73 kB). View file
 
physix/__pycache__/client.cpython-311.pyc ADDED
Binary file (2.56 kB). View file
 
physix/__pycache__/models.cpython-311.pyc ADDED
Binary file (7.06 kB). View file
 
physix/server/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (534 Bytes). View file
 
physix/server/__pycache__/app.cpython-311.pyc ADDED
Binary file (6.48 kB). View file
 
physix/server/__pycache__/environment.cpython-311.pyc ADDED
Binary file (12.6 kB). View file
 
physix/server/__pycache__/interactive.cpython-311.pyc ADDED
Binary file (21.9 kB). View file
 
physix/systems/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (907 Bytes). View file
 
physix/systems/__pycache__/base.cpython-311.pyc ADDED
Binary file (10.5 kB). View file
 
physix/systems/__pycache__/registry.cpython-311.pyc ADDED
Binary file (2.86 kB). View file
 
physix/systems/__pycache__/tier1.cpython-311.pyc ADDED
Binary file (7.26 kB). View file
 
physix/systems/__pycache__/tier2.cpython-311.pyc ADDED
Binary file (6.69 kB). View file
 
physix/systems/__pycache__/tier3.cpython-311.pyc ADDED
Binary file (7.12 kB). View file
 
physix/training/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (672 Bytes). View file
 
physix/training/__pycache__/dataset.cpython-311.pyc ADDED
Binary file (7.39 kB). View file
 
physix/training/__pycache__/prompt.cpython-311.pyc ADDED
Binary file (12.4 kB). View file
 
physix/training/__pycache__/scorer.cpython-311.pyc ADDED
Binary file (8.64 kB). View file
 
physix/training/__pycache__/sft.cpython-311.pyc ADDED
Binary file (11.8 kB). View file
 
physix/training/loop.py CHANGED
@@ -76,6 +76,15 @@ class TrainingConfig(BaseModel):
76
  #: before GRPO begins. Without this the cold base model rarely produces
77
  #: any reward signal in early steps.
78
  sft_checkpoint: Optional[str] = None
 
 
 
 
 
 
 
 
 
79
  output_dir: str = "runs/physix-1.5b-rl"
80
  max_seq_length: int = 2048
81
  lora_r: int = 16
@@ -219,6 +228,20 @@ def _load_model_and_tokenizer(
219
  policy that already knows the JSON format and equation grammar, so early
220
  rollouts produce meaningful reward signal instead of all scoring zero.
221
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  if config.sft_checkpoint:
223
  _log.info(
224
  "Loading SFT-warmed model from %s (GRPO will refine from here)",
@@ -485,7 +508,16 @@ def _parse_args() -> TrainingConfig:
485
  help="How to persist the final adapter (merged_16bit is deployable).",
486
  )
487
  parser.add_argument("--sft-checkpoint", default=None,
488
- help="Path to a LoRA adapter from sft.py to warm-start from.")
 
 
 
 
 
 
 
 
 
489
  parser.add_argument("--wandb-project", default="physix-live")
490
  parser.add_argument("--wandb-run-name", default=None)
491
  parser.add_argument("--push-to-hub", action="store_true")
@@ -504,9 +536,17 @@ def _parse_args() -> TrainingConfig:
504
 
505
  args = parser.parse_args()
506
 
 
 
 
 
 
 
 
507
  return TrainingConfig(
508
  model_name=args.model,
509
  sft_checkpoint=args.sft_checkpoint,
 
510
  output_dir=args.output_dir,
511
  num_steps=args.num_steps,
512
  learning_rate=args.learning_rate,
 
76
  #: before GRPO begins. Without this the cold base model rarely produces
77
  #: any reward signal in early steps.
78
  sft_checkpoint: Optional[str] = None
79
+ #: Optional Hub repo id (or local path) of an existing LoRA adapter to
80
+ #: warm-start GRPO from — e.g. a previous GRPO run that was interrupted
81
+ #: and pushed checkpoints to ``hub_checkpoint_repo_id``. When set, the
82
+ #: base ``model_name`` is loaded and this adapter is applied as the
83
+ #: starting trainable LoRA (skipping the fresh ``get_peft_model`` call).
84
+ #: SFT is unnecessary in this case (the adapter is already downstream
85
+ #: of an SFT warm-start), so leave ``sft_checkpoint`` unset when using
86
+ #: this flag.
87
+ lora_adapter_repo: Optional[str] = None
88
  output_dir: str = "runs/physix-1.5b-rl"
89
  max_seq_length: int = 2048
90
  lora_r: int = 16
 
228
  policy that already knows the JSON format and equation grammar, so early
229
  rollouts produce meaningful reward signal instead of all scoring zero.
230
  """
231
+ if config.lora_adapter_repo:
232
+ _log.info(
233
+ "Resuming from existing LoRA adapter %s (warm-start, skipping fresh PEFT init)",
234
+ config.lora_adapter_repo,
235
+ )
236
+ model, tokenizer = FastLanguageModel.from_pretrained(
237
+ model_name=config.lora_adapter_repo,
238
+ max_seq_length=config.max_seq_length,
239
+ load_in_4bit=True,
240
+ dtype=None,
241
+ )
242
+ FastLanguageModel.for_training(model)
243
+ return model, tokenizer
244
+
245
  if config.sft_checkpoint:
246
  _log.info(
247
  "Loading SFT-warmed model from %s (GRPO will refine from here)",
 
508
  help="How to persist the final adapter (merged_16bit is deployable).",
509
  )
510
  parser.add_argument("--sft-checkpoint", default=None,
511
+ help="Path to a merged SFT model from sft.py to warm-start from.")
512
+ parser.add_argument(
513
+ "--lora-adapter-repo",
514
+ default=None,
515
+ help=(
516
+ "Hub repo id (or local path) of an existing LoRA adapter to warm-start "
517
+ "GRPO from — e.g. a previous run's checkpoint at "
518
+ "user/physix-1.5b-rl-ckpt. Mutually exclusive with --sft-checkpoint."
519
+ ),
520
+ )
521
  parser.add_argument("--wandb-project", default="physix-live")
522
  parser.add_argument("--wandb-run-name", default=None)
523
  parser.add_argument("--push-to-hub", action="store_true")
 
536
 
537
  args = parser.parse_args()
538
 
539
+ if args.sft_checkpoint and args.lora_adapter_repo:
540
+ parser.error(
541
+ "--sft-checkpoint and --lora-adapter-repo are mutually exclusive. "
542
+ "Use --lora-adapter-repo to resume from a prior GRPO run, or "
543
+ "--sft-checkpoint for a fresh GRPO from a merged SFT model."
544
+ )
545
+
546
  return TrainingConfig(
547
  model_name=args.model,
548
  sft_checkpoint=args.sft_checkpoint,
549
+ lora_adapter_repo=args.lora_adapter_repo,
550
  output_dir=args.output_dir,
551
  num_steps=args.num_steps,
552
  learning_rate=args.learning_rate,
physix/verifier/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (1.49 kB). View file
 
physix/verifier/__pycache__/metrics.cpython-311.pyc ADDED
Binary file (5.43 kB). View file
 
physix/verifier/__pycache__/mismatch.cpython-311.pyc ADDED
Binary file (6.56 kB). View file
 
physix/verifier/__pycache__/parser.cpython-311.pyc ADDED
Binary file (12.4 kB). View file
 
physix/verifier/__pycache__/reward.cpython-311.pyc ADDED
Binary file (3.87 kB). View file
 
physix/verifier/__pycache__/simulator.cpython-311.pyc ADDED
Binary file (10.4 kB). View file
 
tests/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (167 Bytes). View file
 
tests/__pycache__/test_client_ws.cpython-311-pytest-9.0.3.pyc ADDED
Binary file (10.3 kB). View file
 
tests/__pycache__/test_dataset.cpython-311-pytest-9.0.3.pyc ADDED
Binary file (13.2 kB). View file
 
tests/__pycache__/test_environment.cpython-311-pytest-9.0.3.pyc ADDED
Binary file (30.7 kB). View file
 
tests/__pycache__/test_interactive_api.cpython-311-pytest-9.0.3.pyc ADDED
Binary file (45.6 kB). View file
 
tests/__pycache__/test_prompt.cpython-311-pytest-9.0.3.pyc ADDED
Binary file (25 kB). View file
 
tests/__pycache__/test_scorer.cpython-311-pytest-9.0.3.pyc ADDED
Binary file (8.38 kB). View file