Skip to content

refactor(optimization): value-only backward#30

Merged
eric-tramel merged 7 commits into
mainfrom
refactor/feedback
Jan 21, 2026
Merged

refactor(optimization): value-only backward#30
eric-tramel merged 7 commits into
mainfrom
refactor/feedback

Conversation

@eric-tramel
Copy link
Copy Markdown
Owner

@eric-tramel eric-tramel commented Jan 18, 2026

Summary

  • Refactor backward pipeline to be Value-only with tape registry + Value.backward entrypoint
  • Replace Feedback/Loss/TracedOutput with functional loss fns returning structured Value payloads
  • Update execution/training behavior to attach tape ids to Value outputs and propagate through modules/optimizer

Rationale

Aligns plait’s autograd semantics with PyTorch-style loss.backward() while keeping per-record tape behavior and simplifying the API surface.

Changes

  • Added tape registry and Value helpers (attach_tape, collect_tape_ids, no_grad, Grad alias) and implemented Value.backward(retain_graph=...)
  • Updated executor/module/backward/parameter/optimizer to operate on Value feedback and structured payloads
  • Rewrote loss API to pure async functions returning Value (structured list[list[str]] payloads), updated examples/docs/tests
  • Removed legacy Feedback, Loss base class, and TracedOutput wrapper

API Notes / Migration

  • Training mode now returns Value outputs with tape ids (no TracedOutput)
  • Loss fns are async callables returning Value; call await output.backward(grad=loss_val, optimizer=optimizer)
  • Parameter feedback accepts Value payloads; structured payload is flattened into strings

Tests

  • make ci

Docs

  • Updated optimization/inference/execution/parameter docs and examples to new Value-based workflow

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39d7505a62

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plait/values.py Outdated
@eric-tramel eric-tramel self-assigned this Jan 19, 2026
@eric-tramel
Copy link
Copy Markdown
Owner Author

Update: fixed per-record grads in Value.backward (list/tuple and dict support), added unit tests for LossModule and TrainingStep, and added coverage for default optimizer fallback.\n\nTests: make ci; uv run --group dev -m pytest --cov=plait (90% total).

@eric-tramel eric-tramel merged commit eb556dd into main Jan 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant