IDifferentiableModelComponent is a model component that can report the derivative of its most recent step. More...
#include <hydrocouple.h>
Public Member Functions | |
| virtual | ~IDifferentiableModelComponent ()=default |
| ~IDifferentiableModelComponent destructor. | |
| virtual std::vector< IInput * > | differentiableInputs () const =0 |
| The inputs a derivative reaches. | |
| virtual std::vector< IArgument * > | differentiableArguments () const =0 |
| The arguments (parameters) a derivative reaches. | |
| virtual std::vector< IOutput * > | differentiableOutputs () const =0 |
| The outputs whose derivative the component can report. | |
| virtual std::vector< IComponentDataItem * > | differentiableStates () const =0 |
| The data items that make up the state carried from one step to the next. | |
| virtual bool | vjp (DifferentialSet seeds, DifferentialSet results, std::string *message=nullptr)=0 |
| Vector-Jacobian product of the most recent step (reverse mode). | |
| virtual bool | jvp (DifferentialSet seeds, DifferentialSet results, std::string *message=nullptr)=0 |
| Jacobian-vector product of the most recent step (forward mode). | |
Public Member Functions inherited from HydroCouple::IModelComponent | |
| virtual | ~IModelComponent ()=default |
| IModelComponent::~IModelComponent destructor. | |
| virtual IModelComponentInfo * | componentInfo () const =0 |
| Contains the metadata about this IModelComponent instance. | |
| virtual ComponentStatus | status () const =0 |
| Defines current status of the IModelComponent. | |
| virtual std::vector< IArgument * > | arguments () const =0 |
| Arguments needed to let the component do its work. | |
| virtual std::vector< IInput * > | inputs () const =0 |
| The list of consumer items for which a component can receive values. | |
| virtual std::vector< IOutput * > | outputs () const =0 |
| The list of IOutputs for which a component can produce results. | |
| virtual std::vector< IComponentDataItem * > | results () const =0 |
| List of the model's output results. | |
| virtual std::vector< IComponentDataItem * > | states () const =0 |
| The data items that make up the state carried from one update() to the next. | |
| virtual void | initialize ()=0 |
| Initializes the current IModelComponent. | |
| virtual std::vector< std::string > | validate ()=0 |
| Validates the populated instance of the IModelComponent. | |
| virtual void | prepare ()=0 |
| Prepares the IModelComponent for calls to the update() method. | |
| virtual void | update (const std::vector< IOutput * > &requiredOutputs={})=0 |
| This method is called to let the component update itself, thus reaching its next state. | |
| virtual void | finish ()=0 |
| finish() must be invoked as the last of any methods in the IModelComponent interface. | |
| virtual const IWorkflowComponent * | workflow () const =0 |
| Gets the workflow that this component is part of. | |
| virtual void | setWorkflow (const IWorkflowComponent *workflow)=0 |
| Sets the workflow that this component is part of. | |
| virtual std::set< Capability > | capabilities () const =0 |
| The set of optional capabilities this component supports. | |
| virtual std::vector< ErrorEntry > | errors (bool clearAfterRead=false)=0 |
| Drains this component's diagnostic queue. | |
| virtual std::string | referenceDirectory () const =0 |
| Gets the reference directory for this component instance. | |
| virtual void | setReferenceDirectory (const std::string &referenceDirectory)=0 |
| setReferenceDirectory Sets the reference directory for this component instance. | |
Public Member Functions inherited from HydroCouple::IIdentity | |
| virtual | ~IIdentity ()=default |
| IIdentity::~IIdentity is a virtual destructor. | |
| virtual const std::string & | id () const =0 |
| Gets a unique identifier for the entity. | |
Public Member Functions inherited from HydroCouple::IDescription | |
| virtual | ~IDescription ()=default |
| IDescription::~IDescription is a virtual destructor. | |
| virtual const std::string & | caption () const =0 |
| Gets caption for the entity. | |
| virtual void | setCaption (const std::string &caption)=0 |
| Sets caption for the entity. | |
| virtual const std::string & | description () const =0 |
| Gets additional descriptive information for the entity. | |
| virtual void | setDescription (const std::string &description)=0 |
| Gets additional descriptive information for the entity. | |
Public Member Functions inherited from HydroCouple::IPropertyChanged | |
| virtual | ~IPropertyChanged ()=default |
| IPropertyChanged::~IPropertyChanged is a virtual destructor. | |
Public Member Functions inherited from HydroCouple::ISignal< std::string > | |
| virtual | ~ISignal ()=default |
| ISignal::~ISignal is a virtual destructor. | |
| virtual void | connect (const std::shared_ptr< ISlot< Args... > > &slot)=0 |
| connect is used to connect a slot to the signal. | |
| virtual void | disconnect (const std::shared_ptr< ISlot< Args... > > &slot)=0 |
| disconnect is used to disconnect a slot from the signal. | |
| virtual void | blockSignals (bool block)=0 |
| blockSignals is used to block signals from being emitted. | |
Public Member Functions inherited from HydroCouple::ISignal< const std::shared_ptr< IComponentStatusChangeEventArgs > & > | |
| virtual | ~ISignal ()=default |
| ISignal::~ISignal is a virtual destructor. | |
| virtual void | connect (const std::shared_ptr< ISlot< Args... > > &slot)=0 |
| connect is used to connect a slot to the signal. | |
| virtual void | disconnect (const std::shared_ptr< ISlot< Args... > > &slot)=0 |
| disconnect is used to disconnect a slot from the signal. | |
| virtual void | blockSignals (bool block)=0 |
| blockSignals is used to block signals from being emitted. | |
Additional Inherited Members | |
Public Types inherited from HydroCouple::IModelComponent | |
| enum class | ComponentStatus : uint8_t { Created = 0 , Initializing = 1 , Initialized = 2 , Validating = 3 , Valid = 4 , WaitingForData = 5 , Invalid = 6 , Preparing = 7 , Updating = 8 , Updated = 9 , Checkpointing = 10 , Done = 11 , Finishing = 12 , Finished = 13 , Failed = 14 } |
| HydroCouple::ComponentStatus is an enumerator that describes the status of a component over the course of its lifetime. More... | |
Protected Member Functions inherited from HydroCouple::ISignal< std::string > | |
| virtual void | emit (Args... args)=0 |
| emit is used to emit the signal. | |
Protected Member Functions inherited from HydroCouple::ISignal< const std::shared_ptr< IComponentStatusChangeEventArgs > & > | |
| virtual void | emit (Args... args)=0 |
| emit is used to emit the signal. | |
IDifferentiableModelComponent is a model component that can report the derivative of its most recent step.
The contract, not the method. How a component obtains its derivative – a hand-written adjoint, an operator-overloading tool, source transformation, or a machine-learning framework's autograd – is the component's business; the interface asks only for the products below, so that derivatives compose across components written in different languages, across shared-library and process boundaries, and under any orchestrator (a C++ engine, or a framework's own autograd driving the components from Python).
The step. update() maps the state the component held before it, the values of its inputs and the values of its arguments to the state it holds after it and the values of its outputs. The items that make up the state are listed by differentiableStates(); they are ordinary data items (the data plane reads them), so a state cotangent has a shape and a kind like any other buffer and can be carried from one step to the previous one by whoever is composing the derivative. That is what lets a gradient flow through time inside a component.
The linearization point is the most recent update(). vjp() and jvp() describe that step and do not change the component's state. To differentiate an earlier step, the orchestrator restores the state before it (e.g. through ICheckpointableModelComponent), re-supplies that step's inputs and arguments, and calls update() again.
Buffers. Results are written, not accumulated: every buffer in results is overwritten in full. A seed that is absent is zero. An entry naming an item the component does not list as differentiable, or in a role that item does not have, is refused with a message.
Declared through Capability::Differentiable.
|
virtualdefault |
~IDifferentiableModelComponent destructor.
|
nodiscardpure virtual |
The arguments (parameters) a derivative reaches.
|
nodiscardpure virtual |
The inputs a derivative reaches.
Inputs not listed are treated as constant.
|
nodiscardpure virtual |
The outputs whose derivative the component can report.
|
nodiscardpure virtual |
The data items that make up the state carried from one step to the next.
Empty for a component whose step does not depend on its past.
|
nodiscardpure virtual |
Jacobian-vector product of the most recent step (forward mode).
| [in] | seeds | holds tangents of Input, Argument and StateBefore entries. |
| [in] | results | holds the buffers to overwrite with tangents of Output and StateAfter entries. |
| [out] | message | optionally receives a failure description. |
|
nodiscardpure virtual |
Vector-Jacobian product of the most recent step (reverse mode).
| [in] | seeds | holds cotangents of Output and StateAfter entries. |
| [in] | results | holds the buffers to overwrite with cotangents of Input, Argument and StateBefore entries. |
| [out] | message | optionally receives a failure description. |