fannheyward / coc-pyright

Pyright extension for coc.nvim
MIT License
1.29k stars 47 forks source link

Large Blocks of Code Incorrectly Marked As Unreachable #887

Closed xanderdunn closed 1 year ago

xanderdunn commented 1 year ago

Versions

showOutput Pyright:

Workspace: /home/xander/dev/magic-dev-testing
  Using python from python

  [Info  - 15:33:11.725] Pyright language server 1.1.293 starting
  [Info  - 15:33:11.725] Server root directory: /home/xander/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/
  [Info  - 15:33:11.728] Starting service instance "magic-dev-testing"
  [Info  - 15:33:11.741] Starting service instance "<default>"
  [Info  - 15:33:11.744] No configuration file found.
  [Info  - 15:33:11.745] No pyproject.toml file found.
  [Warn  - 15:33:11.748] stubPath /home/xander/dev/magic-dev-testing/typings is not a valid directory.
  [Info  - 15:33:11.749] Assuming Python platform Linux
  [Info  - 15:33:11.885] Searching for source files
  [Info  - 15:33:11.889] Found 3 source files
  [Info  - 15:33:11.891] No pyproject.toml file found.
  [Warn  - 15:33:11.891] stubPath typings is not a valid directory.
  [Info  - 15:33:11.892] Assuming Python platform Linux
  [Info  - 15:33:11.931] Searching for source files
  [Info  - 15:33:11.931] No source files found.
  [Info  - 15:33:14.157] [FG] Long operation: analyzing: /home/xander/dev/magic-dev-testing/src/fused_gelu.py (2177ms)

To reproduce the issue, install the pytorch and triton packages. I find that this issue does not reproduce if triton is not installed:

pip3 install torch
git clone https://github.com/openai/triton.git;
cd triton/python;
pip install cmake; # build time dependency
pip install -e .

Now open the file fused_gelu.py from here.

This is the syntax highlighting I see:

Screenshot 2023-02-14 at 15 36 49

The bottom half of the function gelu_partial_layer_fused_forward is erroneously marked as unreachable code. It is 100% definitely incorrect because you can actually run it yourself and see that the code is executed. This happens to several of the functions in this file, including the PartialGeluLayer.bakcward static method that is not jit compiled.

It's bad enough that I've had to disable Coc to be able to work with this file. It would be interesting to understand why this is happening here and if it can be fixed. If not, is there a way I could disable the unreachable code warnings and syntax highlighting for this file specifically?

fannheyward commented 1 year ago

Code is unreachable

This error message is reported by Pyright, have no idea what happened, but Pyright reports the following code is unreadable, coc marked them, we can do nothing in coc/coc-pyright side. Properly an issue of Pyright.

xanderdunn commented 1 year ago

Thanks, microsoft/pyright#4640