helloadhavan/github_issues huggingface dataset:
Repository: ggml-org/llama.cpp
Pull request: common : use std::string_view now that we target c++17

We no longer need this polyfill.

Changed files:
filename: common/json-schema-to-grammar.cpp
patch: @@ -41,49 +41,6 @@ static std::string build_repetition(const std::string & item_rule, int min_items
     return result;
 }
 
-/* Minimalistic replacement for std::string_view, which is only available from C++17 onwards */
-class string_view {
-    const std::string & _str;
-    const size_t _start;
-    const size_t _end;
-public:
-    string_view(const std::string & str, size_t start = 0, size_t end  = std::string::npos) : _str(str), _start(start), _end(end == std::string::npos ? str.length() : end) {}
-
-    size_t size() const {
-        return _end - _start;
-    }
-
-    size_t length() const {
-        return size();
-    }
-
-    operator std::string() const {
-        return str();
-    }
-
-    std::string str() const {
-        return _str.substr(_start, _end - _start);
-    }
-
-    string_view substr(size_t pos, size_t len = std::string::npos) const {
-        return string_view(_str, _start + pos, len == std::string::npos ? _end : _start + pos + len);
-    }
-
-    char operator[](size_t pos) const {
-        auto index = _start + pos;
-        if (index >= _end) {
-            throw std::out_of_range("string_view index out of range");
-        }
-        return _str[_start + pos];
-    }
-
-    bool operator==(const string_view & other) const {
-        std::string this_str = *this;
-        std::string other_str = other;
-        return this_str == other_str;
-    }
-};
-
 static void _build_min_max_int(int min_value, int max_value, std::stringstream & out, int decimals_left = 16, bool top_level = true) {
     auto has_min = min_value != std::numeric_limits<int>::min();
     auto has_max = max_value != std::numeric_limits<int>::max();
@@ -112,14 +69,14 @@ static void _build_min_max_int(int min_value, int max_value, std::stringstream &
         }
         out << "}";
     };
-    std::function<void(const string_view &, const string_view &)> uniform_range =
-        [&](const string_view & from, const string_view & to) {
+    std::function<void(const std::string_view &, const std::string_view &)> uniform_range =
+        [&](const std::string_view & from, const std::string_view & to) {
             size_t i = 0;
             while (i < from.length() && i < to.length() && from[i] == to[i]) {
                 i++;
             }
             if (i > 0) {
-                out << "\"" << from.substr(0, i).str() << "\"";
+                out << "\"" << from.substr(0, i) << "\"";
             }
             if (i < from.length() && i < to.length()) {
                 if (i > 0) {
Repository: ggml-org/llama.cpp
Pull request: gguf-py : fix Qwen3-Embedding eos token

Qwen3-Embedding sets a different EOS token than defined in `tokenizer_config.json` using `TemplateProcessing`, so we override that if detected (and try to shift EOS onto EOT/EOM just in case).

Changed files:
filename: gguf-py/gguf/vocab.py
patch: @@ -197,6 +197,16 @@ def _try_load_from_tokenizer_json(self, path: Path) -> bool:
                         if special_last := tmpl_single[-1].get('SpecialToken', {}).get('id'):
                             if not tokenizer_config:
                                 special_eos = special_last
+                            elif special_last != special_eos:
+                                if 'eot' not in self.special_token_types:
+                                    self.special_token_types = tuple(self.special_token_types) + ('eot', )
+                                    tokenizer_config['eot_token'] = special_eos
+                                elif 'eom' not in self.special_token_types:
+                                    self.special_token_types = tuple(self.special_token_types) + ('eom', )
+                                    tokenizer_config['eom_token'] = special_eos
+                                else:
+                                    logger.warning(f'Overriding EOS token {special_eos!r} with {special_last!r} without EOT/EOM fallback!')
+                                tokenizer_config['eos_token'] = special_eos = special_last
                             self.add_special_token['eos'] = True if special_last == special_eos else False
                             if special_last != special_eos:
                                 logger.warning(f'Unknown trailing special token {special_last!r} in TemplateProcessing<single>')
Repository: facebook/react
Pull request: devtools: Fix typo from directores to directories

The Overview documents had a small typo.
- packages/react-devtools-core/README.md



Changed files:
filename: packages/react-devtools-core/README.md
patch: @@ -90,7 +90,7 @@ Set the DOM element DevTools UI should be rendered into on initialization.
 _Optional_ callback to be notified when DevTools `WebSocket` closes (or errors).
 
 #### `setProjectRoots(roots: Array<string>)`
-_Optional_ set of root directores for source files. These roots can be used to open an inspected component's source code using an IDE.
+_Optional_ set of root directories for source files. These roots can be used to open an inspected component's source code using an IDE.
 
 #### `setStatusListener(callback: Function)`
 _Optional_ callback to be notified of socket server events (e.g. initialized, errored, connected).
Repository: huggingface/transformers
Pull request: Fix HybridChunedCache & Llama4

# What does this PR do?

As per the title!
It aligns HybridChunkedCache on what was done in https://github.com/huggingface/transformers/pull/37972 (i.e. simply take the min between max_len and window), which was causing lengths mismatches with llama4 in `get_mask_sizes` with the default HybridChunkedCache!


Changed files:
filename: src/transformers/cache_utils.py
patch: @@ -1967,7 +1967,8 @@ def __init__(
         else:
             self.sliding_window = config.sliding_window
         self.max_cache_len = max_cache_len
-        self._sliding_window_max_len = min(self.sliding_window, max_cache_len)
+        # Sliding layers can't be larger than the overall max cache len
+        self.sliding_window = min(config.sliding_window, self.max_cache_len)
         self.max_batch_size = max_batch_size
         self.head_dim = getattr(config, "head_dim", config.hidden_size // config.num_attention_heads)
         self._dtype = dtype
@@ -1989,7 +1990,7 @@ def initialise_cache_layer(self, layer_idx, key_states):
         num_key_value_heads = key_states.shape[1]
         device = key_states.device
         global_cache_shape = (self.max_batch_size, num_key_value_heads, self.max_cache_len, self.head_dim)
-        sliding_cache_shape = (self.max_batch_size, num_key_value_heads, self._sliding_window_max_len, self.head_dim)
+        sliding_cache_shape = (self.max_batch_size, num_key_value_heads, self.sliding_window, self.head_dim)
         # Note: `mark_static_address` is used to tag the cache as an fixed data pointer, preventing cuda graph
         # breaks when updating the cache.
         cache_shape = sliding_cache_shape if self.is_sliding[layer_idx] else global_cache_shape
@@ -2163,7 +2164,7 @@ def initialise_cache_layer(self, layer_idx, key_states):
         device = key_states.device if self.is_sliding[layer_idx] else self.offload_device
         pin_memory = not self.is_sliding[layer_idx]
         global_cache_shape = (self.max_batch_size, num_key_value_heads, self.max_cache_len, self.head_dim)
-        sliding_cache_shape = (self.max_batch_size, num_key_value_heads, self._sliding_window_max_len, self.head_dim)
+        sliding_cache_shape = (self.max_batch_size, num_key_value_heads, self.sliding_window, self.head_dim)
         # Note: `mark_static_address` is used to tag the cache as an fixed data pointer, preventing cuda graph
         # breaks when updating the cache.
         cache_shape = sliding_cache_shape if self.is_sliding[layer_idx] else global_cache_shape
Repository: nodejs/node
Pull request: stream: fix typo in `ReadableStreamBYOBReader.readIntoRequests`

The `readIntoRequests` field was misspelled as `requestIntoRequests`. This didn't break anything of importance, but it did show up when inspecting the `ReadableStreamBYOBReader`:
```
$ node
> rs = new ReadableStream({ type: "bytes" })
> reader = rs.getReader({ mode: "byob" })
ReadableStreamBYOBReader {
  stream: ReadableStream { locked: true, state: 'readable', supportsBYOB: true },
  requestIntoRequests: 0,
  close: Promise {
    <pending>,
    [Symbol(async_id_symbol)]: 192,
    [Symbol(trigger_async_id_symbol)]: 6
  }
}
> reader.read(new Uint8Array(1))
> reader
ReadableStreamBYOBReader {
  stream: ReadableStream { locked: true, state: 'readable', supportsBYOB: true },
  requestIntoRequests: 0,
  close: Promise {
    <pending>,
    [Symbol(async_id_symbol)]: 192,
    [Symbol(trigger_async_id_symbol)]: 6
  }
}
```
Note that `requestIntoRequests` always stays 0, whereas it should be 1 because of the pending `read(view)` request.

Changed files:
filename: lib/internal/webstreams/readablestream.js
patch: @@ -925,7 +925,7 @@ class ReadableStreamBYOBReader {
       throw new ERR_INVALID_ARG_TYPE('stream', 'ReadableStream', stream);
     this[kState] = {
       stream: undefined,
-      requestIntoRequests: [],
+      readIntoRequests: [],
       close: {
         promise: undefined,
         resolve: undefined,
@@ -1031,7 +1031,7 @@ class ReadableStreamBYOBReader {
   [kInspect](depth, options) {
     return customInspect(depth, options, this[kType], {
       stream: this[kState].stream,
-      requestIntoRequests: this[kState].requestIntoRequests.length,
+      readIntoRequests: this[kState].readIntoRequests.length,
       close: this[kState].close.promise,
     });
   }
Repository: ggml-org/llama.cpp
Pull request: gguf-py : fix TemplateProcessing pair when bos/eos is missing

Fixes incorrect slicing when there's no bos and/or eos token.

Changed files:
filename: gguf-py/gguf/vocab.py
patch: @@ -201,9 +201,9 @@ def _try_load_from_tokenizer_json(self, path: Path) -> bool:
                             if special_last != special_eos:
                                 logger.warning(f'Unknown trailing special token {special_last!r} in TemplateProcessing<single>')
                     if tmpl_pair:
-                        seq_start = 1 if tmpl_pair[0].get('SpecialToken', {}).get('id') == special_first else 0
-                        seq_stop = -1 if tmpl_pair[-1].get('SpecialToken', {}).get('id') == special_last else None
-                        if seq_start == 0 or seq_stop is None:
+                        seq_start = 1 if special_first and tmpl_pair[0].get('SpecialToken', {}).get('id') == special_first else 0
+                        seq_stop = -1 if special_last and tmpl_pair[-1].get('SpecialToken', {}).get('id') == special_last else None
+                        if (special_first and seq_start == 0) or (special_last and seq_stop is None):
                             logger.warning('TemplateProcessing<single> leading/trailing special tokens do not match TemplateProcessing<pair>')
                         if tmpl_pair := tmpl_pair[slice(seq_start, seq_stop)]:
                             tmpl_a = tmpl_pair[0].get('Sequence', {}).get('id')
Repository: electron/electron
Pull request: fix: ensure `utilityProcess` only emits one 'exit' event

Backport of #44243

See that PR for details.


Notes: Fixed an issue where the `exit` event could be emitted twice from the `utilityProcess`.


Changed files:
filename: shell/browser/api/electron_api_utility_process.cc
patch: @@ -246,12 +246,16 @@ void UtilityProcessWrapper::OnServiceProcessLaunch(
 }
 
 void UtilityProcessWrapper::HandleTermination(uint64_t exit_code) {
+  // HandleTermination is called from multiple callsites,
+  // we need to ensure we only process it for the first callsite.
+  if (terminated_)
+    return;
+  terminated_ = true;
+
   if (pid_ != base::kNullProcessId)
     GetAllUtilityProcessWrappers().Remove(pid_);
   CloseConnectorPort();
-
   EmitWithoutEvent("exit", exit_code);
-
   Unpin();
 }
 
@@ -290,13 +294,8 @@ void UtilityProcessWrapper::CloseConnectorPort() {
 }
 
 void UtilityProcessWrapper::Shutdown(uint64_t exit_code) {
-  if (pid_ != base::kNullProcessId)
-    GetAllUtilityProcessWrappers().Remove(pid_);
   node_service_remote_.reset();
-  CloseConnectorPort();
-  // Emit 'exit' event
-  EmitWithoutEvent("exit", exit_code);
-  Unpin();
+  HandleTermination(exit_code);
 }
 
 void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {

filename: shell/browser/api/electron_api_utility_process.h
patch: @@ -98,6 +98,7 @@ class UtilityProcessWrapper final
   int stdout_read_fd_ = -1;
   int stderr_read_fd_ = -1;
   bool connector_closed_ = false;
+  bool terminated_ = false;
   std::unique_ptr<mojo::Connector> connector_;
   blink::MessagePortDescriptor host_port_;
   mojo::Remote<node::mojom::NodeService> node_service_remote_;

filename: spec/api-utility-process-spec.ts
patch: @@ -58,10 +58,20 @@ describe('utilityProcess module', () => {
       await once(child, 'spawn');
     });
 
-    it('emits \'exit\' when child process exits gracefully', async () => {
+    it('emits \'exit\' when child process exits gracefully', (done) => {
       const child = utilityProcess.fork(path.join(fixturesPath, 'empty.js'));
-      const [code] = await once(child, 'exit');
-      expect(code).to.equal(0);
+      child.on('exit', (code) => {
+        expect(code).to.equal(0);
+        done();
+      });
+    });
+
+    it('emits \'exit\' when the child process file does not exist', (done) => {
+      const child = utilityProcess.fork('nonexistent');
+      child.on('exit', (code) => {
+        expect(code).to.equal(1);
+        done();
+      });
     });
 
     ifit(!isWindows32Bit)('emits the correct error code when child process exits nonzero', async () => {
Repository: vercel/next.js
Pull request: fix(next-swc): Fix react compiler usefulness detector (15.3)

### What?

Fix the usefulness detector for the React Compiler

### Why?

JSX was also a target of the React Compiler



Closes PACK-4666

Changed files:
filename: crates/next-custom-transforms/src/react_compiler.rs
patch: @@ -1,5 +1,5 @@
 use swc_core::ecma::{
-    ast::{Callee, Expr, FnDecl, FnExpr, Pat, Program, ReturnStmt, VarDeclarator},
+    ast::{Callee, Expr, FnDecl, FnExpr, Pat, Program, ReturnStmt, Stmt, VarDeclarator},
     visit::{Visit, VisitWith},
 };
 
@@ -34,6 +34,25 @@ impl Visit for Finder {
         node.visit_children_with(self);
     }
 
+    fn visit_expr(&mut self, node: &Expr) {
+        if self.found {
+            return;
+        }
+        if matches!(
+            node,
+            Expr::JSXMember(..)
+                | Expr::JSXNamespacedName(..)
+                | Expr::JSXEmpty(..)
+                | Expr::JSXElement(..)
+                | Expr::JSXFragment(..)
+        ) {
+            self.found = true;
+            return;
+        }
+
+        node.visit_children_with(self);
+    }
+
     fn visit_fn_decl(&mut self, node: &FnDecl) {
         let old = self.is_interested;
         self.is_interested = node.ident.sym.starts_with("use")
@@ -47,7 +66,7 @@ impl Visit for Finder {
     fn visit_fn_expr(&mut self, node: &FnExpr) {
         let old = self.is_interested;
 
-        self.is_interested = node.ident.as_ref().is_some_and(|ident| {
+        self.is_interested |= node.ident.as_ref().is_some_and(|ident| {
             ident.sym.starts_with("use") || ident.sym.starts_with(|c: char| c.is_ascii_uppercase())
         });
 
@@ -69,6 +88,13 @@ impl Visit for Finder {
         node.visit_children_with(self);
     }
 
+    fn visit_stmt(&mut self, node: &Stmt) {
+        if self.found {
+            return;
+        }
+        node.visit_children_with(self);
+    }
+
     fn visit_var_declarator(&mut self, node: &VarDeclarator) {
         let old = self.is_interested;
Repository: nodejs/node
Pull request: doc: update history of stream.Readable.toWeb()

Adds the exact version for when the 2nd `options` argument is available.

Refs: https://github.com/nodejs/node/pull/43515


Changed files:
filename: doc/api/stream.md
patch: @@ -3138,6 +3138,11 @@ Returns whether the stream is readable.
 
 <!-- YAML
 added: v17.0.0
+changes:
+  - version:
+    - v18.7.0
+    pr-url: https://github.com/nodejs/node/pull/43515
+    description: include strategy options on Readable.
 -->
 
 > Stability: 1 - Experimental
Repository: denoland/deno
Pull request: fix: don't warn on ignored signals on windows

Closes #26183.

The warnings are super noisy and not actionable for the user

Changed files:
filename: ext/node/polyfills/process.ts
patch: @@ -520,9 +520,7 @@ Process.prototype.on = function (
     } else if (
       event !== "SIGBREAK" && event !== "SIGINT" && Deno.build.os === "windows"
     ) {
-      // Ignores all signals except SIGBREAK and SIGINT on windows.
-      // deno-lint-ignore no-console
-      console.warn(`Ignoring signal "${event}" on Windows`);
+      // TODO(#26331): Ignores all signals except SIGBREAK and SIGINT on windows.
     } else {
       EventEmitter.prototype.on.call(this, event, listener);
       Deno.addSignalListener(event as Deno.Signal, listener);

filename: tests/unit_node/process_test.ts
patch: @@ -25,7 +25,6 @@ import {
   assertThrows,
   fail,
 } from "@std/assert";
-import { assertSpyCall, assertSpyCalls, spy } from "@std/testing/mock";
 import { stripAnsiCode } from "@std/fmt/colors";
 import * as path from "@std/path";
 import { delay } from "@std/async/delay";
@@ -239,33 +238,6 @@ Deno.test({
   },
 });
 
-Deno.test({
-  name: "process.on - ignored signals on windows",
-  ignore: Deno.build.os !== "windows",
-  fn() {
-    const ignoredSignals = ["SIGHUP", "SIGUSR1", "SIGUSR2"];
-
-    for (const signal of ignoredSignals) {
-      using consoleSpy = spy(console, "warn");
-      const handler = () => {};
-      process.on(signal, handler);
-      process.off(signal, handler);
-      assertSpyCall(consoleSpy, 0, {
-        args: [`Ignoring signal "${signal}" on Windows`],
-      });
-    }
-
-    {
-      using consoleSpy = spy(console, "warn");
-      const handler = () => {};
-      process.on("SIGTERM", handler);
-      process.off("SIGTERM", handler);
-      // No warning is made for SIGTERM
-      assertSpyCalls(consoleSpy, 0);
-    }
-  },
-});
-
 Deno.test(
   { permissions: { run: true, read: true } },
   async function processKill() {
Repository: huggingface/transformers
Pull request: Fix tp error when torch distributed is already initialized

# What does this PR do?

This PR fixes an issue when the torch distributed is already initialized. current_device is referenced before assignment. 

Getting the following traceback in accelerate when testing tp training. 
```
[rank1]:     tp_plan, device_map, device_mesh = initialize_tensor_parallelism(tp_plan, tp_size=None)
[rank1]:   File "/home/marc/transformers/src/transformers/integrations/tensor_parallel.py", line 79, in initialize_tensor_parallelism
[rank1]:     index = current_device.current_device() if device_type != "cpu" else None
[rank1]: UnboundLocalError: local variable 'current_device' referenced before assignment
```


Changed files:
filename: src/transformers/integrations/tensor_parallel.py
patch: @@ -52,6 +52,7 @@ def initialize_tensor_parallelism(tp_plan, tp_size=None):
 
     # Detect the accelerator on the machine. If no accelerator is available, it returns CPU.
     device_type = torch._C._get_accelerator().type
+    current_device = getattr(torch, device_type)
     if not torch.distributed.is_initialized():
         try:
             rank = int(os.environ["RANK"])
@@ -73,6 +74,9 @@ def initialize_tensor_parallelism(tp_plan, tp_size=None):
                 "We tried to initialize torch.distributed for you, but it failed. Make "
                 "sure you init torch distributed in your script to use `tp_plan='auto'`."
             ) from e
+
+    if device_type != "cpu":
+        current_device.set_device(int(os.environ["LOCAL_RANK"]))
     index = current_device.current_device() if device_type != "cpu" else None
     tp_device = torch.device(device_type, index)
Repository: electron/electron
Pull request: fix: ensure `utilityProcess` only emits one 'exit' event

Backport of #44243

See that PR for details.


Notes: Fixed an issue where the `exit` event could be emitted twice from the `utilityProcess`.


Changed files:
filename: shell/browser/api/electron_api_utility_process.cc
patch: @@ -247,12 +247,16 @@ void UtilityProcessWrapper::OnServiceProcessLaunch(
 }
 
 void UtilityProcessWrapper::HandleTermination(uint64_t exit_code) {
+  // HandleTermination is called from multiple callsites,
+  // we need to ensure we only process it for the first callsite.
+  if (terminated_)
+    return;
+  terminated_ = true;
+
   if (pid_ != base::kNullProcessId)
     GetAllUtilityProcessWrappers().Remove(pid_);
   CloseConnectorPort();
-
   EmitWithoutEvent("exit", exit_code);
-
   Unpin();
 }
 
@@ -292,13 +296,8 @@ void UtilityProcessWrapper::CloseConnectorPort() {
 }
 
 void UtilityProcessWrapper::Shutdown(uint64_t exit_code) {
-  if (pid_ != base::kNullProcessId)
-    GetAllUtilityProcessWrappers().Remove(pid_);
   node_service_remote_.reset();
-  CloseConnectorPort();
-  // Emit 'exit' event
-  EmitWithoutEvent("exit", exit_code);
-  Unpin();
+  HandleTermination(exit_code);
 }
 
 void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {

filename: shell/browser/api/electron_api_utility_process.h
patch: @@ -105,6 +105,7 @@ class UtilityProcessWrapper final
   int stdout_read_fd_ = -1;
   int stderr_read_fd_ = -1;
   bool connector_closed_ = false;
+  bool terminated_ = false;
   std::unique_ptr<mojo::Connector> connector_;
   blink::MessagePortDescriptor host_port_;
   mojo::Receiver<node::mojom::NodeServiceClient> receiver_{this};

filename: spec/api-utility-process-spec.ts
patch: @@ -58,10 +58,20 @@ describe('utilityProcess module', () => {
       await once(child, 'spawn');
     });
 
-    it('emits \'exit\' when child process exits gracefully', async () => {
+    it('emits \'exit\' when child process exits gracefully', (done) => {
       const child = utilityProcess.fork(path.join(fixturesPath, 'empty.js'));
-      const [code] = await once(child, 'exit');
-      expect(code).to.equal(0);
+      child.on('exit', (code) => {
+        expect(code).to.equal(0);
+        done();
+      });
+    });
+
+    it('emits \'exit\' when the child process file does not exist', (done) => {
+      const child = utilityProcess.fork('nonexistent');
+      child.on('exit', (code) => {
+        expect(code).to.equal(1);
+        done();
+      });
     });
 
     ifit(!isWindows32Bit)('emits the correct error code when child process exits nonzero', async () => {
Repository: ggml-org/llama.cpp
Pull request: Fix Llama 4 conversion

See https://github.com/ggml-org/llama.cpp/issues/14237



Changed files:
filename: convert_hf_to_gguf.py
patch: @@ -2193,7 +2193,7 @@ def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iter
                 name += ".weight"
             if "multi_modal_projector.linear_1" in name:
                 # despite the name with number postfix, this is a single fully connected layer
-                return [(gguf.TENSOR_NAMES[gguf.MODEL_TENSOR.V_MMPROJ_FC], data_torch)]
+                return [(gguf.TENSOR_NAMES[gguf.MODEL_TENSOR.V_MMPROJ_FC] + '.weight', data_torch)]
             return [(self.map_tensor_name(name), data_torch)]
         return []