helloadhavan/github_issues huggingface dataset:
Repository: denoland/deno
Pull request: fix(lint): support linting jsr pkg without version field

- https://github.com/denoland/deno_graph/pull/517

Changed files:
filename: cli/args/mod.rs
patch: @@ -1902,8 +1902,7 @@ pub fn config_to_deno_graph_workspace_member(
   };
   let version = match &config.json.version {
     Some(name) => Some(deno_semver::Version::parse_standard(name)?),
-    // todo(#25230): remove
-    None => bail!("Missing 'version' field in config file."),
+    None => None,
   };
   Ok(deno_graph::WorkspaceMember {
     base: config.specifier.join("./").unwrap(),

filename: tests/specs/lint/jsr_pkg_no_version/__test__.jsonc
patch: @@ -0,0 +1,5 @@
+{
+  "args": "lint",
+  "output": "lint.out",
+  "exitCode": 1
+}

filename: tests/specs/lint/jsr_pkg_no_version/deno.json
patch: @@ -0,0 +1,4 @@
+{
+  "name": "@scope/pkg",
+  "exports": "./mod.ts"
+}

filename: tests/specs/lint/jsr_pkg_no_version/lint.out
patch: @@ -0,0 +1,14 @@
+error[no-slow-types]: missing explicit return type in the public API
+ --> [WILDLINE]:1:17
+  | 
+1 | export function test() {
+  |                 ^^^^ this function is missing an explicit return type
+  | 
+  = hint: add an explicit return type to the function
+
+  info: all functions in the public API must have an explicit return type
+  docs: https://jsr.io/go/slow-type-missing-explicit-return-type
+
+
+Found 1 problem
+Checked 1 file

filename: tests/specs/lint/jsr_pkg_no_version/mod.ts
patch: @@ -0,0 +1,3 @@
+export function test() {
+  return 1 + 2;
+}
Repository: facebook/react
Pull request: Match bundle.name and match upper case entry points

Fix matching in the build script.

It's possible to provide a custom bundle name in the case we build deep imports. We should match those names as a convenience.

The script also calls toLowerCase on requested names but some entries have upper case now.

Changed files:
filename: scripts/rollup/build.js
patch: @@ -438,13 +438,21 @@ function shouldSkipBundle(bundle, bundleType) {
     }
   }
   if (requestedBundleNames.length > 0) {
+    // If the name ends with `something/index` we only match if the
+    // entry ends in something. Such as `react-dom/index` only matches
+    // `react-dom` but not `react-dom/server`. Everything else is fuzzy
+    // search.
+    const entryLowerCase = bundle.entry.toLowerCase() + '/index.js';
     const isAskingForDifferentNames = requestedBundleNames.every(
-      // If the name ends with `something/index` we only match if the
-      // entry ends in something. Such as `react-dom/index` only matches
-      // `react-dom` but not `react-dom/server`. Everything else is fuzzy
-      // search.
-      requestedName =>
-        (bundle.entry + '/index.js').indexOf(requestedName) === -1
+      requestedName => {
+        const matchEntry = entryLowerCase.indexOf(requestedName) !== -1;
+        if (!bundle.name) {
+          return !matchEntry;
+        }
+        const matchName =
+          bundle.name.toLowerCase().indexOf(requestedName) !== -1;
+        return !matchEntry && !matchName;
+      }
     );
     if (isAskingForDifferentNames) {
       return true;
Repository: denoland/deno
Pull request: v2.0.0-rc.0

Not strictly necessary, but bumping for good measure :))

Changed files:
filename: Cargo.lock
patch: @@ -1146,7 +1146,7 @@ dependencies = [
 
 [[package]]
 name = "deno"
-version = "1.46.2"
+version = "2.0.0-rc.0"
 dependencies = [
  "anstream",
  "async-trait",

filename: cli/Cargo.toml
patch: @@ -2,7 +2,7 @@
 
 [package]
 name = "deno"
-version = "1.46.2"
+version = "2.0.0-rc.0"
 authors.workspace = true
 default-run = "deno"
 edition.workspace = true
Repository: huggingface/transformers
Pull request: Fix error message in `hub.py`

# What does this PR do?
This PR fixes a broken link in an error message in `hub.py`. A space is missing between the link and the following text.

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@stevhliu @Rocketknight1


Changed files:
filename: src/transformers/utils/hub.py
patch: @@ -572,7 +572,7 @@ def cached_files(
         )
         raise EnvironmentError(
             f"{path_or_repo_id} does not appear to have {msg}. Checkout 'https://huggingface.co/{path_or_repo_id}/tree/{revision_}'"
-            "for available files."
+            " for available files."
         )
 
     # Remove potential missing entries (we can silently remove them at this point based on the flags)
Repository: electron/electron
Pull request: perf: hold `V8FunctionInvoker` args in a `std::array`

Backport of #43752

See that PR for details.


Notes: none.

Changed files:
filename: shell/common/gin_helper/callback.h
patch: @@ -5,8 +5,8 @@
 #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_CALLBACK_H_
 #define ELECTRON_SHELL_COMMON_GIN_HELPER_CALLBACK_H_
 
+#include <array>
 #include <utility>
-#include <vector>
 
 #include "base/functional/bind.h"
 #include "shell/common/gin_converters/std_converter.h"
@@ -54,7 +54,7 @@ struct V8FunctionInvoker<v8::Local<v8::Value>(ArgTypes...)> {
         isolate, context->GetMicrotaskQueue(), true,
         v8::MicrotasksScope::kRunMicrotasks};
     v8::Context::Scope context_scope(context);
-    std::vector<v8::Local<v8::Value>> args{
+    std::array<v8::Local<v8::Value>, sizeof...(raw)> args{
         gin::ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
     v8::MaybeLocal<v8::Value> ret = holder->Call(
         context, holder, args.size(), args.empty() ? nullptr : &args.front());
@@ -80,7 +80,7 @@ struct V8FunctionInvoker<void(ArgTypes...)> {
         isolate, context->GetMicrotaskQueue(), true,
         v8::MicrotasksScope::kRunMicrotasks};
     v8::Context::Scope context_scope(context);
-    std::vector<v8::Local<v8::Value>> args{
+    std::array<v8::Local<v8::Value>, sizeof...(raw)> args{
         gin::ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
     holder
         ->Call(context, holder, args.size(),
@@ -105,7 +105,7 @@ struct V8FunctionInvoker<ReturnType(ArgTypes...)> {
         isolate, context->GetMicrotaskQueue(), true,
         v8::MicrotasksScope::kRunMicrotasks};
     v8::Context::Scope context_scope(context);
-    std::vector<v8::Local<v8::Value>> args{
+    std::array<v8::Local<v8::Value>, sizeof...(raw)> args{
         gin::ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
     v8::Local<v8::Value> result;
     auto maybe_result = holder->Call(context, holder, args.size(),
Repository: nodejs/node
Pull request: test: update error code in tls-psk-circuit for for OpenSSL 3.4

Update parallel/test-tls-psk-circuit.js to account for error code changes in OpenSSL 3.4 and probably later.

Changed files:
filename: test/parallel/test-tls-psk-circuit.js
patch: @@ -66,7 +66,8 @@ const expectedHandshakeErr = common.hasOpenSSL(3, 2) ?
   'ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE' : 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE';
 test({ psk: USERS.UserB, identity: 'UserC' }, {}, expectedHandshakeErr);
 // Recognized user but incorrect secret should fail handshake
-const expectedIllegalParameterErr = common.hasOpenSSL(3, 2) ?
-  'ERR_SSL_SSL/TLS_ALERT_ILLEGAL_PARAMETER' : 'ERR_SSL_SSLV3_ALERT_ILLEGAL_PARAMETER';
+const expectedIllegalParameterErr = common.hasOpenSSL(3, 4) ? 'ERR_SSL_TLSV1_ALERT_DECRYPT_ERROR' :
+  common.hasOpenSSL(3, 2) ?
+    'ERR_SSL_SSL/TLS_ALERT_ILLEGAL_PARAMETER' : 'ERR_SSL_SSLV3_ALERT_ILLEGAL_PARAMETER';
 test({ psk: USERS.UserA, identity: 'UserB' }, {}, expectedIllegalParameterErr);
 test({ psk: USERS.UserB, identity: 'UserB' });
Repository: vercel/next.js
Pull request: Add tests for normalize_path

Just some simple unit tests

I developed these while pursuing a performance improvement that ultimately failed, but i figured i should keep the tests.

Closes PACK-4528

Changed files:
filename: turbopack/crates/turbo-tasks-fs/src/util.rs
patch: @@ -194,3 +194,34 @@ pub async fn uri_from_file(root: Vc<FileSystemPath>, path: Option<&str>) -> Resu
 
     Ok(uri)
 }
+
+#[cfg(test)]
+mod tests {
+
+    use rstest::*;
+
+    use crate::util::normalize_path;
+
+    #[rstest]
+    #[case("file.js")]
+    #[case("a/b/c/d/e/file.js")]
+    fn test_normalize_path_no_op(#[case] path: &str) {
+        assert_eq!(path, normalize_path(path).unwrap());
+    }
+
+    #[rstest]
+    #[case("/file.js", "file.js")]
+    #[case("./file.js", "file.js")]
+    #[case("././file.js", "file.js")]
+    #[case("a/../c/../file.js", "file.js")]
+    fn test_normalize_path(#[case] path: &str, #[case] normalized: &str) {
+        assert_eq!(normalized, normalize_path(path).unwrap());
+    }
+
+    #[rstest]
+    #[case("../file.js")]
+    #[case("a/../../file.js")]
+    fn test_normalize_path_invalid(#[case] path: &str) {
+        assert_eq!(None, normalize_path(path));
+    }
+}
Repository: ggml-org/llama.cpp
Pull request: tests : avoid github urls due to throttling

Tests have been randomly failing due to GitHub's new throttling policy, use another URL.

Changed files:
filename: tests/test-arg-parser.cpp
patch: @@ -128,7 +128,7 @@ int main(void) {
 
     if (common_has_curl()) {
         printf("test-arg-parser: test curl-related functions\n\n");
-        const char * GOOD_URL = "https://raw.githubusercontent.com/ggml-org/llama.cpp/refs/heads/master/README.md";
+        const char * GOOD_URL = "https://ggml.ai/";
         const char * BAD_URL  = "https://www.google.com/404";
         const char * BIG_FILE = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v1.bin";
Repository: facebook/react
Pull request: [Transition Tracing] Fix pushTransition for Transition Tracing in Offscreen

We forgot to move `pushTransition` out from the `enableCache` flag in #24321 in a place that both transition tracing and cache need to push transitions. Move it out from behind the `enableCache` to prepare for the next PRs.

Changed files:
filename: packages/react-reconciler/src/ReactFiberBeginWork.new.js
patch: @@ -748,14 +748,16 @@ function updateOffscreenComponent(
 
       subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes);
 
+      let prevCachePool = null;
       if (enableCache) {
         // If the render that spawned this one accessed the cache pool, resume
         // using the same cache. Unless the parent changed, since that means
         // there was a refresh.
-        const prevCachePool = prevState.cachePool;
-        pushTransition(workInProgress, prevCachePool, null);
+        prevCachePool = prevState.cachePool;
       }
 
+      pushTransition(workInProgress, prevCachePool, null);
+
       // Since we're not hidden anymore, reset the state
       workInProgress.memoizedState = null;
     } else {

filename: packages/react-reconciler/src/ReactFiberBeginWork.old.js
patch: @@ -748,14 +748,16 @@ function updateOffscreenComponent(
 
       subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes);
 
+      let prevCachePool = null;
       if (enableCache) {
         // If the render that spawned this one accessed the cache pool, resume
         // using the same cache. Unless the parent changed, since that means
         // there was a refresh.
-        const prevCachePool = prevState.cachePool;
-        pushTransition(workInProgress, prevCachePool, null);
+        prevCachePool = prevState.cachePool;
       }
 
+      pushTransition(workInProgress, prevCachePool, null);
+
       // Since we're not hidden anymore, reset the state
       workInProgress.memoizedState = null;
     } else {
Repository: huggingface/transformers
Pull request: fix performance issue in convert_ids_to_tokens


Changed files:
filename: src/transformers/tokenization_utils_fast.py
patch: @@ -410,9 +410,11 @@ def convert_ids_to_tokens(
         if isinstance(ids, int):
             return self._tokenizer.id_to_token(ids)
         tokens = []
+        # self.all_special_ids is an @property which may be slow, so only compute it once before the loop
+        ids_to_skip = set(self.all_special_ids) if skip_special_tokens else set()
         for index in ids:
             index = int(index)
-            if skip_special_tokens and index in self.all_special_ids:
+            if index in ids_to_skip:
                 continue
             tokens.append(self._tokenizer.id_to_token(index))
         return tokens
Repository: electron/electron
Pull request: perf: hold `V8FunctionInvoker` args in a `std::array`

#### Description of Change

Same idea as https://github.com/electron/electron/pull/43750, but for `V8FunctionInvoker`'s args.

Since the number of args is known at compile time, we can avoid a little heap memory management by using a std::array instead of a std::vector, e.g.:

```diff
   template<typename... Args>
   void Foo(Args&&... args) {
      ...
-     std::vector<Local> local_args = { ConvertToV8(args)... };
+     std::array<Local, sizeof...(args)> local_args = { ConvertToV8(args)... };
      ...
   }
```

#### Checklist

- [x] PR description included and stakeholders cc'd
- [x] `npm test` passes
- [x] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).

#### Release Notes

Notes: none.

Changed files:
filename: shell/common/gin_helper/callback.h
patch: @@ -5,8 +5,8 @@
 #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_CALLBACK_H_
 #define ELECTRON_SHELL_COMMON_GIN_HELPER_CALLBACK_H_
 
+#include <array>
 #include <utility>
-#include <vector>
 
 #include "base/functional/bind.h"
 #include "shell/common/gin_converters/std_converter.h"
@@ -54,7 +54,7 @@ struct V8FunctionInvoker<v8::Local<v8::Value>(ArgTypes...)> {
         isolate, context->GetMicrotaskQueue(), true,
         v8::MicrotasksScope::kRunMicrotasks};
     v8::Context::Scope context_scope(context);
-    std::vector<v8::Local<v8::Value>> args{
+    std::array<v8::Local<v8::Value>, sizeof...(raw)> args{
         gin::ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
     v8::MaybeLocal<v8::Value> ret = holder->Call(
         context, holder, args.size(), args.empty() ? nullptr : &args.front());
@@ -80,7 +80,7 @@ struct V8FunctionInvoker<void(ArgTypes...)> {
         isolate, context->GetMicrotaskQueue(), true,
         v8::MicrotasksScope::kRunMicrotasks};
     v8::Context::Scope context_scope(context);
-    std::vector<v8::Local<v8::Value>> args{
+    std::array<v8::Local<v8::Value>, sizeof...(raw)> args{
         gin::ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
     holder
         ->Call(context, holder, args.size(),
@@ -105,7 +105,7 @@ struct V8FunctionInvoker<ReturnType(ArgTypes...)> {
         isolate, context->GetMicrotaskQueue(), true,
         v8::MicrotasksScope::kRunMicrotasks};
     v8::Context::Scope context_scope(context);
-    std::vector<v8::Local<v8::Value>> args{
+    std::array<v8::Local<v8::Value>, sizeof...(raw)> args{
         gin::ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
     v8::Local<v8::Value> result;
     auto maybe_result = holder->Call(context, holder, args.size(),
Repository: nodejs/node
Pull request: test: remove test-runner-watch-mode-complex flaky designation

Refs: https://github.com/nodejs/node/pull/55006
Refs: https://github.com/nodejs/node/issues/54807#issuecomment-2550896871

<!--
Before submitting a pull request, please read:

- the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
- the commit message formatting guidelines at
  https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes.

If you believe this PR should be highlighted in the Node.js CHANGELOG
please add the `notable-change` label.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->


Changed files:
filename: test/parallel/parallel.status
patch: @@ -20,8 +20,6 @@ test-fs-read-stream-concurrent-reads: PASS, FLAKY
 test-snapshot-incompatible: SKIP
 
 [$system==win32]
-# https://github.com/nodejs/node/issues/54807
-test-runner-watch-mode-complex: PASS, FLAKY
 # https://github.com/nodejs/node/issues/54808
 test-async-context-frame: PASS, FLAKY
 # https://github.com/nodejs/node/issues/54534
Repository: vercel/next.js
Pull request: fix: error build if fixture typechecking fails

The type checking introduced in #75935 wasn't actually failing the build, because `find ... -exec ...` seems to eat non-zero exit codes. This is fixed by using `xargs` instead.

Also fixes some files that were failing typechecking but no one noticed due to the above bug.

Changed files:
filename: crates/next-custom-transforms/tests/fixture/server-actions/modules.d.ts
patch: @@ -49,3 +49,6 @@ declare module 'components' {
 declare module 'navigation' {
   export function redirect(href: string): void
 }
+
+// Some tests generate `data:text/javascript,...` imports
+declare module 'data:text/*'

filename: crates/next-custom-transforms/tests/fixture/server-actions/tsconfig.json
patch: @@ -29,6 +29,8 @@
     "./server-graph/25/output.js",
     "./server-graph/28/output.js",
     "./server-graph/30/output.js",
+    // FIXME: buggy renaming of anonymous functions
+    "./server-graph/51/output.js",
     // Excluded because of weird TS behavior around `action.bind(...)` making args optional
     // (but only if no JSDoc type annotations are present)
     "./server-graph/24/output.js"

filename: package.json
patch: @@ -43,7 +43,7 @@
     "lint-ast-grep": "ast-grep scan",
     "lint-no-typescript": "run-p prettier-check lint-eslint lint-language",
     "types-and-precompiled": "run-p lint-typescript check-precompiled check-compiler-fixtures types:test-lib",
-    "check-compiler-fixtures": "find crates/next-custom-transforms/tests/fixture -type f -name 'tsconfig.json' -exec /bin/sh -c 'echo \"project: $1\"; pnpm tsc --noEmit --project \"$1\"' -- {} \\;",
+    "check-compiler-fixtures": "find crates/next-custom-transforms/tests/fixture -type f -name 'tsconfig.json' -print0 | xargs --null -n1 -I'{}' pnpm tsc --noEmit --project '{}'",
     "validate-externals-doc": "node ./scripts/validate-externals-doc.js",
     "lint": "run-p test-types lint-typescript prettier-check lint-eslint lint-ast-grep lint-language",
     "lint-fix": "pnpm prettier-fix && pnpm lint-eslint --fix",
Repository: ggml-org/llama.cpp
Pull request: metal : fix typo in FA kernel comments

"key" -> "value"

Changed files:
filename: ggml/src/ggml-metal/ggml-metal.metal
patch: @@ -3255,7 +3255,7 @@ template<
     typename kd4x4_t, // key type in device memory
     short nl_k,
     void (*deq_k)(device const kd4x4_t *, short, thread k4x4_t &),
-    typename vd4x4_t, // key type in device memory
+    typename vd4x4_t, // value type in device memory
     short nl_v,
     void (*deq_v)(device const vd4x4_t *, short, thread v4x4_t &),
     short DK,        // K head size
@@ -3776,7 +3776,7 @@ template<
     typename kd4_t, // key type in device memory
     short nl_k,
     void (*deq_k_t4)(device const kd4_t *, short, thread k4_t &),
-    typename vd4_t, // key type in device memory
+    typename vd4_t, // value type in device memory
     short nl_v,
     void (*deq_v_t4)(device const vd4_t *, short, thread v4_t &),
     short DK,       // K head size
Repository: huggingface/transformers
Pull request: Align gpt2 mask preparation to #37612

# What does this PR do?

Align gpt2. This was a race condition in merging order of https://github.com/huggingface/transformers/pull/37612 and https://github.com/huggingface/transformers/pull/35761
It causes the following error https://app.circleci.com/pipelines/github/huggingface/transformers/128019/workflows/ba65aabf-d3a9-4750-b3f6-b264aa3c5bce/jobs/1715832

cc @zucchini-nlp to double-check!

Changed files:
filename: src/transformers/models/gpt2/modeling_gpt2.py
patch: @@ -1119,7 +1119,7 @@ def _update_causal_mask(
             ):
                 return None
 
-        dtype, device = input_tensor.dtype, input_tensor.device
+        dtype = input_tensor.dtype
         sequence_length = input_tensor.shape[1]
         if using_static_cache:
             target_length = past_key_values.get_max_cache_shape()
@@ -1136,7 +1136,6 @@ def _update_causal_mask(
             sequence_length=sequence_length,
             target_length=target_length,
             dtype=dtype,
-            device=device,
             cache_position=cache_position,
             batch_size=input_tensor.shape[0],
         )
@@ -1161,7 +1160,6 @@ def _prepare_4d_causal_attention_mask_with_cache_position(
         sequence_length: int,
         target_length: int,
         dtype: torch.dtype,
-        device: torch.device,
         cache_position: torch.Tensor,
         batch_size: int,
         **kwargs,
@@ -1181,8 +1179,6 @@ def _prepare_4d_causal_attention_mask_with_cache_position(
                 to account for the 0 padding, the part of the cache that is not filled yet.
             dtype (`torch.dtype`):
                 The dtype to use for the 4D attention mask.
-            device (`torch.device`):
-                The device to plcae the 4D attention mask on.
             cache_position (`torch.Tensor`):
                 Indices depicting the position of the input sequence tokens in the sequence.
             batch_size (`torch.Tensor`):
@@ -1194,11 +1190,11 @@ def _prepare_4d_causal_attention_mask_with_cache_position(
         else:
             min_dtype = torch.finfo(dtype).min
             causal_mask = torch.full(
-                (sequence_length, target_length), fill_value=min_dtype, dtype=dtype, device=device
+                (sequence_length, target_length), fill_value=min_dtype, dtype=dtype, device=cache_position.device
             )
             if sequence_length != 1:
                 causal_mask = torch.triu(causal_mask, diagonal=1)
-            causal_mask *= torch.arange(target_length, device=device) > cache_position.reshape(-1, 1)
+            causal_mask *= torch.arange(target_length, device=cache_position.device) > cache_position.reshape(-1, 1)
             causal_mask = causal_mask[None, None, :, :].expand(batch_size, 1, -1, -1)
             if attention_mask is not None:
                 causal_mask = causal_mask.clone()  # copy to contiguous memory for in-place edit