Skip to content

Commit 76b5d11

Browse files
committed
Updated misconfiguration test to accommodate both new and ancient versions of Lightning
1 parent 644df38 commit 76b5d11

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
88

99
### Added
1010

11-
- Support for Lightning ``2.5.2`` and ``2.5.3``
11+
- Verified support for Lightning ``2.5.2`` and ``2.5.3``
1212

1313
### Fixed
1414

1515
- Updated explicit pytorch version mapping matrix to include recent PyTorch release
1616
- Fixed newly failing test dependent on deprecated Lightning class attribute. Resolved [#19](https://github.com/speediedan/finetuning-scheduler/issues/19).
1717

18+
### Changed
19+
20+
- For the examples extra, updated minimum `datasets` version to `4.0.0` to ensure the new API (especially important removal of `trust_remote_code`) is used.
21+
1822
## [2.5.1] - 2025-03-27
1923

2024
### Added

requirements/examples.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
datasets
1+
datasets>=4.0.0 # important removal of trust_remote_code
22
evaluate
33
transformers>=4.18.0
44
scikit-learn
55
sentencepiece
66
tensorboardX>=2.2
77
tabulate
88
psutil
9-
numpy<2.0 # to avoid issues with oldest supported pytorch (2.2)
9+
numpy # <2.0 # to avoid issues with oldest supported pytorch (2.2)

src/fts_examples/fts_superglue.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ def __init__(
126126
"dataloader_kwargs": dataloader_kwargs,
127127
"tokenizers_parallelism": tokenizers_parallelism,
128128
}
129-
# starting with HF Datasets v3.x, trust_remote_code must be `True` https://bit.ly/hf_datasets_trust_remote_req
130-
self.trust_remote_code = True
131129
self.save_hyperparameters(self.init_hparams)
132130
self.dataloader_kwargs = {
133131
"num_workers": dataloader_kwargs.get("num_workers", 0),
@@ -142,12 +140,11 @@ def prepare_data(self):
142140
"""Load the SuperGLUE dataset."""
143141
# N.B. PL calls prepare_data from a single process (rank 0) so do not use it to assign
144142
# state (e.g. self.x=y)
145-
datasets.load_dataset("super_glue", self.hparams.task_name, trust_remote_code=self.trust_remote_code)
143+
datasets.load_dataset("aps/super_glue", self.hparams.task_name)
146144

147145
def setup(self, stage):
148146
"""Setup our dataset splits for training/validation."""
149-
self.dataset = datasets.load_dataset("super_glue", self.hparams.task_name,
150-
trust_remote_code=self.trust_remote_code)
147+
self.dataset = datasets.load_dataset("aps/super_glue", self.hparams.task_name)
151148
for split in self.dataset.keys():
152149
self.dataset[split] = self.dataset[split].map(
153150
self._convert_to_features, batched=True, remove_columns=["label"]
@@ -203,9 +200,9 @@ def __init__(
203200
experiment_tag: str = "default",
204201
log_env_details: bool = True,
205202
):
206-
"""In this example, this :class:`~lightning.pytorch.core.module.LightningModule` is initialized by composing
207-
the ./config/fts_defaults.yaml default configuration with various scheduled fine-tuning yaml configurations
208-
via the :class:`~lightning.pytorch.cli.LightningCLI` but it can be used like any other
203+
"""In this example, this :class:`~lightning.pytorch.core.module.LightningModule` is initialized by
204+
composing the ./config/fts_defaults.yaml default configuration with various scheduled fine-tuning yaml
205+
configurations via the :class:`~lightning.pytorch.cli.LightningCLI` but it can be used like any other
209206
:class:`~lightning.pytorch.core.module.LightningModule` as well.
210207
211208
Args:

src/fts_examples/ipynb_src/fts_superglue_nb.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ def __init__(
234234
tokenizers_parallelism: bool = True,
235235
**dataloader_kwargs: Any,
236236
):
237-
r"""Initialize the ``LightningDataModule`` designed for both the RTE or BoolQ SuperGLUE Hugging Face datasets.
237+
r"""Initialize the ``LightningDataModule`` designed for both the RTE or BoolQ SuperGLUE Hugging Face
238+
datasets.
238239
239240
Args:
240241
model_name_or_path (str):
@@ -255,8 +256,6 @@ def __init__(
255256
super().__init__()
256257
task_name = task_name if task_name in TASK_NUM_LABELS.keys() else DEFAULT_TASK
257258
self.text_fields = self.TASK_TEXT_FIELD_MAP[task_name]
258-
# starting with HF Datasets v3.x, trust_remote_code must be `True` https://bit.ly/hf_datasets_trust_remote_req
259-
self.trust_remote_code = True
260259
self.dataloader_kwargs = {
261260
"num_workers": dataloader_kwargs.get("num_workers", 0),
262261
"pin_memory": dataloader_kwargs.get("pin_memory", False),
@@ -271,12 +270,11 @@ def prepare_data(self):
271270
"""Load the SuperGLUE dataset."""
272271
# N.B. PL calls prepare_data from a single process (rank 0) so do not use it to assign
273272
# state (e.g. self.x=y)
274-
datasets.load_dataset("super_glue", self.hparams.task_name, trust_remote_code=self.trust_remote_code)
273+
datasets.load_dataset("aps/super_glue", self.hparams.task_name)
275274

276275
def setup(self, stage):
277276
"""Setup our dataset splits for training/validation."""
278-
self.dataset = datasets.load_dataset("super_glue", self.hparams.task_name,
279-
trust_remote_code=self.trust_remote_code)
277+
self.dataset = datasets.load_dataset("aps/super_glue", self.hparams.task_name)
280278
for split in self.dataset.keys():
281279
self.dataset[split] = self.dataset[split].map(
282280
self._convert_to_features, batched=True, remove_columns=["label"]

tests/test_finetuning_scheduler_callback.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,8 +2251,7 @@ class TestConnectWarn(Callback, CallbackResolverMixin):
22512251

22522252
def __init__(self, *args, **kwargs) -> None:
22532253
super().__init__(*args, **kwargs)
2254-
#self.callback_attrs = ("lr_finder",)
2255-
self.callback_attrs = ("optimal_lr",)
2254+
self.callback_attrs = ("_max_lr", "_min_lr", "_early_exit")
22562255
# choosing this callback because it's simple and has an attribute to find during target callback resolution
22572256
self.target_callback_ref = "LearningRateFinder"
22582257

0 commit comments

Comments
 (0)