Skip to content

Reference model and training loop for the elicitation path #48

Description

@ajtritt

Part of #43. Depends on #45 (sample contract) and #47 (package scaffolder).

When the user has no model code (tier 4 of the evidence hierarchy, pure elicitation), the builder has nothing to verify the consumer contract against, and the user receives a Dataset with no demonstration that it feeds anything. Both problems are solved by generating a minimal reference model alongside the training loop, so the deliverable is a working example rather than an untested class.

The reference model is a contract witness, not an architecture recommendation. Its purpose is to prove tensors flow, to make the model-forward check runnable in every case, and to give the user a working starting point to replace. It must be labeled that way in the generated code and the README, or a domain scientist will reasonably read it as DSAgt endorsing an architecture for their science.

Scope

  • Emit examples/train_minimal.py in every case. When the user has model code, it imports their model; otherwise it imports the generated reference model.
  • Emit examples/model.py only when the user has no model code. Smallest architecture that consumes the declared contract, chosen from the contract's shapes and semantic roles.
  • Sample kinds covered in v1: array, tabular, and graph. Array and tabular samples get an MLP head over flattened inputs. Graph samples get a two-layer message-passing network.
  • The graph reference model is implemented in plain torch using Tensor.index_add_ for neighborhood aggregation, not torch_geometric. PyG is a heavy dependency with compiled extensions version-matched to the torch build, and a reference model that fails to import defeats its own purpose: the acceptance criterion is that the example runs on CPU in under a minute, which it cannot do if the user first has to solve a PyG installation.
  • The exception is a contract that already commits to PyG (as the XGC case does, where samples are torch_geometric.data.Data objects). There the collation is PyG's, so the reference model uses PyG too and the dependency is already the user's, not one the builder introduced.
  • The training loop runs a handful of steps over a small subset, prints the loss, and exits. It is a smoke harness, not a training script: no checkpoints, no schedulers, no logging integrations.
  • Both files carry a header comment stating the model is a placeholder for contract verification.

Acceptance criteria

  • python examples/train_minimal.py completes on CPU in under a minute against the project's data and shows a loss value.
  • The model-forward check in Built-in check-dataset code #46 passes using the generated model when no user model exists.
  • The generated model is derived from the contract, so a contract change that alters input shape produces a correspondingly changed reference model.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions