Skip to content

Comments

feat: improve test coverage and enforce variable gradient consistency#205

Open
Rakshitha-Ireddi wants to merge 1 commit intozou-group:mainfrom
Rakshitha-Ireddi:feature/test-coverage-and-refactor
Open

feat: improve test coverage and enforce variable gradient consistency#205
Rakshitha-Ireddi wants to merge 1 commit intozou-group:mainfrom
Rakshitha-Ireddi:feature/test-coverage-and-refactor

Conversation

@Rakshitha-Ireddi
Copy link

Summary

This PR improves the reliability of the get_engine loading mechanism and enforces graph consistency in Variable.

Changes

  1. Test Coverage: Added tests/test_get_engine.py which uses mocks to verify that get_engine correctly dispatches to OpenAI, Anthropic, Gemini, Cohere, and LiteLLM providers without requiring real API keys.
  2. Core Refactor: Converted Variable.requires_grad to a property. The setter now validates that you cannot set requires_grad=False if any predecessors have requires_grad=True, preventing invalid computation graph states (addressing a TODO in variable.py).
  3. Verification: Added tests/test_variable_grad.py to verify the new gradient invariant logic.

Motivation

  • The get_engine function has complex dispatch logic that was previously untested.
  • The gradient consistency check ensures users don't accidentally break the autograd graph.

Authors

  • Ireddi Rakshitha
  • Yaswanth Devavarapu

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