-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Open
Labels
featureIs an improvement or enhancementIs an improvement or enhancementlightningclipl.cli.LightningCLIpl.cli.LightningCLI
Description
Description & Motivation
- When LightningCLI parses YAML configs it inspects constructor annotations via
LightningArgumentParser/jsonargparse. Typing constructs such astyping.List[str]orProtocolinstances (e.g., ourModelConverter) are not concrete runtime types, so LightningCLI raises validation/type errors before callbacks are instantiated (docs describe type-driven config parsing). - In our repo we had to strip the annotations entirely just to unblock training:
trainer:
...
callbacks:
- class_path: crosslayer_transcoder.utils.callbacks.ModelConversionCallback
init_args:
converter:
class_path: crosslayer_transcoder.utils.model_converters.circuit_tracer.CircuitTracerConverter # implements ModelConverter Protocol
init_args:
...
on_events: ["on_train_batch_end"]
class ModelConversionCallback(L.Callback):
# Note: you can't type these directly with List or ModelConverter
def __init__(
self,
converter, # type: ModelConverter
on_events=["on_train_batch_end"], # type: List[str]
):
super().__init__()
...
Pitch
- During schema generation, detect when an annotation is a
typingobject or protocol thatjsonargparsecan’t coerce. - Instead of raising, fall back to treating the argument as
Any(or defaulting to primitive validators) and log a warning pointing users to supported types.
Alternatives
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
featureIs an improvement or enhancementIs an improvement or enhancementlightningclipl.cli.LightningCLIpl.cli.LightningCLI