Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for verify() #960

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Documentation for verify() #960

wants to merge 4 commits into from

Conversation

vkovinicTT
Copy link
Contributor

Added documentation for the verify() function and VerifyConfig class. This includes an overview of verification steps, examples of usage, and details on configurable checkers such as AutomaticValueChecker, AllCloseValueChecker and FullValueChecker. Additionally, provided information for enabling/disabling verification features through the VerifyConfig.

Copy link
Contributor

@pilkicTT pilkicTT left a comment

Choose a reason for hiding this comment

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

thanks for adding the docs!

ps. please update the PR title

@@ -7,6 +7,7 @@
# Project setup
- [Building](./build.md)
- [Testing](./test.md)
- [Verification](./verification.md)
Copy link
Contributor

Choose a reason for hiding this comment

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

imo this should be in the dev notes section, something like Verification in tests

def test_add():

class Add(nn.Module):
def __init__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

fix indent (4 spaces)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for some reason github renders it to 8 spaces, even though it's 4 spaces for me locally.

Copy link
Contributor

Choose a reason for hiding this comment

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

you should use spaces, not tabs

<br/>
<br/>

<img src="imgs/checkers/checkers.svg" alt="Checkers" style="width: 1200%;">
Copy link
Contributor

Choose a reason for hiding this comment

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

let's see what others say, but to me the picture doesn't add much value and makes the doc harder to edit/update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nvukobratTT what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay with using images and they can be really useful as part of documentaion. However, it's important that those can be edit/updated over time.

That said, I would opt out for using ExcallyDraw to create this and similar diagrams, and next to the image also store exported ED file which we can load and edit in the future.

| Feature | Enabled (default) |
|-----------------------------------|:-----------------:|
| Verification as a method | `True` |
| Output size check | `True` |
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the output size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed table a bit, hopefully it's clearer now.

Copy link
Contributor

Choose a reason for hiding this comment

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

what is the output length? 😄 is it the number of output tensors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hahah yes (I will put number of output tensors instead)

@vkovinicTT vkovinicTT changed the title Vkovinic/verify doc Documentation for verify() Dec 24, 2024
@vkovinicTT vkovinicTT force-pushed the vkovinic/verify_doc branch 2 times, most recently from e8e5897 to 6dd3150 Compare December 25, 2024 11:26
@vkovinicTT vkovinicTT requested a review from pilkicTT December 25, 2024 11:32
@vkovinicTT vkovinicTT force-pushed the vkovinic/verify_doc branch 5 times, most recently from 0301a80 to 4966a68 Compare December 26, 2024 10:57

## General Overview

When comparing our `compiled_model` with the `framework_model` (e.g., `PyTorch`), we aim to verify whether the output from the `compiled_model` is sufficiently similar to the output from the `framework_model` (where required degree of similarity is configurable).
Copy link
Contributor

Choose a reason for hiding this comment

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

For the introduction section, let's use common language instead of code-specific names (e.g. instead of compiled_model, let's use compiled model).

Using code-specific names is beneficial below examples. In other case, I would more prefer to have common language :))


## General Overview

When comparing our `compiled_model` with the `framework_model` (e.g., `PyTorch`), we aim to verify whether the output from the `compiled_model` is sufficiently similar to the output from the `framework_model` (where required degree of similarity is configurable).
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also mention what the framework model is. E.g. model that is run on host/cpu.

2. Run a forward pass through the framework model
3. Compile the framework model using `Forge`
4. Run a forward pass through the compiled model
5. Compare the outputs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit picking, but let's put . on every point, or remove it :))

|-----------------------------------|---------------------|:-----------------:|
| Verification as a method | `enabled` | `True` |
| Number of output tensors check | `verify_size` | `True` |
| Output type check | `verify_dtype` | `True` |
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's be more precise. E.g. output data format/type check

For more information about `VerifyConfig` you can check `forge/forge/verify/config.py`.

**Example of usage**
```python
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can keep following examples a bit shorter. E.g. now that we have full example above, we can do something like this:

    ...

    fw_out = framework_model(*inputs)
    co_out = compiled_model(*inputs)

    verify(inputs, framework_model, compiled_model, VerifyConfig(verify_dtype=False))

Copy link
Contributor

@nvukobratTT nvukobratTT left a comment

Choose a reason for hiding this comment

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

LGTM!

@vkovinicTT vkovinicTT self-assigned this Dec 27, 2024
@vkovinicTT vkovinicTT added the documentation Improvements or additions to documentation label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants