Skip to content

fix docs examples for ForwardBackwardOutput metrics access#37

Open
lokashrinav wants to merge 1 commit intothinking-machines-lab:mainfrom
lokashrinav:fix/fwdbwd-loss-docs
Open

fix docs examples for ForwardBackwardOutput metrics access#37
lokashrinav wants to merge 1 commit intothinking-machines-lab:mainfrom
lokashrinav:fix/fwdbwd-loss-docs

Conversation

@lokashrinav
Copy link
Copy Markdown

Summary

This updates TrainingClient documentation examples to reflect the actual ForwardBackwardOutput shape.

ForwardBackwardOutput does not expose a .loss attribute. Accessing result.loss raises an AttributeError.
For built-in cross-entropy examples, loss is available under:

result.metrics["loss:sum"]

For custom loss examples, metrics are user-defined, so the docs now show printing the full result.metrics map instead of assuming a loss:sum key always exists.

What changed

  • Replaced .loss usage in standard forward/forward_backward examples with metrics["loss:sum"]
  • Updated custom loss examples to print result.metrics (without assuming loss:sum)

Why

Running the documented examples as written currently fails with:

AttributeError: 'ForwardBackwardOutput' object has no attribute 'loss'

This PR aligns the docs with the real API surface and avoids misleading assumptions in custom-loss workflows.

Reproduction

fwdbwd_future = await training_client.forward_backward_async(data=[datum], loss_fn="cross_entropy")
fwdbwd_result = await fwdbwd_future.result_async()
print(fwdbwd_result.loss)  # AttributeError

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