Skip to content

Pyright failing on main in pyro flows #1162

Closed

Description

@janfb

image

Problem 1:

def init_affine_coupling(dim: int, device: str = "cpu", **kwargs):
"""Provides the default initial arguments for an affine autoregressive transform."""
assert dim > 1, "In 1d this would be equivalent to affine flows, use them."
nonlinearity = kwargs.pop("nonlinearity", nn.ReLU())
split_dim = kwargs.get("split_dim", dim // 2)
hidden_dims = kwargs.pop("hidden_dims", [5 * dim + 20, 5 * dim + 20])
params_dims = (dim - split_dim, dim - split_dim)
arn = DenseNN(split_dim, hidden_dims, params_dims, nonlinearity=nonlinearity).to(
device
)
return [split_dim, arn], {"log_scale_min_clip": -3.0}

Problem 2:

for name, node in model_trace.iter_stochastic_nodes():
fn = node["fn"]
transforms[name] = biject_to(fn.support).inv

@manuelgloeckler any idea why this appears now?

Activity

  1. manuelgloeckler commented on Jun 11, 2024

    @manuelgloeckler
    Contributor

    I am not able to reproduce these errors locally (but some others) in Python 3.11.7.
    Will check python 3.8.

    Edit, here are my local pyright outputs:

    • Python 3.8.19:
    Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest`
    
    0 errors, 0 warnings, 0 informations 
    • Python 3.10.13 / 3.11.7
    /root/sbi/sbi/analysis/plot.py
      /root/sbi/sbi/analysis/plot.py:184:16 - error: Argument of type "tuple[Tensor, Tensor, Tensor, Tensor]" cannot be assigned to parameter "extent" of type "tuple[float, float, float, float] | None" in function "imshow"
        Type "tuple[Tensor, Tensor, Tensor, Tensor]" cannot be assigned to type "tuple[float, float, float, float] | None"
          "tuple[Tensor, Tensor, Tensor, Tensor]" is incompatible with "tuple[float, float, float, float]"
            Tuple entry 1 is incorrect type
              "Tensor" is incompatible with "float"
          "tuple[Tensor, Tensor, Tensor, Tensor]" is incompatible with "None" (reportArgumentType)
      /root/sbi/sbi/analysis/plot.py:394:21 - error: Argument of type "tuple[Unknown | Tensor, Unknown | Tensor]" cannot be assigned to parameter "left" of type "float | tuple[float, float] | None" in function "set_xlim"
        Type "tuple[Unknown | Tensor, Unknown | Tensor]" cannot be assigned to type "float | tuple[float, float] | None"
          "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "float"
          "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "tuple[float, float]"
            Tuple entry 1 is incorrect type
              Type "Unknown | Tensor" cannot be assigned to type "float"
                "Tensor" is incompatible with "float"
          "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "None" (reportArgumentType)
      /root/sbi/sbi/analysis/plot.py:397:21 - error: Argument of type "tuple[Unknown | Tensor, Unknown | Tensor]" cannot be assigned to parameter "bottom" of type "float | tuple[float, float] | None" in function "set_ylim"
        Type "tuple[Unknown | Tensor, Unknown | Tensor]" cannot be assigned to type "float | tuple[float, float] | None"
          "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "float"
          "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "tuple[float, float]"
            Tuple entry 1 is incorrect type
              Type "Unknown | Tensor" cannot be assigned to type "float"
                "Tensor" is incompatible with "float"
          "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "None" (reportArgumentType)
      /root/sbi/sbi/analysis/plot.py:1975:19 - error: No overloads for "delete" match the provided arguments (reportCallIssue)
      /root/sbi/sbi/analysis/plot.py:1975:29 - error: Argument of type "BarContainer | Polygon | list[BarContainer | Polygon]" cannot be assigned to parameter "arr" of type "ArrayLike" in function "delete" (reportArgumentType)
    5 errors, 0 warnings, 0 informations
    

    So, it seems to be some GitHub workflow environment-specific problem ...

  2. linked a pull request that will close this issuePyright GitHub action error #1165on Jun 11, 2024
  3. manuelgloeckler commented on Jun 11, 2024

    @manuelgloeckler
    Contributor

    Okay, I fixed it in #1165. In the end it was:

    • Tuple instead of List (required by Pyro)
    • The second error expects a node always to have the key "fn," which might not be true.
      Not sure why this only happens in GitHub workflows (likely different pyro versions?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions