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

[ET] Fix serde handling of inf #6799

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

SS-JIA
Copy link
Contributor

@SS-JIA SS-JIA commented Nov 12, 2024

Stack from ghstack (oldest at bottom):

Context

I was trying to inspect the ETDump of a Vulkan LLaMa inference run, and experienced an Exception stemming from a symbol range containing an infinity.

The full error log is

Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4035, in _mag
    mag_first_dig = int(ceil(log10(xpos)))
OverflowError: cannot convert float infinity to integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 31, in <module>
    __invoke_main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 28, in __invoke_main
    run_as_main(module, main_function)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/meta_only/bootstrap.py", line 98, in run_as_main
    oss_run_as_main(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/bootstrap.py", line 94, in run_as_main
    main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/backends/vulkan/fb/tools/inspector/inspector_cli.py", line 41, in main
    inspector = Inspector(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/inspector/_inspector.py", line 1025, in __init__
    self._etrecord = parse_etrecord(etrecord_path=etrecord)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/etrecord/_etrecord.py", line 318, in parse_etrecord
    edge_dialect_program = deserialize(serialized_artifact)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 683, in deserialize
    return ExportedProgramDeserializer(expected_opset_version).deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 598, in deserialize
    res = GraphModuleDeserializer().deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/export_serialize.py", line 1855, in deserialize
    lower = int(vr.lower)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 308, in __int__
    r = self.round(2)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 3856, in round
    digits_to_decimal = _mag(x)  # _mag(12) = 2, _mag(.012) = -1
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4037, in _mag
    mag_first_dig = int(ceil(Float(mpf_log(xpos._mpf_, 53))/log(10)))
AttributeError: 'Infinity' object has no attribute '_mpf_'

This arises because the range of a symbol is [-inf to inf]. Since infinity cannot be converted to int in Python, an exception is raised.

Changes

Check if a range bound is negative or positive infinity and set it explicitly instead of converted the symbolic integer to int.

Differential Revision: D65848116

## Context

I was trying to inspect the ETDump of a Vulkan LLaMa inference run, and experienced an `Exception` stemming from a symbol range containing an infinity.

The full error log is

```
Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4035, in _mag
    mag_first_dig = int(ceil(log10(xpos)))
OverflowError: cannot convert float infinity to integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 31, in <module>
    __invoke_main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 28, in __invoke_main
    run_as_main(module, main_function)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/meta_only/bootstrap.py", line 98, in run_as_main
    oss_run_as_main(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/bootstrap.py", line 94, in run_as_main
    main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/backends/vulkan/fb/tools/inspector/inspector_cli.py", line 41, in main
    inspector = Inspector(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/inspector/_inspector.py", line 1025, in __init__
    self._etrecord = parse_etrecord(etrecord_path=etrecord)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/etrecord/_etrecord.py", line 318, in parse_etrecord
    edge_dialect_program = deserialize(serialized_artifact)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 683, in deserialize
    return ExportedProgramDeserializer(expected_opset_version).deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 598, in deserialize
    res = GraphModuleDeserializer().deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/export_serialize.py", line 1855, in deserialize
    lower = int(vr.lower)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 308, in __int__
    r = self.round(2)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 3856, in round
    digits_to_decimal = _mag(x)  # _mag(12) = 2, _mag(.012) = -1
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4037, in _mag
    mag_first_dig = int(ceil(Float(mpf_log(xpos._mpf_, 53))/log(10)))
AttributeError: 'Infinity' object has no attribute '_mpf_'
```

This arises because the range of a symbol is `[-inf to inf]`. Since infinity cannot be converted to `int` in Python, an exception is raised.

## Changes

Check if a range bound is negative or positive infinity and set it explicitly instead of converted the symbolic integer to `int`.

Differential Revision: [D65848116](https://our.internmc.facebook.com/intern/diff/D65848116/)

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Nov 12, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/6799

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit e176763 with merge base dc41596 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 12, 2024
SS-JIA added a commit that referenced this pull request Nov 12, 2024
## Context

I was trying to inspect the ETDump of a Vulkan LLaMa inference run, and experienced an `Exception` stemming from a symbol range containing an infinity.

The full error log is

```
Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4035, in _mag
    mag_first_dig = int(ceil(log10(xpos)))
OverflowError: cannot convert float infinity to integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 31, in <module>
    __invoke_main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 28, in __invoke_main
    run_as_main(module, main_function)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/meta_only/bootstrap.py", line 98, in run_as_main
    oss_run_as_main(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/bootstrap.py", line 94, in run_as_main
    main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/backends/vulkan/fb/tools/inspector/inspector_cli.py", line 41, in main
    inspector = Inspector(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/inspector/_inspector.py", line 1025, in __init__
    self._etrecord = parse_etrecord(etrecord_path=etrecord)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/etrecord/_etrecord.py", line 318, in parse_etrecord
    edge_dialect_program = deserialize(serialized_artifact)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 683, in deserialize
    return ExportedProgramDeserializer(expected_opset_version).deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 598, in deserialize
    res = GraphModuleDeserializer().deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/export_serialize.py", line 1855, in deserialize
    lower = int(vr.lower)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 308, in __int__
    r = self.round(2)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 3856, in round
    digits_to_decimal = _mag(x)  # _mag(12) = 2, _mag(.012) = -1
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4037, in _mag
    mag_first_dig = int(ceil(Float(mpf_log(xpos._mpf_, 53))/log(10)))
AttributeError: 'Infinity' object has no attribute '_mpf_'
```

This arises because the range of a symbol is `[-inf to inf]`. Since infinity cannot be converted to `int` in Python, an exception is raised.

## Changes

Check if a range bound is negative or positive infinity and set it explicitly instead of converted the symbolic integer to `int`.

Differential Revision: [D65848116](https://our.internmc.facebook.com/intern/diff/D65848116/)

ghstack-source-id: 253206878
Pull Request resolved: #6799
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D65848116

## Context

I was trying to inspect the ETDump of a Vulkan LLaMa inference run, and experienced an `Exception` stemming from a symbol range containing an infinity.

The full error log is

```
Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4035, in _mag
    mag_first_dig = int(ceil(log10(xpos)))
OverflowError: cannot convert float infinity to integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 31, in <module>
    __invoke_main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 28, in __invoke_main
    run_as_main(module, main_function)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/meta_only/bootstrap.py", line 98, in run_as_main
    oss_run_as_main(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/bootstrap.py", line 94, in run_as_main
    main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/backends/vulkan/fb/tools/inspector/inspector_cli.py", line 41, in main
    inspector = Inspector(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/inspector/_inspector.py", line 1025, in __init__
    self._etrecord = parse_etrecord(etrecord_path=etrecord)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/etrecord/_etrecord.py", line 318, in parse_etrecord
    edge_dialect_program = deserialize(serialized_artifact)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 683, in deserialize
    return ExportedProgramDeserializer(expected_opset_version).deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 598, in deserialize
    res = GraphModuleDeserializer().deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/export_serialize.py", line 1855, in deserialize
    lower = int(vr.lower)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 308, in __int__
    r = self.round(2)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 3856, in round
    digits_to_decimal = _mag(x)  # _mag(12) = 2, _mag(.012) = -1
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4037, in _mag
    mag_first_dig = int(ceil(Float(mpf_log(xpos._mpf_, 53))/log(10)))
AttributeError: 'Infinity' object has no attribute '_mpf_'
```

This arises because the range of a symbol is `[-inf to inf]`. Since infinity cannot be converted to `int` in Python, an exception is raised.

## Changes

Check if a range bound is negative or positive infinity and set it explicitly instead of converted the symbolic integer to `int`.

Differential Revision: [D65848116](https://our.internmc.facebook.com/intern/diff/D65848116/)

[ghstack-poisoned]
SS-JIA added a commit that referenced this pull request Nov 12, 2024
Pull Request resolved: #6799

## Context

I was trying to inspect the ETDump of a Vulkan LLaMa inference run, and experienced an `Exception` stemming from a symbol range containing an infinity.

The full error log is

```
Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4035, in _mag
    mag_first_dig = int(ceil(log10(xpos)))
OverflowError: cannot convert float infinity to integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 31, in <module>
    __invoke_main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 28, in __invoke_main
    run_as_main(module, main_function)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/meta_only/bootstrap.py", line 98, in run_as_main
    oss_run_as_main(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/bootstrap.py", line 94, in run_as_main
    main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/backends/vulkan/fb/tools/inspector/inspector_cli.py", line 41, in main
    inspector = Inspector(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/inspector/_inspector.py", line 1025, in __init__
    self._etrecord = parse_etrecord(etrecord_path=etrecord)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/etrecord/_etrecord.py", line 318, in parse_etrecord
    edge_dialect_program = deserialize(serialized_artifact)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 683, in deserialize
    return ExportedProgramDeserializer(expected_opset_version).deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 598, in deserialize
    res = GraphModuleDeserializer().deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/export_serialize.py", line 1855, in deserialize
    lower = int(vr.lower)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 308, in __int__
    r = self.round(2)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 3856, in round
    digits_to_decimal = _mag(x)  # _mag(12) = 2, _mag(.012) = -1
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4037, in _mag
    mag_first_dig = int(ceil(Float(mpf_log(xpos._mpf_, 53))/log(10)))
AttributeError: 'Infinity' object has no attribute '_mpf_'
```

This arises because the range of a symbol is `[-inf to inf]`. Since infinity cannot be converted to `int` in Python, an exception is raised.

## Changes

Check if a range bound is negative or positive infinity and set it explicitly instead of converted the symbolic integer to `int`.
ghstack-source-id: 253217725
@exported-using-ghexport

Differential Revision: [D65848116](https://our.internmc.facebook.com/intern/diff/D65848116/)
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D65848116

@facebook-github-bot facebook-github-bot merged commit 1490d74 into gh/SS-JIA/144/base Nov 13, 2024
39 of 41 checks passed
@facebook-github-bot facebook-github-bot deleted the gh/SS-JIA/144/head branch November 13, 2024 20:03
SS-JIA added a commit that referenced this pull request Nov 13, 2024
Pull Request resolved: #6799

## Context

I was trying to inspect the ETDump of a Vulkan LLaMa inference run, and experienced an `Exception` stemming from a symbol range containing an infinity.

The full error log is

```
Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4035, in _mag
    mag_first_dig = int(ceil(log10(xpos)))
OverflowError: cannot convert float infinity to integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 31, in <module>
    __invoke_main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__run_lpar_main__.py", line 28, in __invoke_main
    run_as_main(module, main_function)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/meta_only/bootstrap.py", line 98, in run_as_main
    oss_run_as_main(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/__par__/bootstrap.py", line 94, in run_as_main
    main()
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/backends/vulkan/fb/tools/inspector/inspector_cli.py", line 41, in main
    inspector = Inspector(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/inspector/_inspector.py", line 1025, in __init__
    self._etrecord = parse_etrecord(etrecord_path=etrecord)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/devtools/etrecord/_etrecord.py", line 318, in parse_etrecord
    edge_dialect_program = deserialize(serialized_artifact)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 683, in deserialize
    return ExportedProgramDeserializer(expected_opset_version).deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/serialize.py", line 598, in deserialize
    res = GraphModuleDeserializer().deserialize(
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/executorch/exir/serde/export_serialize.py", line 1855, in deserialize
    lower = int(vr.lower)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 308, in __int__
    r = self.round(2)
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 3856, in round
    digits_to_decimal = _mag(x)  # _mag(12) = 2, _mag(.012) = -1
  File "/data/users/ssjia/fbsource/buck-out/v2/gen/fbcode/17b27aeeb079adbf/executorch/backends/vulkan/fb/tools/inspector/__inspector_cli__/inspector_cli#link-tree/sympy/core/expr.py", line 4037, in _mag
    mag_first_dig = int(ceil(Float(mpf_log(xpos._mpf_, 53))/log(10)))
AttributeError: 'Infinity' object has no attribute '_mpf_'
```

This arises because the range of a symbol is `[-inf to inf]`. Since infinity cannot be converted to `int` in Python, an exception is raised.

## Changes

Check if a range bound is negative or positive infinity and set it explicitly instead of converted the symbolic integer to `int`.
ghstack-source-id: 253217725
@exported-using-ghexport

Differential Revision: [D65848116](https://our.internmc.facebook.com/intern/diff/D65848116/)

Co-authored-by: Stephen Jia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants