Skip to content

feat(weights): WeightUpdater trait + stub + feature-gated Candle LoRA (#139) - #159

Merged
micahstubbs merged 1 commit into
mainfrom
claude/issue-139-weight-updates
Jun 7, 2026
Merged

feat(weights): WeightUpdater trait + stub + feature-gated Candle LoRA (#139)#159
micahstubbs merged 1 commit into
mainfrom
claude/issue-139-weight-updates

Conversation

@micahstubbs

Copy link
Copy Markdown
Owner

Addresses #139 (and unblocks #91): formalizes the weight-update path with the standard feature-flag pattern so the harness-vs-weight loop works in the default build while a real Candle LoRA path is cleanly feature-gated (candle isn't in the offline cargo cache, so CI never builds it).

Default build (always compiled):

  • WeightUpdater trait with two implementors; StubWeightUpdater aliases the existing dependency-free CPU-reference LoRA (name() == "lora-reference-cpu"), so the weight_update.json artifact shape is unchanged and tests/web_api.rs still passes. Scheduler harness-vs-weight decision + closed loop run with zero heavy deps.
  • src/closed_loop.rs constructs StubWeightUpdater (one-line backend swap point).
  • New offline tests (stub learns / trait-object dispatch); existing scheduler "choose weight on plateau" still passes.

Feature-gated weight-updates (NOT built in CI):

  • CandleLoRAWeightUpdater on candle-core/candle-nn: a compiling, documented skeleton implementing the same trait; update() is panic-free and honestly reports "training not yet implemented" rather than fabricating a loss curve. TODO(#139) markers list the real path (device selection, frozen-base forward + LoRA vars, tokenization, reward-weighted AdamW, safetensors).

Cargo.toml: candle deps optional = true + non-default weight-updates feature. Verified cargo build --offline and --offline --features llm both succeed (candle only fetched when the feature is explicitly enabled).

Gate green: fmt/clippy/test (default + --features llm) + parity OK.

https://claude.ai/code/session_01WX3ZN9azxr1fyWuZAaRJ7Y


Generated by Claude Code

…ndle LoRA (#139)

Unblock the harness-vs-weight SIA loop by making real weight updates
representable while keeping the default/llm builds and CI dependency-free.

- WeightUpdater trait now has two backends:
  - StubWeightUpdater (default build): a type alias for the existing
    dependency-free CPU reference LoRA. Keeps the weight_update.json shape
    stable (updater = "lora-reference-cpu"), so tests/web_api.rs is unaffected.
  - CandleLoRAWeightUpdater (behind non-default `weight-updates` feature):
    a documented, TODO-marked native-Rust LoRA skeleton on candle-core /
    candle-nn. candle-* are declared optional and only pulled by the feature,
    so default + llm builds and CI never fetch/compile them.
- closed_loop.rs uses StubWeightUpdater (one-line backend swap point).
- Offline unit tests: stub == CPU reference + learns, WeightUpdater trait-object
  dispatch, and a feature-gated Candle skeleton contract test.

Gate: fmt, clippy (default + llm), cargo test (default + llm), and the
cross-language parity check all pass; offline default/llm builds verified.

https://claude.ai/code/session_01WX3ZN9azxr1fyWuZAaRJ7Y
@micahstubbs
micahstubbs merged commit d29cab4 into main Jun 7, 2026
15 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