helloadhavan/github_issues huggingface dataset:
Repository: denoland/deno
Pull request: fix(ext/node): fix `test-worker-process-argv.js` test

Done with @claude 

Changed files:
filename: ext/node/polyfills/worker_threads.ts
patch: @@ -44,9 +44,11 @@ import {
 } from "ext:deno_web/01_broadcast_channel.js";
 import { untransferableSymbol } from "ext:deno_node/internal_binding/util.ts";
 import process from "node:process";
+import { fileURLToPath } from "node:url";
 import { createRequire } from "node:module";
 
 const {
+  ArrayIsArray,
   encodeURIComponent,
   Error,
   FunctionPrototypeCall,
@@ -218,10 +220,29 @@ class NodeWorker extends EventEmitter {
     }
     // When envOpt === SHARE_ENV, env_ stays undefined and the worker
     // will use the default process.env backed by Deno.env (shared OS env).
+
+    // Handle the `argv` option: must be an array or undefined.
+    // Values are coerced to strings like Node.js does.
+    let argv_: string[] | undefined = undefined;
+    if (options?.argv != null) {
+      if (!ArrayIsArray(options.argv)) {
+        throw new ERR_INVALID_ARG_TYPE(
+          "options.argv",
+          "Array",
+          options.argv,
+        );
+      }
+      argv_ = [];
+      for (let i = 0; i < options.argv.length; i++) {
+        argv_[i] = String(options.argv[i]);
+      }
+    }
+
     const serializedWorkerMetadata = serializeJsMessageData({
       workerData: options?.workerData,
       environmentData: environmentData,
       env: env_,
+      argv: argv_,
       name: this.#name,
       isEval: !!options?.eval,
       isWorkerThread: true,
@@ -596,7 +617,7 @@ internals.__initWorkerThreads = (
           moduleSpecifier &&
           StringPrototypeStartsWith(moduleSpecifier, "file:")
         ) {
-          scriptPath = new URL(moduleSpecifier).pathname;
+          scriptPath = fileURLToPath(moduleSpecifier);
         } else {
           scriptPath = moduleSpecifier ?? "";
         }

filename: tests/node_compat/config.jsonc
patch: @@ -1576,7 +1576,7 @@
     // "parallel/test-worker-name.js": {},
     "parallel/test-worker-on-process-exit.js": {},
     "parallel/test-worker-onmessage.js": {},
-    // "parallel/test-worker-process-argv.js": {},
+    "parallel/test-worker-process-argv.js": {},
     "parallel/test-worker-process-env.js": {},
     // TODO(bartlomieju): this test just hangs
     // "parallel/test-worker-process-env-shared.js": {},
Repository: nodejs/node
Pull request: build: improve the `format-cpp` error message

This change specifies the target branch name instead of leaving that to
the committer to fill in.

Signed-off-by: Darshan Sen <raisinten@gmail.com>

<!--
Before submitting a pull request, please read
https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md.

Commit message formatting guidelines:
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.

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: .github/workflows/linters.yml
patch: @@ -78,7 +78,7 @@ jobs:
             echo
             echo 'ERROR: Please run:'
             echo
-            echo '  CLANG_FORMAT_START="$(git merge-base HEAD <target-branch-name>)" make format-cpp'
+            echo "  CLANG_FORMAT_START="$\(git merge-base HEAD ${GITHUB_BASE_REF}\)" make format-cpp"
             echo
             echo 'to format the commits in your branch.'
             exit "$EXIT_CODE"
Repository: denoland/deno
Pull request: fix: run on pre-Windows 10 version 1709

Fixes denoland/deno#27635

The [`IsWow64Process2` line was removed](https://github.com/quinn-rs/quinn/commit/85011ef42e663e52fb52d490b4798f8936dd6517) in `0.5.9` so this patch bump resolves the issue for older versions of Windows.

I'm not sure how to make tests for this, but you can validate that the issue is resolved by successfully running `dino.exe` on any version of Windows before Windows 10 version 1709.

Changed files:
filename: Cargo.lock
patch: @@ -3920,7 +3920,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
 dependencies = [
  "libc",
- "windows-sys 0.59.0",
+ "windows-sys 0.52.0",
 ]
 
 [[package]]
@@ -7441,16 +7441,16 @@ dependencies = [
 
 [[package]]
 name = "quinn-udp"
-version = "0.5.8"
+version = "0.5.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "52cd4b1eff68bf27940dd39811292c49e007f4d0b4c357358dc9b0197be6b527"
+checksum = "1c40286217b4ba3a71d644d752e6a0b71f13f1b6a2c5311acfcbe0c2418ed904"
 dependencies = [
  "cfg_aliases",
  "libc",
  "once_cell",
  "socket2 0.5.5",
  "tracing",
- "windows-sys 0.59.0",
+ "windows-sys 0.52.0",
 ]
 
 [[package]]
Repository: electron/electron
Pull request: fix: titlebar showing in content protected window

Backport of #47241

See that PR for details.


Notes: Fixed an issue where protected transparent windows inappropriately showed a titlebar after visibility change.


Changed files:
filename: shell/browser/ui/win/electron_desktop_window_tree_host_win.cc
patch: @@ -143,11 +143,33 @@ bool ElectronDesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) {
 void ElectronDesktopWindowTreeHostWin::HandleVisibilityChanged(bool visible) {
   if (native_window_view_->widget())
     native_window_view_->widget()->OnNativeWidgetVisibilityChanged(visible);
+
+  if (visible)
+    UpdateAllowScreenshots();
 }
 
 void ElectronDesktopWindowTreeHostWin::SetAllowScreenshots(bool allow) {
-  ::SetWindowDisplayAffinity(GetAcceleratedWidget(),
-                             allow ? WDA_NONE : WDA_EXCLUDEFROMCAPTURE);
+  if (allow_screenshots_ == allow)
+    return;
+
+  allow_screenshots_ = allow;
+
+  // If the window is not visible, do not set the window display affinity
+  // because `SetWindowDisplayAffinity` will attempt to compose the window,
+  if (!IsVisible())
+    return;
+
+  UpdateAllowScreenshots();
+}
+
+void ElectronDesktopWindowTreeHostWin::UpdateAllowScreenshots() {
+  bool allowed = views::DesktopWindowTreeHostWin::AreScreenshotsAllowed();
+  if (allowed == allow_screenshots_)
+    return;
+
+  ::SetWindowDisplayAffinity(
+      GetAcceleratedWidget(),
+      allow_screenshots_ ? WDA_NONE : WDA_EXCLUDEFROMCAPTURE);
 }
 
 void ElectronDesktopWindowTreeHostWin::OnNativeThemeUpdated(

filename: shell/browser/ui/win/electron_desktop_window_tree_host_win.h
patch: @@ -51,8 +51,11 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin,
   bool ShouldWindowContentsBeTransparent() const override;
 
  private:
+  void UpdateAllowScreenshots();
+
   raw_ptr<NativeWindowViews> native_window_view_;  // weak ref
   std::optional<bool> force_should_paint_as_active_;
+  bool allow_screenshots_ = true;
   bool widget_init_done_ = false;
 };
Repository: vercel/next.js
Pull request: Fix double comma in build manifest

## What?

Fixes a bug highlighted by Vercel Agent while moving code in #84125. 

Specific comment: https://github.com/vercel/next.js/pull/84125/files#r2371621679



Closes PACK-5557

Changed files:
filename: packages/next/src/build/webpack/plugins/build-manifest-plugin-utils.ts
patch: @@ -72,9 +72,9 @@ export function createEdgeRuntimeManifest(
     `globalThis.__BUILD_MANIFEST.lowPriorityFiles = [\n` +
     manifestFilenames
       .map((filename) => {
-        return `"/static/" + process.env.__NEXT_BUILD_ID + "/${filename}",\n`
+        return `"/static/" + process.env.__NEXT_BUILD_ID + "/${filename}"`
       })
-      .join(',') +
+      .join(',\n') +
     `\n];`
 
   return manifestDefCode + lowPriorityFilesCode
Repository: facebook/react
Pull request: Add FB RSC Entry for React Package

I noticed that the www-modern builds pick up the `.experimental.js` entry points but these flags that are associated with these exports are not enabled in www, so it gets the wrong builds.

This file is just a clone over the stable `ReactServer.js` one. We should probably do the reexport pattern instead.


Changed files:
filename: packages/react/src/ReactServer.fb.js
patch: @@ -0,0 +1,60 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+export {default as __SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE} from './ReactSharedInternalsServer';
+
+import {forEach, map, count, toArray, only} from './ReactChildren';
+import {
+  REACT_FRAGMENT_TYPE,
+  REACT_PROFILER_TYPE,
+  REACT_STRICT_MODE_TYPE,
+  REACT_SUSPENSE_TYPE,
+} from 'shared/ReactSymbols';
+import {
+  cloneElement,
+  createElement,
+  isValidElement,
+} from './jsx/ReactJSXElement';
+import {createRef} from './ReactCreateRef';
+import {use, useId, useCallback, useDebugValue, useMemo} from './ReactHooks';
+import {forwardRef} from './ReactForwardRef';
+import {lazy} from './ReactLazy';
+import {memo} from './ReactMemo';
+import {cache} from './ReactCacheServer';
+import version from 'shared/ReactVersion';
+
+const Children = {
+  map,
+  forEach,
+  count,
+  toArray,
+  only,
+};
+
+export {
+  Children,
+  REACT_FRAGMENT_TYPE as Fragment,
+  REACT_PROFILER_TYPE as Profiler,
+  REACT_STRICT_MODE_TYPE as StrictMode,
+  REACT_SUSPENSE_TYPE as Suspense,
+  cloneElement,
+  createElement,
+  createRef,
+  use,
+  forwardRef,
+  isValidElement,
+  lazy,
+  memo,
+  cache,
+  useId,
+  useCallback,
+  useDebugValue,
+  useMemo,
+  version,
+};
Repository: ollama/ollama
Pull request: Allow setting max vram for workarounds

Until we get all the memory calculations correct, this can provide and escape valve for users to workaround out of memory crashes.

Example usage (windows)
```powershell
$env:OLLAMA_MAX_VRAM="3221225472"
ollama.exe serve
...
time=2024-03-06T16:52:04.246-08:00 level=INFO source=gpu.go:251 msg="user override OLLAMA_MAX_VRAM=3221225472"
...
llm_load_tensors: offloading 20 repeating layers to GPU
llm_load_tensors: offloaded 20/33 layers to GPU
llm_load_tensors:        CPU buffer size =  3647.87 MiB
llm_load_tensors:      CUDA0 buffer size =  2171.88 MiB
```

This was llama2 which would have normally fit entirely on my GPU.

Changed files:
filename: gpu/gpu.go
patch: @@ -242,6 +242,15 @@ func getCPUMem() (memInfo, error) {
 }
 
 func CheckVRAM() (int64, error) {
+	userLimit := os.Getenv("OLLAMA_MAX_VRAM")
+	if userLimit != "" {
+		avail, err := strconv.ParseInt(userLimit, 10, 64)
+		if err != nil {
+			return 0, fmt.Errorf("Invalid OLLAMA_MAX_VRAM setting %s: %s", userLimit, err)
+		}
+		slog.Info(fmt.Sprintf("user override OLLAMA_MAX_VRAM=%d", avail))
+		return avail, nil
+	}
 	gpuInfo := GetGPUInfo()
 	if gpuInfo.FreeMemory > 0 && (gpuInfo.Library == "cuda" || gpuInfo.Library == "rocm") {
 		// leave 10% or 1024MiB of VRAM free per GPU to handle unaccounted for overhead

filename: gpu/gpu_darwin.go
patch: @@ -1,18 +1,33 @@
 //go:build darwin
 
 package gpu
+
 /*
 #cgo CFLAGS: -x objective-c
 #cgo LDFLAGS: -framework Foundation -framework CoreGraphics -framework Metal
 #include "gpu_info_darwin.h"
 */
 import "C"
 import (
+	"fmt"
+	"log/slog"
+	"os"
 	"runtime"
+	"strconv"
 )
 
 // CheckVRAM returns the free VRAM in bytes on Linux machines with NVIDIA GPUs
 func CheckVRAM() (int64, error) {
+	userLimit := os.Getenv("OLLAMA_MAX_VRAM")
+	if userLimit != "" {
+		avail, err := strconv.ParseInt(userLimit, 10, 64)
+		if err != nil {
+			return 0, fmt.Errorf("Invalid OLLAMA_MAX_VRAM setting %s: %s", userLimit, err)
+		}
+		slog.Info(fmt.Sprintf("user override OLLAMA_MAX_VRAM=%d", avail))
+		return avail, nil
+	}
+
 	if runtime.GOARCH == "amd64" {
 		// gpu not supported, this may not be metal
 		return 0, nil
Repository: denoland/deno
Pull request: ci: use code blocks for test lists in Node compat Slack messages

## Summary
- Format newly passing, newly failing, and flaky test lists in the Node compat Slack thread as code blocks (triple backticks) instead of inline code for improved readability

## Test plan
- [ ] Verify Slack message rendering with code blocks displays correctly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Changed files:
filename: tests/node_compat/slack.ts
patch: @@ -294,27 +294,29 @@ async function generateThreadBlocks(
     const sorted = [...newlyPassing.entries()].sort(([a], [b]) =>
       a.localeCompare(b)
     );
-    let text = `*Newly Passing (${sorted.length}):*\n`;
+    let text = `*Newly Passing (${sorted.length}):*\n\`\`\`\n`;
     for (const [testName, oses] of sorted.slice(0, MAX_NEWLY_PASSING)) {
-      text += `\`${testName}\` (${formatOsList(oses)})\n`;
+      text += `${testName} (${formatOsList(oses)})\n`;
     }
     if (sorted.length > MAX_NEWLY_PASSING) {
-      text += `_...and ${sorted.length - MAX_NEWLY_PASSING} more_\n`;
+      text += `...and ${sorted.length - MAX_NEWLY_PASSING} more\n`;
     }
+    text += `\`\`\``;
     blocks.push({ type: "section", text: { type: "mrkdwn", text } });
   }
 
   if (newlyFailing.size > 0) {
     const sorted = [...newlyFailing.entries()].sort(([a], [b]) =>
       a.localeCompare(b)
     );
-    let text = `*Started Failing (${sorted.length}):*\n`;
+    let text = `*Started Failing (${sorted.length}):*\n\`\`\`\n`;
     for (const [testName, oses] of sorted.slice(0, MAX_NEWLY_FAILING)) {
-      text += `\`${testName}\` (${formatOsList(oses)})\n`;
+      text += `${testName} (${formatOsList(oses)})\n`;
     }
     if (sorted.length > MAX_NEWLY_FAILING) {
-      text += `_...and ${sorted.length - MAX_NEWLY_FAILING} more_\n`;
+      text += `...and ${sorted.length - MAX_NEWLY_FAILING} more\n`;
     }
+    text += `\`\`\``;
     blocks.push({ type: "section", text: { type: "mrkdwn", text } });
   }
 
@@ -324,17 +326,18 @@ async function generateThreadBlocks(
     );
     let text = `*Flaky Tests (last ${
       FLAKY_HISTORY_DAYS + 1
-    } runs, ${sorted.length} tests):*\n`;
+    } runs, ${sorted.length} tests):*\n\`\`\`\n`;
     for (const [testName, osStats] of sorted.slice(0, MAX_FLAKY)) {
       const parts: string[] = [];
       for (const [os, stats] of osStats) {
         parts.push(`${os}: ${stats.pass}/${stats.total}`);
       }
-      text += `\`${testName}\` ${parts.join(", ")}\n`;
+      text += `${testName}  ${parts.join(", ")}\n`;
     }
     if (sorted.length > MAX_FLAKY) {
-      text += `_...and ${sorted.length - MAX_FLAKY} more_\n`;
+      text += `...and ${sorted.length - MAX_FLAKY} more\n`;
     }
+    text += `\`\`\``;
     blocks.push({ type: "section", text: { type: "mrkdwn", text } });
   }
Repository: ggml-org/llama.cpp
Pull request: server: strip content-length header on proxy

fix https://github.com/ggml-org/llama.cpp/issues/17710

Note: there is also another alternative fix is to allow `server_http_proxy` to select if it wants to return a stream
 or not. but IMO this solution is not elegant because in case of non-stream:
- it is difficult to track timeout errors
- proxy with large amount of data becomes slow
- higher memory usage
- add lot more code

Changed files:
filename: tools/server/server-models.cpp
patch: @@ -900,6 +900,7 @@ static bool should_strip_proxy_header(const std::string & header_name) {
     // Headers that get duplicated when router forwards child responses
     if (header_name == "server" ||
         header_name == "transfer-encoding" ||
+        header_name == "content-length" || // quick fix for https://github.com/ggml-org/llama.cpp/issues/17710
         header_name == "keep-alive") {
         return true;
     }
Repository: ollama/ollama
Pull request: fix some typos


Changed files:
filename: docs/development.md
patch: @@ -69,7 +69,7 @@ go build .
 
 *Your operating system distribution may already have packages for AMD ROCm and CLBlast. Distro packages are often preferable, but instructions are distro-specific. Please consult distro-specific docs for dependencies if available!*
 
-Install [CLBlast](https://github.com/CNugteren/CLBlast/blob/master/doc/installation.md) and [ROCm](https://rocm.docs.amd.com/en/latest/deploy/linux/quick_start.html) developement packages first, as well as `cmake` and `golang`.
+Install [CLBlast](https://github.com/CNugteren/CLBlast/blob/master/doc/installation.md) and [ROCm](https://rocm.docs.amd.com/en/latest/deploy/linux/quick_start.html) development packages first, as well as `cmake` and `golang`.
 
 Typically the build scripts will auto-detect ROCm, however, if your Linux distro
 or installation approach uses unusual paths, you can specify the location by

filename: llm/generate/gen_common.sh
patch: @@ -1,4 +1,4 @@
-# common logic accross linux and darwin
+# common logic across linux and darwin
 
 init_vars() {
     case "${GOARCH}" in
Repository: huggingface/transformers
Pull request: Fix docker quantization

# What does this PR do?

As per title 

Changed files:
filename: docker/transformers-quantization-latest-gpu/Dockerfile
patch: @@ -30,22 +30,21 @@ RUN python3 -m pip install --no-cache-dir -U $VERSION torchvision torchaudio tor
 
 RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/accelerate@main#egg=accelerate
 
-# needed in bnb and awq
-RUN python3 -m pip install --no-cache-dir einops
-
-# Add bitsandbytes for mixed int8 testing
-RUN python3 -m pip install --no-cache-dir bitsandbytes
-
-# Add gptqmodel for gtpq quantization testing, installed from source for pytorch==2.6.0 compatibility
-RUN python3 -m pip install lm_eval
-RUN git clone https://github.com/ModelCloud/GPTQModel.git && cd GPTQModel && pip install -v . --no-build-isolation
-
 # Add optimum for gptq quantization testing
 RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/optimum@main#egg=optimum
 
 # Add PEFT
 RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/peft@main#egg=peft
 
+# needed in bnb and awq
+RUN python3 -m pip install --no-cache-dir einops
+
+# Add bitsandbytes
+RUN python3 -m pip install --no-cache-dir bitsandbytes
+
+# # Add gptqmodel
+# RUN python3 -m pip install --no-cache-dir gptqmodel
+
 # Add hqq for quantization testing
 RUN python3 -m pip install --no-cache-dir hqq
Repository: facebook/react
Pull request: Use explicit git hash length in version string


This avoids potential differences between Git versions.

Having a guarantee unique hash isn't neccessary as it's just informational and we have the date in the version string as well.


Changed files:
filename: scripts/rollup/build-all-release-channels.js
patch: @@ -19,9 +19,7 @@ const {
 // Runs the build script for both stable and experimental release channels,
 // by configuring an environment variable.
 
-const sha = String(
-  spawnSync('git', ['show', '-s', '--no-show-signature', '--format=%h']).stdout
-).trim();
+const sha = String(spawnSync('git', ['rev-parse', 'HEAD']).stdout).slice(0, 8);
 
 let dateString = String(
   spawnSync('git', [
Repository: denoland/deno
Pull request: fix(repl): handle EOF gracefully in JSON REPL mode

Closes the JSON REPL cleanly when the IPC pipe is closed (e.g. ctrl+d / EOF) instead of printing `error: unexpected end of file` and exiting with code 1.


Changed files:
filename: cli/tools/repl/mod.rs
patch: @@ -310,15 +310,25 @@ async fn run_json(mut repl_session: ReplSession) -> Result<i32, AnyError> {
 
   loop {
     let mut line_fut = std::pin::pin!(async {
-      let len = receiver.read_u32_le().await?;
-      let mut buf = vec![0; len as _];
+      let len = match receiver.read_u32_le().await {
+        Ok(n) => n,
+        // Treat the case of 0-byte input as "expected" EOF
+        Err(e) if e.kind() == io::ErrorKind::UnexpectedEof => {
+          return Ok(None);
+        }
+        Err(e) => return Err(e),
+      };
+      let mut buf = vec![0; len as usize];
       receiver.read_exact(&mut buf).await?;
-      Ok::<_, AnyError>(buf)
+      Ok(Some(buf))
     });
     let mut poll_worker = true;
     let line = loop {
       tokio::select! {
-        line = &mut line_fut => break line?,
+        line = &mut line_fut => match line? {
+          Some(line) => break line,
+          None => return Ok(repl_session.worker.exit_code()),
+        },
         _ = repl_session.run_event_loop(), if poll_worker => {
           poll_worker = false;
           continue;

filename: tests/specs/repl/json/test.out
patch: @@ -2,3 +2,4 @@
 hello
 { type: "RunSuccess", output: "2" }
 { type: "RunFailure", text: "Uncaught" }
+0

filename: tests/specs/repl/json/test.ts
patch: @@ -3,6 +3,7 @@ const {
   getExtraPipeRids,
   writableStreamForRid,
   readableStreamForRid,
+  core: { close },
 } = Deno[Deno.internal];
 
 const command = new Deno.Command(Deno.execPath(), {
@@ -99,3 +100,8 @@ const readable = readableStreamForRid(pipeRid);
   console.log(JSON.parse(new TextDecoder().decode(value)));
   reader.releaseLock();
 }
+
+// Test EOF (ctrl+d): closing the underlying socket should cause a clean exit
+close(pipeRid);
+const status = await child.status;
+console.log(status.code);
Repository: huggingface/transformers
Pull request: Fix 8bit bnb loading

# What does this PR do?

This PR fixes some code related to 8-bit models that was changed during a recent refactor https://github.com/huggingface/transformers/pull/41138. The issue was that `SCB` value was actually modified when moving the param from cpu to cuda. 

Changed files:
filename: src/transformers/quantizers/quantizer_bnb_8bit.py
patch: @@ -185,7 +185,6 @@ def create_quantized_param(
                 "Detected int8 weights but the version of bitsandbytes is not compatible with int8 serialization. "
                 "Make sure to download the latest `bitsandbytes` version. `pip install --upgrade bitsandbytes`."
             )
-
         # Those 2 can only happen when self.pre_quantized == True
         if tensor_name == "SCB":
             setattr(module.weight, "SCB", param_value.to(target_device))
@@ -202,8 +201,11 @@ def create_quantized_param(
         old_value = getattr(module, tensor_name)
         kwargs = old_value.__dict__
         kwargs.pop("_is_hf_initialized", None)
+        # Need to pop SCB and reset it because of bnb internals that modifies its value when switching devices ...
+        SCB = kwargs.pop("SCB", None)
         new_value = bnb.nn.Int8Params(param_value.to("cpu"), requires_grad=False, **kwargs).to(target_device)
-
+        if SCB is not None:
+            setattr(new_value, "SCB", SCB)
         # Set it to the module
         module._parameters[tensor_name] = new_value