nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: JuliaGPU/KernelAbstractions.jl
Pull request #538 (2024-10-18 09:11:12)

Allow return statements for GPU-only kernels
It's a bit annoying to not be able to use return statements.
Currently you have to do something like this, but it looks weird:

```julia
@kernel function ker!(args...)
    i = @index(Global)
    _ker!(i, args...)
end

function _ker!(i, args...)
    ...
end
```

vchuravy: This needs tests. Making it GPU only is fine given #533 
pxl-th: @vchuravy if that's OK, I'd also like to tag a new release after this PR is merged.

Patch:
diff --git a/src/macros.jl b/src/macros.jl
index 55b4bab4..a511758d 100644
--- a/src/macros.jl
+++ b/src/macros.jl
@@ -14,7 +14,9 @@ function __kernel(expr, generate_cpu = true, force_inbounds = false)
     def = splitdef(expr)
     name = def[:name]
     args = def[:args]
-    find_return(expr) && error("Return statement not permitted in a kernel function $name")
+    generate_cpu && find_return(expr) && error(
+        "Return statement not permitted in a kernel function $name",
+    )
 
     constargs = Array{Bool}(undef, length(args))
     for (i, arg) in enumerate(args)


Test patch:
diff --git a/test/test.jl b/test/test.jl
index 8977231b..337af10d 100644
--- a/test/test.jl
+++ b/test/test.jl
@@ -306,4 +306,22 @@ function unittest_testsuite(Backend, backend_str, backend_mod, BackendArrayT; sk
         @test size(KernelAbstractions.zeros(backend, Float32, 0, 9)) == (0, 9)
     end
 
+    @kernel cpu = false function gpu_return_kernel!(x)
+        i = @index(Global)
+        if i ≤ (length(x) ÷ 2)
+            x[i] = 1
+            return
+        end
+    end
+    @testset "GPU kernel return statement" begin
+        if !(Backend() isa CPU)
+            A = KernelAbstractions.zeros(Backend(), Int64, 1024)
+            gpu_return_kernel!(Backend())(A; ndrange = length(A))
+            synchronize(Backend())
+            Ah = Array(A)
+            @test all(a -> a == 1, @view(Ah[1:(length(A) ÷ 2)]))
+            @test all(a -> a == 0, @view(Ah[(length(A) ÷ 2 + 1):end]))
+        end
+    end
+
 end
Repository: pytest-dev/pytest-xdist
Pull request #1079 (2024-04-29 22:30:41)

[pre-commit.ci] pre-commit autoupdate
<!--pre-commit.ci start-->
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.1 → v0.4.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.1...v0.4.7)
- [github.com/pre-commit/mirrors-mypy: v1.9.0 → v1.10.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.9.0...v1.10.0)
<!--pre-commit.ci end-->


Patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 88d7fb4..2410881 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
 repos:
 - repo: https://github.com/astral-sh/ruff-pre-commit
-  rev: "v0.4.1"
+  rev: "v0.4.7"
   hooks:
     - id: ruff
       args: ["--fix"]
@@ -23,7 +23,7 @@ repos:
         language: python
         additional_dependencies: [pygments, restructuredtext_lint]
 -   repo: https://github.com/pre-commit/mirrors-mypy
-    rev: v1.9.0
+    rev: v1.10.0
     hooks:
     -   id: mypy
         files: ^(src/|testing/)
diff --git a/changelog/1092.trivial b/changelog/1092.trivial
new file mode 100644
index 0000000..295c701
--- /dev/null
+++ b/changelog/1092.trivial
@@ -0,0 +1,1 @@
+Update an error message to better indicate where users should go for more information.
diff --git a/pyproject.toml b/pyproject.toml
index 8e5e817..341d1a0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -112,6 +112,7 @@ ignore = [
     "PLW0120",  # remove the else and dedent its contents
     "PLW2901",  # for loop variable overwritten by assignment target
     "PLR5501",  # Use `elif` instead of `else` then `if`
+    "UP031",  # Use format specifiers instead of percent format
 ]
 
 [tool.ruff.lint.pycodestyle]
diff --git a/src/xdist/report.py b/src/xdist/report.py
index eb463ab..ea00e5b 100644
--- a/src/xdist/report.py
+++ b/src/xdist/report.py
@@ -23,7 +23,8 @@ def report_collection_diff(
         "Different tests were collected between {from_id} and {to_id}. "
         "The difference is:\n"
         "{diff}\n"
-        "To see why this happens see Known limitations in documentation"
+        "To see why this happens see 'Known limitations' in documentation "
+        "for pytest-xdist"
     ).format(from_id=from_id, to_id=to_id, diff="\n".join(diff))
     msg = "\n".join(x.rstrip() for x in error_message.split("\n"))
     return msg


Test patch:
diff --git a/testing/test_dsession.py b/testing/test_dsession.py
index e57caeb..184fe35 100644
--- a/testing/test_dsession.py
+++ b/testing/test_dsession.py
@@ -543,7 +543,8 @@ def test_report_collection_diff_different() -> None:
         "+XXX\n"
         " ccc\n"
         "-YYY\n"
-        "To see why this happens see Known limitations in documentation"
+        "To see why this happens see 'Known limitations' in documentation "
+        "for pytest-xdist"
     )
 
     msg = report_collection_diff(from_collection, to_collection, "1", "2")