aligntune 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. aligntune/__init__.py +368 -0
  2. aligntune/__main__.py +11 -0
  3. aligntune/_fallbacks.py +132 -0
  4. aligntune/_imports.py +598 -0
  5. aligntune/backends/__init__.py +64 -0
  6. aligntune/backends/trl/__init__.py +55 -0
  7. aligntune/backends/trl/eval/__init__.py +0 -0
  8. aligntune/backends/trl/rewards/__init__.py +27 -0
  9. aligntune/backends/trl/rewards/training.py +838 -0
  10. aligntune/backends/trl/rl/__init__.py +53 -0
  11. aligntune/backends/trl/rl/counterfact_grpo/__init__.py +11 -0
  12. aligntune/backends/trl/rl/counterfact_grpo/counterfact_grpo.py +1283 -0
  13. aligntune/backends/trl/rl/counterfact_grpo/custom_trainer.py +2101 -0
  14. aligntune/backends/trl/rl/dapo/__init__.py +11 -0
  15. aligntune/backends/trl/rl/dapo/dapo.py +1003 -0
  16. aligntune/backends/trl/rl/dpo/__init__.py +11 -0
  17. aligntune/backends/trl/rl/dpo/dpo.py +668 -0
  18. aligntune/backends/trl/rl/dr_grpo/__init__.py +11 -0
  19. aligntune/backends/trl/rl/dr_grpo/drgrpo.py +939 -0
  20. aligntune/backends/trl/rl/gbmpo/__init__.py +3 -0
  21. aligntune/backends/trl/rl/gbmpo/gbmpo.py +1116 -0
  22. aligntune/backends/trl/rl/gbmpo/gbmpo_trainer.py +1826 -0
  23. aligntune/backends/trl/rl/grpo/__init__.py +11 -0
  24. aligntune/backends/trl/rl/grpo/grpo.py +1105 -0
  25. aligntune/backends/trl/rl/gspo/__init__.py +11 -0
  26. aligntune/backends/trl/rl/gspo/gspo.py +1381 -0
  27. aligntune/backends/trl/rl/meta_es/es_utils.py +446 -0
  28. aligntune/backends/trl/rl/meta_es/logging_config.py +70 -0
  29. aligntune/backends/trl/rl/meta_es/meta_es_trainer.py +172 -0
  30. aligntune/backends/trl/rl/meta_es/meta_es_trainer_utils.py +673 -0
  31. aligntune/backends/trl/rl/meta_es/neural_mirror_grpo.py +726 -0
  32. aligntune/backends/trl/rl/meta_es/train_nmdrgrpo_code.py +1523 -0
  33. aligntune/backends/trl/rl/meta_es/train_nmdrgrpo_es_math.py +635 -0
  34. aligntune/backends/trl/rl/meta_es/vllm_evaluator.py +674 -0
  35. aligntune/backends/trl/rl/meta_es/vllm_evaluator_math.py +489 -0
  36. aligntune/backends/trl/rl/neural_mirror_grpo/NMGrpo.py +941 -0
  37. aligntune/backends/trl/rl/neural_mirror_grpo/neural_mirror_grpo.py +726 -0
  38. aligntune/backends/trl/rl/pace/__init__.py +49 -0
  39. aligntune/backends/trl/rl/pace/baseline.py +549 -0
  40. aligntune/backends/trl/rl/pace/curriculum.py +467 -0
  41. aligntune/backends/trl/rl/pace/pace.py +981 -0
  42. aligntune/backends/trl/rl/ppo/__init__.py +11 -0
  43. aligntune/backends/trl/rl/ppo/ppo.py +1235 -0
  44. aligntune/backends/trl/sft/Classification_trainer.py +787 -0
  45. aligntune/backends/trl/sft/__init__.py +11 -0
  46. aligntune/backends/trl/sft/sft.py +1659 -0
  47. aligntune/backends/unsloth/__init__.py +44 -0
  48. aligntune/backends/unsloth/eval/__init__.py +0 -0
  49. aligntune/backends/unsloth/rl/__init__.py +36 -0
  50. aligntune/backends/unsloth/rl/bolt/__init__.py +18 -0
  51. aligntune/backends/unsloth/rl/bolt/bolt.py +695 -0
  52. aligntune/backends/unsloth/rl/counterfact_grpo/__init__.py +11 -0
  53. aligntune/backends/unsloth/rl/counterfact_grpo/counterfact_grpo.py +960 -0
  54. aligntune/backends/unsloth/rl/dapo/__init__.py +9 -0
  55. aligntune/backends/unsloth/rl/dapo/dapo.py +1060 -0
  56. aligntune/backends/unsloth/rl/dpo/__init__.py +9 -0
  57. aligntune/backends/unsloth/rl/dpo/dpo.py +712 -0
  58. aligntune/backends/unsloth/rl/dr_grpo/__init__.py +9 -0
  59. aligntune/backends/unsloth/rl/dr_grpo/drgrpo.py +963 -0
  60. aligntune/backends/unsloth/rl/gbmpo/__init__.py +3 -0
  61. aligntune/backends/unsloth/rl/gbmpo/gbmpo.py +1216 -0
  62. aligntune/backends/unsloth/rl/gbmpo/gbmpo_trainer.py +1826 -0
  63. aligntune/backends/unsloth/rl/grpo/__init__.py +9 -0
  64. aligntune/backends/unsloth/rl/grpo/grpo.py +1108 -0
  65. aligntune/backends/unsloth/rl/gspo/__init__.py +9 -0
  66. aligntune/backends/unsloth/rl/gspo/gspo.py +1279 -0
  67. aligntune/backends/unsloth/rl/neural_mirror_grpo/NMGrpo.py +1140 -0
  68. aligntune/backends/unsloth/rl/neural_mirror_grpo/neural_mirror_grpo.py +726 -0
  69. aligntune/backends/unsloth/rl/ppo/__init__.py +76 -0
  70. aligntune/backends/unsloth/rl/ppo/ppo.py +2345 -0
  71. aligntune/backends/unsloth/rl/ppo/unsloth_patches.py +355 -0
  72. aligntune/backends/unsloth/sft/__init__.py +9 -0
  73. aligntune/backends/unsloth/sft/sft.py +1203 -0
  74. aligntune/cli/__init__.py +95 -0
  75. aligntune/cli/__main__.py +10 -0
  76. aligntune/cli/arg_parser.py +442 -0
  77. aligntune/cli/config_builders.py +469 -0
  78. aligntune/cli/diagnose.py +367 -0
  79. aligntune/cli/finetune.py +508 -0
  80. aligntune/cli/recipes.py +320 -0
  81. aligntune/cli/unified-old.py +1135 -0
  82. aligntune/cli/unified.py +1679 -0
  83. aligntune/cli/validate.py +511 -0
  84. aligntune/core/backend_factory.py +1320 -0
  85. aligntune/core/callbacks/__init__.py +7 -0
  86. aligntune/core/callbacks/base.py +165 -0
  87. aligntune/core/dataset_adapters.py +361 -0
  88. aligntune/core/optimization.py +424 -0
  89. aligntune/core/precision_handler.py +207 -0
  90. aligntune/core/rl/__init__.py +65 -0
  91. aligntune/core/rl/caching.py +324 -0
  92. aligntune/core/rl/config.py +729 -0
  93. aligntune/core/rl/config_loader.py +307 -0
  94. aligntune/core/rl/distributed.py +319 -0
  95. aligntune/core/rl/evaluator.py +1053 -0
  96. aligntune/core/rl/function_based_reward_model.py +276 -0
  97. aligntune/core/rl/logging.py +327 -0
  98. aligntune/core/rl/models.py +371 -0
  99. aligntune/core/rl/registries.py +631 -0
  100. aligntune/core/rl/reward_model_wrapper.py +212 -0
  101. aligntune/core/rl/rollout.py +412 -0
  102. aligntune/core/rl/sample_logger.py +135 -0
  103. aligntune/core/rl/trainer_base.py +920 -0
  104. aligntune/core/rl/trainer_factory.py +152 -0
  105. aligntune/core/sft/__init__.py +44 -0
  106. aligntune/core/sft/config.py +762 -0
  107. aligntune/core/sft/config_loader.py +174 -0
  108. aligntune/core/sft/evaluator.py +1017 -0
  109. aligntune/core/sft/logging.py +117 -0
  110. aligntune/core/sft/trainer_base.py +601 -0
  111. aligntune/core/sft/trainer_factory.py +78 -0
  112. aligntune/data/__init__.py +0 -0
  113. aligntune/data/full_requirements_test.py +201 -0
  114. aligntune/data/loaders/__init__.py +0 -0
  115. aligntune/data/loaders/base.py +7 -0
  116. aligntune/data/loaders/csv_loader.py +20 -0
  117. aligntune/data/loaders/directory_loader.py +27 -0
  118. aligntune/data/loaders/hf_loader.py +45 -0
  119. aligntune/data/loaders/json_loader.py +12 -0
  120. aligntune/data/loaders/parquet_loader.py +9 -0
  121. aligntune/data/loaders/resolver.py +33 -0
  122. aligntune/data/manager.py +214 -0
  123. aligntune/data/processors.py +675 -0
  124. aligntune/data/schemas.py +90 -0
  125. aligntune/eval/__init__.py +113 -0
  126. aligntune/eval/caching.py +40 -0
  127. aligntune/eval/cli.py +248 -0
  128. aligntune/eval/core.py +419 -0
  129. aligntune/eval/evaluator.py +492 -0
  130. aligntune/eval/full_evaluation_test.py +228 -0
  131. aligntune/eval/lm_eval_integration.py +443 -0
  132. aligntune/eval/metrics/__init__.py +22 -0
  133. aligntune/eval/metrics/base.py +45 -0
  134. aligntune/eval/metrics/code.py +249 -0
  135. aligntune/eval/metrics/dpo.py +372 -0
  136. aligntune/eval/metrics/generic.py +52 -0
  137. aligntune/eval/metrics/math.py +139 -0
  138. aligntune/eval/metrics/rl.py +57 -0
  139. aligntune/eval/metrics/text.py +128 -0
  140. aligntune/eval/registry.py +56 -0
  141. aligntune/eval/rl_evaluator.py +573 -0
  142. aligntune/eval/runner.py +751 -0
  143. aligntune/eval/safe_executor.py +509 -0
  144. aligntune/main.py +1024 -0
  145. aligntune/py.typed +0 -0
  146. aligntune/recipes/__init__.py +538 -0
  147. aligntune/recipes/config.py +22 -0
  148. aligntune/rewards/__init__.py +69 -0
  149. aligntune/rewards/core.py +3161 -0
  150. aligntune/rewards/factory.py +162 -0
  151. aligntune/rewards/registry.py +528 -0
  152. aligntune/rewards/training.py +804 -0
  153. aligntune/rl/__init__.py +10 -0
  154. aligntune/rl/core/__init__.py +10 -0
  155. aligntune/scripts/__init__.py +3 -0
  156. aligntune/scripts/precompute_baseline.py +1937 -0
  157. aligntune/sft/__init__.py +10 -0
  158. aligntune/sft/core/__init__.py +10 -0
  159. aligntune/utils/__init__.py +132 -0
  160. aligntune/utils/auth.py +239 -0
  161. aligntune/utils/checkpointing.py +439 -0
  162. aligntune/utils/colored_logging.py +259 -0
  163. aligntune/utils/config_extractor.py +346 -0
  164. aligntune/utils/config_utils.py +501 -0
  165. aligntune/utils/device.py +425 -0
  166. aligntune/utils/diagnostics.py +454 -0
  167. aligntune/utils/environment.py +278 -0
  168. aligntune/utils/errors.py +429 -0
  169. aligntune/utils/inference_utils.py +40 -0
  170. aligntune/utils/logging.py +301 -0
  171. aligntune/utils/math_grading.py +758 -0
  172. aligntune/utils/model_loader.py +577 -0
  173. aligntune/utils/validation.py +514 -0
  174. aligntune-0.2.0.dist-info/METADATA +306 -0
  175. aligntune-0.2.0.dist-info/RECORD +179 -0
  176. aligntune-0.2.0.dist-info/WHEEL +5 -0
  177. aligntune-0.2.0.dist-info/entry_points.txt +25 -0
  178. aligntune-0.2.0.dist-info/licenses/LICENSE +21 -0
  179. aligntune-0.2.0.dist-info/top_level.txt +1 -0
aligntune/__init__.py ADDED
@@ -0,0 +1,368 @@
1
+ """
2
+ AlignTune: A comprehensive fine-tuning library supporting both SFT and RL training methods.
3
+ """
4
+
5
+ import logging
6
+ import os
7
+ import sys
8
+
9
+ # Import colored logging utilities
10
+ try:
11
+ from .utils.colored_logging import (
12
+ init_aligntune_logging,
13
+ print_aligntune_banner,
14
+ print_section_banner,
15
+ print_subsection,
16
+ aligntune_info,
17
+ aligntune_warning,
18
+ aligntune_error,
19
+ aligntune_success,
20
+ aligntune_step,
21
+ setup_colored_logging,
22
+ )
23
+ COLORED_LOGGING_AVAILABLE = True
24
+ except ImportError:
25
+ COLORED_LOGGING_AVAILABLE = False
26
+ # Fallback to basic logging
27
+ if not logging.getLogger().handlers:
28
+ logging.basicConfig(level=logging.INFO)
29
+ logger = logging.getLogger("aligntune")
30
+ logger.setLevel(logging.WARNING)
31
+
32
+ # Initialize colored logging if available
33
+ if COLORED_LOGGING_AVAILABLE:
34
+ logger = setup_colored_logging("aligntune", logging.WARNING)
35
+ else:
36
+ # Configure basic logging as fallback
37
+ if not logging.getLogger().handlers:
38
+ logging.basicConfig(level=logging.INFO)
39
+ logger = logging.getLogger("aligntune")
40
+ logger.setLevel(logging.WARNING)
41
+
42
+ # -----------------------------------------------------------------------------
43
+ # VERSION & METADATA
44
+ # -----------------------------------------------------------------------------
45
+ try:
46
+ from importlib.metadata import version as _pkg_version, PackageNotFoundError as _PkgNotFound
47
+ __version__ = _pkg_version("aligntune")
48
+ except Exception: # Fallback during editable installs before metadata exists
49
+ __version__ = "0.0.0"
50
+ __author__ = "Your Name"
51
+ __email__ = "your.email@example.com"
52
+
53
+ # -----------------------------------------------------------------------------
54
+ # CORE IMPORTS
55
+ # -----------------------------------------------------------------------------
56
+ # Import all components from the centralized import management system
57
+ from ._imports import (
58
+ # Core availability flags
59
+ UNSLOTH_AVAILABLE,
60
+ UNSLOTH_ERROR_INFO,
61
+ TRL_AVAILABLE,
62
+ UNIFIED_RL_AVAILABLE,
63
+ UNIFIED_SFT_AVAILABLE,
64
+ EVAL_AVAILABLE,
65
+ REWARDS_AVAILABLE,
66
+ BACKEND_FACTORY_AVAILABLE,
67
+ UNIFIED_AVAILABLE,
68
+ CLI_AVAILABLE,
69
+
70
+ # Unified system components
71
+ UnifiedConfig,
72
+ AlgorithmType,
73
+ PrecisionType,
74
+ BackendType,
75
+ UnifiedModelConfig,
76
+ UnifiedDatasetConfig,
77
+ RewardConfig,
78
+ UnifiedTrainingConfig,
79
+ DistributedConfig,
80
+ UnifiedLoggingConfig,
81
+ ConfigLoader,
82
+ TrainerBase,
83
+ TrainingState,
84
+ TrainerFactory,
85
+ DatasetRegistry,
86
+ RewardRegistry,
87
+ TaskRegistry,
88
+ UnifiedLogger,
89
+ UnifiedEvaluator,
90
+ PolicyModel,
91
+ ReferenceModel,
92
+ ValueModel,
93
+ RolloutEngine,
94
+ # Optimization components
95
+ OptimizerRegistry,
96
+ SchedulerRegistry,
97
+ OptimizerType,
98
+ SchedulerType,
99
+ get_optimizer_for_config,
100
+ get_scheduler_for_config,
101
+ validate_optimizer_availability,
102
+ validate_scheduler_availability,
103
+ # Recipe system
104
+ RecipeRegistry,
105
+ RecipeTypeEnum,
106
+ ModelFamily,
107
+ RecipeMetadata,
108
+ Recipe,
109
+ load_recipe_from_yaml,
110
+ load_builtin_recipes,
111
+ # Validation and diagnostics
112
+ ConfigValidator,
113
+ validate_config,
114
+ TrainingDiagnostics,
115
+ TrainingMonitor,
116
+ DiagnosticsCollector,
117
+ generate_training_report,
118
+ run_config_validation,
119
+ run_comprehensive_diagnostics,
120
+ # Error handling and UX
121
+ AlignTuneError,
122
+ ConfigurationError,
123
+ TrainingError,
124
+ EnvironmentError,
125
+ ValidationError,
126
+ handle_error,
127
+ create_progress_display,
128
+ HealthMonitor,
129
+ config_error,
130
+ training_error,
131
+ env_error,
132
+ validation_error,
133
+ PPOTrainer,
134
+ DPOTrainer,
135
+ GRPOTrainer,
136
+ GSPOTrainer,
137
+
138
+ # SFT system components
139
+ SFTConfig,
140
+ SFTTaskType,
141
+ SFTModelConfig,
142
+ SFTDatasetConfig,
143
+ SFTTrainingConfig,
144
+ SFTLoggingConfig,
145
+ SFTConfigLoader,
146
+ SFTTrainerFactory,
147
+ InstructionTrainer,
148
+ ClassificationTrainer,
149
+ ChatTrainer,
150
+
151
+ # Evaluation system
152
+ EvalType,
153
+ TaskCategory,
154
+ EvalConfig,
155
+ EvalTask,
156
+ EvalResult,
157
+ EvalRunner,
158
+ LMEvalConfig,
159
+ LMEvalRunner,
160
+ get_available_lm_eval_tasks,
161
+ run_standard_benchmark,
162
+
163
+ # Rewards system
164
+ RewardType,
165
+ RewardConfig as RewardsRewardConfig,
166
+ RewardFunction,
167
+ RewardFunctionFactory,
168
+ CompositeReward,
169
+ rewards_registry,
170
+
171
+ # Backend factory
172
+ BackendFactory,
173
+ TrainingType,
174
+ BackendFactoryType as BackendType,
175
+ FactoryBackendType,
176
+ RLAlgorithm,
177
+ BackendConfig,
178
+ create_sft_trainer,
179
+ create_rl_trainer,
180
+ list_backends,
181
+
182
+ # CLI components
183
+ cli_main,
184
+
185
+ # Helper functions
186
+ get_available_trainers,
187
+ print_available_trainers,
188
+ check_dependencies,
189
+ get_missing_dependencies,
190
+ )
191
+
192
+ # Import fallback functions from dedicated module
193
+ from ._fallbacks import (
194
+ train_dpo_from_yaml,
195
+ train_ppo_from_yaml,
196
+ train_grpo_from_yaml,
197
+ train_grpo_from_config,
198
+ create_sample_dpo_config,
199
+ create_minimal_dpo_config,
200
+ create_sample_ppo_config,
201
+ create_minimal_ppo_config,
202
+ create_specialized_ppo_configs,
203
+ load_ppo_config_from_yaml,
204
+ show_ppo_configuration_menu,
205
+ select_ppo_dataset_size,
206
+ create_grpo_configurations,
207
+ select_grpo_config_interactively,
208
+ evaluate_grpo_model,
209
+ )
210
+
211
+ # =============================================================================
212
+ # EXPORTS
213
+ # =============================================================================
214
+
215
+ # Core exports that are always available
216
+ __all__ = [
217
+ # Version info
218
+ "__version__",
219
+ "__author__",
220
+ "__email__",
221
+
222
+ # Core availability flags
223
+ "UNSLOTH_AVAILABLE",
224
+ "TRL_AVAILABLE",
225
+ "UNIFIED_RL_AVAILABLE",
226
+ "UNIFIED_SFT_AVAILABLE",
227
+ "EVAL_AVAILABLE",
228
+ "REWARDS_AVAILABLE",
229
+ "BACKEND_FACTORY_AVAILABLE",
230
+ "UNIFIED_AVAILABLE",
231
+ "CLI_AVAILABLE",
232
+
233
+ # Helper functions
234
+ "get_available_trainers",
235
+ "print_available_trainers",
236
+ "check_dependencies",
237
+ "get_missing_dependencies",
238
+ ]
239
+
240
+ # Add unified system components if available
241
+ if UNIFIED_AVAILABLE:
242
+ __all__.extend([
243
+ "UnifiedConfig",
244
+ "AlgorithmType",
245
+ "PrecisionType",
246
+ "BackendType",
247
+ "UnifiedModelConfig",
248
+ "UnifiedDatasetConfig",
249
+ "RewardConfig",
250
+ "UnifiedTrainingConfig",
251
+ "DistributedConfig",
252
+ "UnifiedLoggingConfig",
253
+ "ConfigLoader",
254
+ "TrainerBase",
255
+ "TrainingState",
256
+ "TrainerFactory",
257
+ "DatasetRegistry",
258
+ "RewardRegistry",
259
+ "TaskRegistry",
260
+ "UnifiedLogger",
261
+ "UnifiedEvaluator",
262
+ "PolicyModel",
263
+ "ReferenceModel",
264
+ "ValueModel",
265
+ "RolloutEngine",
266
+ # Optimization components
267
+ "OptimizerRegistry",
268
+ "SchedulerRegistry",
269
+ "OptimizerType",
270
+ "SchedulerType",
271
+ "get_optimizer_for_config",
272
+ "get_scheduler_for_config",
273
+ "validate_optimizer_availability",
274
+ "validate_scheduler_availability",
275
+ # Recipe system
276
+ "RecipeRegistry",
277
+ "RecipeTypeEnum",
278
+ "ModelFamily",
279
+ "RecipeMetadata",
280
+ "Recipe",
281
+ "load_recipe_from_yaml",
282
+ "load_builtin_recipes",
283
+ # Validation and diagnostics
284
+ "ConfigValidator",
285
+ "validate_config",
286
+ "TrainingDiagnostics",
287
+ "TrainingMonitor",
288
+ "DiagnosticsCollector",
289
+ "generate_training_report",
290
+ "run_config_validation",
291
+ "run_comprehensive_diagnostics",
292
+ # Error handling and UX
293
+ "AlignTuneError",
294
+ "ConfigurationError",
295
+ "TrainingError",
296
+ "EnvironmentError",
297
+ "ValidationError",
298
+ "handle_error",
299
+ "create_progress_display",
300
+ "HealthMonitor",
301
+ "config_error",
302
+ "training_error",
303
+ "env_error",
304
+ "validation_error",
305
+ "PPOTrainer",
306
+ "DPOTrainer",
307
+ "GRPOTrainer",
308
+ "GSPOTrainer",
309
+ ])
310
+
311
+ # Add SFT system components if available
312
+ if UNIFIED_SFT_AVAILABLE:
313
+ __all__.extend([
314
+ "SFTConfig",
315
+ "SFTTaskType",
316
+ "SFTModelConfig",
317
+ "SFTDatasetConfig",
318
+ "SFTTrainingConfig",
319
+ "SFTLoggingConfig",
320
+ "SFTConfigLoader",
321
+ "SFTTrainerFactory",
322
+ "InstructionTrainer",
323
+ "ClassificationTrainer",
324
+ "ChatTrainer",
325
+ ])
326
+
327
+ # Add evaluation components if available
328
+ if EVAL_AVAILABLE:
329
+ __all__.extend([
330
+ "EvalType",
331
+ "TaskCategory",
332
+ "EvalConfig",
333
+ "EvalTask",
334
+ "EvalResult",
335
+ "EvalRunner",
336
+ "LMEvalConfig",
337
+ "LMEvalRunner",
338
+ "get_available_lm_eval_tasks",
339
+ "run_standard_benchmark",
340
+ ])
341
+
342
+ # Add rewards components if available
343
+ if REWARDS_AVAILABLE:
344
+ __all__.extend([
345
+ "RewardType",
346
+ "RewardsRewardConfig",
347
+ "RewardFunction",
348
+ "RewardFunctionFactory",
349
+ "CompositeReward",
350
+ "rewards_registry",
351
+ ])
352
+
353
+ # Add backend factory components if available
354
+ if BACKEND_FACTORY_AVAILABLE:
355
+ __all__.extend([
356
+ "BackendFactory",
357
+ "TrainingType",
358
+ "BackendType",
359
+ "FactoryBackendType",
360
+ "RLAlgorithm",
361
+ "BackendConfig",
362
+ "create_sft_trainer",
363
+ "create_rl_trainer",
364
+ "list_backends",
365
+
366
+ # CLI components
367
+ "cli_main",
368
+ ])
aligntune/__main__.py ADDED
@@ -0,0 +1,11 @@
1
+ """
2
+ AlignTune CLI Entry Point
3
+
4
+ This module provides the main entry point for the AlignTune CLI.
5
+
6
+ """
7
+
8
+ from .cli import main
9
+
10
+ if __name__ == "__main__":
11
+ main()
@@ -0,0 +1,132 @@
1
+ """
2
+ <<<<<<< HEAD
3
+ =======
4
+ Fallback handler module for AlignTune.
5
+
6
+ This module provides fallback functions when dependencies are missing.
7
+ All functions provide clear error messages with installation instructions.
8
+ """
9
+
10
+ def train_dpo_from_yaml(*args, **kwargs):
11
+ """Fallback for DPO training when TRL is not available."""
12
+ raise ImportError(
13
+ "DPO training requires TRL. Install with: pip install trl\n"
14
+ "For more information, visit: https://github.com/huggingface/trl"
15
+ )
16
+
17
+ def train_ppo_from_yaml(*args, **kwargs):
18
+ """Fallback for PPO training when TRL is not available."""
19
+ raise ImportError(
20
+ "PPO training requires TRL. Install with: pip install trl\n"
21
+ "For more information, visit: https://github.com/huggingface/trl"
22
+ )
23
+
24
+ def train_grpo_from_yaml(*args, **kwargs):
25
+ """Fallback for GRPO training when TRL is not available."""
26
+ raise ImportError(
27
+ "GRPO training requires TRL. Install with: pip install trl\n"
28
+ "For more information, visit: https://github.com/huggingface/trl"
29
+ )
30
+
31
+ def train_grpo_from_config(*args, **kwargs):
32
+ """Fallback for GRPO training from config when TRL is not available."""
33
+ raise ImportError(
34
+ "GRPO training requires TRL. Install with: pip install trl\n"
35
+ "For more information, visit: https://github.com/huggingface/trl"
36
+ )
37
+
38
+ def create_sample_dpo_config(*args, **kwargs):
39
+ """Fallback for DPO config creation when TRL is not available."""
40
+ raise ImportError(
41
+ "DPO config creation requires TRL. Install with: pip install trl\n"
42
+ "For more information, visit: https://github.com/huggingface/trl"
43
+ )
44
+
45
+ def create_minimal_dpo_config(*args, **kwargs):
46
+ """Fallback for minimal DPO config when TRL is not available."""
47
+ raise ImportError(
48
+ "DPO config creation requires TRL. Install with: pip install trl\n"
49
+ "For more information, visit: https://github.com/huggingface/trl"
50
+ )
51
+
52
+ def create_sample_ppo_config(*args, **kwargs):
53
+ """Fallback for PPO config creation when TRL is not available."""
54
+ raise ImportError(
55
+ "PPO config creation requires TRL. Install with: pip install trl\n"
56
+ "For more information, visit: https://github.com/huggingface/trl"
57
+ )
58
+
59
+ def create_minimal_ppo_config(*args, **kwargs):
60
+ """Fallback for minimal PPO config when TRL is not available."""
61
+ raise ImportError(
62
+ "PPO config creation requires TRL. Install with: pip install trl\n"
63
+ "For more information, visit: https://github.com/huggingface/trl"
64
+ )
65
+
66
+ def create_specialized_ppo_configs(*args, **kwargs):
67
+ """Fallback for specialized PPO configs when TRL is not available."""
68
+ raise ImportError(
69
+ "PPO config creation requires TRL. Install with: pip install trl\n"
70
+ "For more information, visit: https://github.com/huggingface/trl"
71
+ )
72
+
73
+ def load_ppo_config_from_yaml(*args, **kwargs):
74
+ """Fallback for PPO config loading when TRL is not available."""
75
+ raise ImportError(
76
+ "PPO config loading requires TRL. Install with: pip install trl\n"
77
+ "For more information, visit: https://github.com/huggingface/trl"
78
+ )
79
+
80
+ def show_ppo_configuration_menu(*args, **kwargs):
81
+ """Fallback for PPO config menu when TRL is not available."""
82
+ raise ImportError(
83
+ "PPO config menu requires TRL. Install with: pip install trl\n"
84
+ "For more information, visit: https://github.com/huggingface/trl"
85
+ )
86
+
87
+ def select_ppo_dataset_size(*args, **kwargs):
88
+ """Fallback for PPO dataset selection when TRL is not available."""
89
+ raise ImportError(
90
+ "PPO dataset selection requires TRL. Install with: pip install trl\n"
91
+ "For more information, visit: https://github.com/huggingface/trl"
92
+ )
93
+
94
+ def create_grpo_configurations(*args, **kwargs):
95
+ """Fallback for GRPO config creation when TRL is not available."""
96
+ raise ImportError(
97
+ "GRPO config creation requires TRL. Install with: pip install trl\n"
98
+ "For more information, visit: https://github.com/huggingface/trl"
99
+ )
100
+
101
+ def select_grpo_config_interactively(*args, **kwargs):
102
+ """Fallback for GRPO config selection when TRL is not available."""
103
+ raise ImportError(
104
+ "GRPO config selection requires TRL. Install with: pip install trl\n"
105
+ "For more information, visit: https://github.com/huggingface/trl"
106
+ )
107
+
108
+ def evaluate_grpo_model(*args, **kwargs):
109
+ """Fallback for GRPO evaluation when TRL is not available."""
110
+ raise ImportError(
111
+ "GRPO evaluation requires TRL. Install with: pip install trl\n"
112
+ "For more information, visit: https://github.com/huggingface/trl"
113
+ )
114
+
115
+ # Fallback classes for when trainers are not available
116
+ class FallbackSFTTrainer:
117
+ """Fallback SFT trainer when trainer is not available."""
118
+ def __init__(self, *args, **kwargs):
119
+ raise ImportError(
120
+ "SFT trainer not available. Check your AlignTune installation.\n"
121
+ "Install with: pip install -e .\n"
122
+ "For more information, visit: https://github.com/yourusername/aligntune"
123
+ )
124
+
125
+ class FallbackClassificationTrainer:
126
+ """Fallback classification trainer when trainer is not available."""
127
+ def __init__(self, *args, **kwargs):
128
+ raise ImportError(
129
+ "Classification trainer not available. Check your AlignTune installation.\n"
130
+ "Install with: pip install -e .\n"
131
+ "For more information, visit: https://github.com/yourusername/aligntune"
132
+ )