helloadhavan/github_issues huggingface dataset:
Repository: ggml-org/llama.cpp
Pull request: musa: fix build warning (unused variable)

*Make sure to read the [contributing guidelines](https://github.com/ggml-org/llama.cpp/blob/master/CONTRIBUTING.md) before submitting a PR*

Fix a new warning detected by our internal CI.

Changed files:
filename: ggml/src/ggml-cuda/ggml-cuda.cu
patch: @@ -2664,7 +2664,9 @@ static void evaluate_and_capture_cuda_graph(ggml_backend_cuda_context * cuda_ctx
                                ggml_backend_buft_is_cuda_split(node->src[j]->buffer->buft) || (integrated && ggml_backend_buft_is_cuda_host(node->src[j]->buffer->buft)));
                     }
                 }
-#endif
+#else
+                GGML_UNUSED(integrated);
+#endif // NDEBUG
 
                 bool ok = ggml_cuda_compute_forward(*cuda_ctx, node);
                 if (!ok) {
Repository: electron/electron
Pull request: fix: -Wunsafe-buffer-usage warnings in GetNextZoomLevel() (#44149)

Manual backport of #44149 to 31-x-y. See that PR for details.

Notes: none

Changed files:
filename: shell/browser/ui/inspectable_web_contents.cc
patch: @@ -124,22 +124,20 @@ void SetZoomLevelForWebContents(content::WebContents* web_contents,
   content::HostZoomMap::SetZoomLevel(web_contents, level);
 }
 
-double GetNextZoomLevel(const double level, const bool out) {
+double GetNextZoomLevel(double level, bool out) {
   static constexpr std::array<double, 16U> kPresetFactors{
       0.25, 0.333, 0.5,  0.666, 0.75, 0.9, 1.0, 1.1,
       1.25, 1.5,   1.75, 2.0,   2.5,  3.0, 4.0, 5.0};
-  static constexpr auto kBegin = kPresetFactors.begin();
-  static constexpr auto kEnd = kPresetFactors.end();
+  static constexpr size_t size = std::size(kPresetFactors);
 
   const double factor = blink::PageZoomLevelToZoomFactor(level);
-  auto matches = [=](auto val) {
-    return blink::PageZoomValuesEqual(factor, val);
-  };
-  if (auto iter = std::find_if(kBegin, kEnd, matches); iter != kEnd) {
-    if (out && iter != kBegin)
-      return blink::PageZoomFactorToZoomLevel(*--iter);
-    if (!out && ++iter != kEnd)
-      return blink::PageZoomFactorToZoomLevel(*iter);
+  for (size_t i = 0U; i < size; ++i) {
+    if (!blink::PageZoomValuesEqual(kPresetFactors[i], factor))
+      continue;
+    if (out && i > 0U)
+      return blink::PageZoomFactorToZoomLevel(kPresetFactors[i - 1U]);
+    if (!out && i + 1U < size)
+      return blink::PageZoomFactorToZoomLevel(kPresetFactors[i + 1U]);
   }
   return level;
 }
Repository: huggingface/transformers
Pull request: Fix Llama4

# What does this PR do?

As per the title. It would currently fail with `RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.`, at least when using TP.

Unfortunately, flex block mask and generate got broken as well, but this will be solved by the mask refactor. Solving it here would involve a lot of duplicated efforts.

Changed files:
filename: src/transformers/models/llama4/modeling_llama4.py
patch: @@ -144,7 +144,7 @@ def __init__(self, config):
 
     def forward(self, hidden_states):
         batch, seq_len, hidden_dim = hidden_states.shape
-        hidden_states = hidden_states.view(-1, self.hidden_dim)
+        hidden_states = hidden_states.reshape(-1, self.hidden_dim)
         router_logits = self.router(hidden_states)
         tokens_per_expert = batch * seq_len
Repository: vercel/next.js
Pull request: [backport]: properly gate segmentCache branch in base-server

In 15.1, this branch should be a no-op when PPR is not enabled, because `collectSegmentData` is [gated](https://github.com/vercel/next.js/blob/69afa37323610c9bbfbecd22f0194f2f299d5a6c/packages/next/src/server/app-render/app-render.tsx#L4008) on `isRoutePPREnabled`. 

This also sets a no-store cache header when we respond with a 204 to align with intended behavior. 

Changed files:
filename: packages/next/src/server/base-server.ts
patch: @@ -3054,7 +3054,11 @@ export default abstract class Server<
       }
     )
 
-    if (isPrefetchRSCRequest && typeof segmentPrefetchHeader === 'string') {
+    if (
+      isRoutePPREnabled &&
+      isPrefetchRSCRequest &&
+      typeof segmentPrefetchHeader === 'string'
+    ) {
       // This is a prefetch request issued by the client Segment Cache. These
       // should never reach the application layer (lambda). We should either
       // respond from the cache (HIT) or respond with 204 No Content (MISS).
@@ -3090,15 +3094,14 @@ export default abstract class Server<
       // segment), we should *always* respond with a tree, even if PPR
       // is disabled.
       res.statusCode = 204
-      if (isRoutePPREnabled) {
-        // Set a header to indicate that PPR is enabled for this route. This
-        // lets the client distinguish between a regular cache miss and a cache
-        // miss due to PPR being disabled.
-        // NOTE: Theoretically, when PPR is enabled, there should *never* be
-        // a cache miss because we should generate a fallback route. So this
-        // is mostly defensive.
-        res.setHeader(NEXT_DID_POSTPONE_HEADER, '1')
-      }
+
+      // Set a header to indicate that PPR is enabled for this route. This
+      // lets the client distinguish between a regular cache miss and a cache
+      // miss due to PPR being disabled.
+      // NOTE: Theoretically, when PPR is enabled, there should *never* be
+      // a cache miss because we should generate a fallback route. So this
+      // is mostly defensive.
+      res.setHeader(NEXT_DID_POSTPONE_HEADER, '1')
       return {
         type: 'rsc',
         body: RenderResult.fromStatic(''),

filename: test/e2e/app-dir/segment-cache/incremental-opt-in/segment-cache-incremental-opt-in.test.ts
patch: @@ -1,6 +1,7 @@
 import { nextTestSetup } from 'e2e-utils'
 
-describe('segment cache (incremental opt in)', () => {
+// Backport Note: This test is skipped as it's only currently usable in the experimental release channel.
+describe.skip('segment cache (incremental opt in)', () => {
   const { next, isNextDev, skipped } = nextTestSetup({
     files: __dirname,
     skipDeployment: true,

filename: test/e2e/pages-performance-mark/pages/_document.js
patch: @@ -3,7 +3,6 @@ import { Html, Head, Main, NextScript } from 'next/document'
 export default function Document() {
   return (
     <Html>
-      <Head />
       <Head />
       <body>
         <Main />
Repository: ggml-org/llama.cpp
Pull request: common : suggest --jinja when autodetection fails

In case the user does not know about the `--jinja` option and we don't support/detect the template in legacy, it's nice to be nudged in the correct direction.

Changed files:
filename: common/chat.cpp
patch: @@ -1838,7 +1838,7 @@ static common_chat_params common_chat_templates_apply_legacy(
     if (res < 0) {
         // if the custom "tmpl" is not supported, we throw an error
         // this is a bit redundant (for good), since we're not sure if user validated the custom template with llama_chat_verify_template()
-        throw std::runtime_error("this custom template is not supported");
+        throw std::runtime_error("this custom template is not supported, try using --jinja");
     }
 
     // if it turns out that our buffer is too small, we resize it
Repository: ggml-org/llama.cpp
Pull request: server : fix incorrect usage of llama_get_embeddings()

cont #14208
fix #14223

Changed files:
filename: include/llama.h
patch: @@ -965,6 +965,7 @@ extern "C" {
     LLAMA_API int32_t llama_n_threads_batch(struct llama_context * ctx);
 
     // Set whether the context outputs embeddings or not
+    // TODO: rename to avoid confusion with llama_get_embeddings()
     LLAMA_API void llama_set_embeddings(struct llama_context * ctx, bool embeddings);
 
     // Set whether to use causal attention or not

filename: tools/server/server.cpp
patch: @@ -1358,6 +1358,14 @@ struct server_slot {
         return server_task_type_need_logits(task_type);
     }
 
+    // if the context does not have a memory module then all embeddings have to be computed within a single ubatch
+    // also we cannot split if the pooling would require any past tokens
+    bool can_split() const {
+        return
+            !need_embd() ||
+            (llama_get_memory(ctx) && llama_pooling_type(ctx) == LLAMA_POOLING_TYPE_LAST);
+    }
+
     bool can_batch_with(server_slot & other_slot) const {
         return task_type == other_slot.task_type && are_lora_equal(lora, other_slot.lora);
     }
@@ -1929,14 +1937,6 @@ struct server_context {
         llama_batch_free(batch);
     }
 
-    // if the context does not have a memory module then all embeddings have to be computed within a single ubatch
-    // also we cannot split if the pooling would require any past tokens
-    bool can_split() const {
-        return
-            !llama_get_embeddings(ctx) ||
-            (llama_get_memory(ctx) && llama_pooling_type(ctx) == LLAMA_POOLING_TYPE_LAST);
-    }
-
     bool load_model(const common_params & params) {
         SRV_INF("loading model '%s'\n", params.model.path.c_str());
 
@@ -3130,7 +3130,7 @@ struct server_context {
                             continue;
                         }
 
-                        if (!can_split()) {
+                        if (!slot.can_split()) {
                             if (slot.n_prompt_tokens > n_ubatch) {
                                 slot.release();
                                 send_error(slot, "input is too large to process. increase the physical batch size", ERROR_TYPE_SERVER);
@@ -3273,7 +3273,7 @@ struct server_context {
                         slot.n_prompt_tokens_processed = 0;
                     }
 
-                    if (!can_split()) {
+                    if (!slot.can_split()) {
                         // cannot fit the prompt in the current batch - will try next iter
                         if (batch.n_tokens + slot.n_prompt_tokens > n_batch) {
                             continue;
Repository: huggingface/transformers
Pull request: Mamba2 remove unecessary test parameterization


Changed files:
filename: tests/models/mamba2/test_modeling_mamba2.py
patch: @@ -15,8 +15,6 @@
 
 import unittest
 
-from parameterized import parameterized
-
 from transformers import AutoTokenizer, Mamba2Config, is_torch_available
 from transformers.testing_utils import (
     Expectations,
@@ -362,14 +360,9 @@ def setUp(self):
         self.prompt = ("
Write a hello world program in C++.",)
 
     @require_read_token
-    @parameterized.expand(
-        [
-            (torch_device,),
-        ]
-    )
     @slow
     @require_torch
-    def test_simple_generate(self, device):
+    def test_simple_generate(self):
         """
         Simple generate test to avoid regressions.
         Note: state-spaces (cuda) implementation and pure torch implementation
@@ -380,9 +373,9 @@ def test_simple_generate(self, device):
         tokenizer.pad_token_id = tokenizer.eos_token_id
 
         model = Mamba2ForCausalLM.from_pretrained(self.model_id, torch_dtype=torch.bfloat16)
-        model.to(device)
+        model.to(torch_device)
         input_ids = tokenizer("
Write a hello world program in C++.
", return_tensors="pt")["input_ids"].to(
-            device
+            torch_device
         )
 
         out = model.generate(input_ids, do_sample=False, use_cache=True, max_new_tokens=30)
Repository: vercel/next.js
Pull request: [turbopack] Fix a buggy serializer

Because regexes aren't naively serializable, we use a simple alternate representation and then just re-parse them when deserializing.  A trivial bug was introduced in #78251  that has broken deserialization.  Fix that and add a unit test.

My only defense for such a silly mistake is that this was my first PR 🤦‍♂️



Closes PACK-4660

Changed files:
filename: Cargo.lock
patch: @@ -9508,6 +9508,7 @@ dependencies = [
  "regex",
  "regress",
  "serde",
+ "serde_json",
  "turbo-tasks",
  "turbo-tasks-build",
 ]

filename: turbopack/crates/turbo-esregex/Cargo.toml
patch: @@ -9,6 +9,7 @@ anyhow = { workspace = true }
 regex = { workspace = true }
 regress = { workspace = true }
 serde = { workspace = true }
+serde_json = { workspace = true }
 turbo-tasks = { workspace = true }
 
 [build-dependencies]

filename: turbopack/crates/turbo-esregex/src/lib.rs
patch: @@ -43,7 +43,7 @@ impl TryFrom<RegexForm> for EsRegex {
     type Error = anyhow::Error;
 
     fn try_from(value: RegexForm) -> std::result::Result<Self, Self::Error> {
-        EsRegex::new(&value.pattern, &value.pattern)
+        EsRegex::new(&value.pattern, &value.flags)
     }
 }
 
@@ -87,7 +87,7 @@ impl EsRegex {
                 'u' => applied_flags.push('u'),
                 // sticky search: not relevant for the regex itself
                 'y' => {}
-                _ => bail!("unsupported flag `{}` in regex", flag),
+                _ => bail!("unsupported flag `{flag}` in regex: `{pattern}` with flags: `{flags}`"),
             }
         }
 
@@ -129,6 +129,14 @@ impl EsRegex {
 mod tests {
     use super::{EsRegex, EsRegexImpl};
 
+    #[test]
+    fn round_trip_serialize() {
+        let regex = EsRegex::new("[a-z]", "i").unwrap();
+        let serialized = serde_json::to_string(&regex).unwrap();
+        let parsed = serde_json::from_str::<EsRegex>(&serialized).unwrap();
+        assert_eq!(regex, parsed);
+    }
+
     #[test]
     fn es_regex_matches_simple() {
         let regex = EsRegex::new("a", "").unwrap();
Repository: electron/electron
Pull request: fix: -Wunsafe-buffer-usage warnings when read()ing and write()ing integers

Backport of #44185

See that PR for details.


Notes: none.

Changed files:
filename: shell/browser/electron_browser_main_parts_posix.cc
patch: @@ -25,6 +25,18 @@ namespace electron {
 
 namespace {
 
+// write |ref|'s raw bytes to |fd|.
+template <typename T>
+void WriteValToFd(int fd, const T& ref) {
+  base::span<const uint8_t> bytes = base::byte_span_from_ref(ref);
+  while (!bytes.empty()) {
+    const ssize_t rv = HANDLE_EINTR(write(fd, bytes.data(), bytes.size()));
+    RAW_CHECK(rv >= 0);
+    const size_t n_bytes_written = rv >= 0 ? static_cast<size_t>(rv) : 0U;
+    bytes = bytes.subspan(n_bytes_written);
+  }
+}
+
 // See comment in |PreEarlyInitialization()|, where sigaction is called.
 void SIGCHLDHandler(int signal) {}
 
@@ -49,15 +61,7 @@ void GracefulShutdownHandler(int signal) {
   RAW_CHECK(g_pipe_pid == getpid());
   RAW_CHECK(g_shutdown_pipe_write_fd != -1);
   RAW_CHECK(g_shutdown_pipe_read_fd != -1);
-  size_t bytes_written = 0;
-  do {
-    int rv = HANDLE_EINTR(
-        write(g_shutdown_pipe_write_fd,
-              reinterpret_cast<const char*>(&signal) + bytes_written,
-              sizeof(signal) - bytes_written));
-    RAW_CHECK(rv >= 0);
-    bytes_written += rv;
-  } while (bytes_written < sizeof(signal));
+  WriteValToFd(g_shutdown_pipe_write_fd, signal);
 }
 
 // See comment in |PostCreateMainMessageLoop()|, where sigaction is called.
@@ -130,26 +134,33 @@ NOINLINE void ExitPosted() {
   sleep(UINT_MAX);
 }
 
-void ShutdownDetector::ThreadMain() {
-  base::PlatformThread::SetName("CrShutdownDetector");
-
-  int signal;
-  size_t bytes_read = 0;
-  do {
-    const ssize_t ret = HANDLE_EINTR(
-        read(shutdown_fd_, reinterpret_cast<char*>(&signal) + bytes_read,
-             sizeof(signal) - bytes_read));
-    if (ret < 0) {
+// read |sizeof(T)| raw bytes from |fd| and return the result
+template <typename T>
+[[nodiscard]] std::optional<T> ReadValFromFd(int fd) {
+  auto val = T{};
+  base::span<uint8_t> bytes = base::byte_span_from_ref(val);
+  while (!bytes.empty()) {
+    const ssize_t rv = HANDLE_EINTR(read(fd, bytes.data(), bytes.size()));
+    if (rv < 0) {
       NOTREACHED_IN_MIGRATION() << "Unexpected error: " << strerror(errno);
       ShutdownFDReadError();
-      break;
-    } else if (ret == 0) {
+      return {};
+    }
+    if (rv == 0) {
       NOTREACHED_IN_MIGRATION() << "Unexpected closure of shutdown pipe.";
       ShutdownFDClosedError();
-      break;
+      return {};
     }
-    bytes_read += ret;
-  } while (bytes_read < sizeof(signal));
+    const size_t n_bytes_read = static_cast<size_t>(rv);
+    bytes = bytes.subspan(n_bytes_read);
+  }
+  return val;
+}
+
+void ShutdownDetector::ThreadMain() {
+  base::PlatformThread::SetName("CrShutdownDetector");
+
+  const int signal = ReadValFromFd<int>(shutdown_fd_).value_or(0);
   VLOG(1) << "Handling shutdown for signal " << signal << ".";
 
   if (!task_runner_->PostTask(FROM_HERE,
Repository: vercel/next.js
Pull request: fix(test/e2e): Increase timeout of flaky basepath test

Reducing this timeout from the default of 3000ms to 2500ms makes the failure reproduce 100% of the time for me. Increasing it, I'm unable to reproduce the issue.

Tested with:

```
pnpm test-dev-turbo test/e2e/basepath/router-events.test.ts 'should use urls with basepath in router events for failed route change'
```

This appears fail sometimes with turbopack, but never with webpack. For some reason, webpack is faster at building these error pages? There's a few redirects that have to happen here, and if you get unlucky, those redirects might not finish within 3 seconds on a cold turbopack session.

Closes PACK-4652

Changed files:
filename: test/e2e/basepath/router-events.test.ts
patch: @@ -124,7 +124,7 @@ describe('basePath', () => {
             { shallow: false },
           ],
         ])
-      })
+      }, 10_000)
     } finally {
       await browser.close()
     }
Repository: huggingface/transformers
Pull request: fix dead flax links modeling_flax_pytorch_utils.py

Hey team—noticed a dead link, replaced it with a working URL

https://flax.readthedocs.io/en/latest/installation.html - old links
https://flax.readthedocs.io/en/latest/index.html#installation - new links

Changed files:
filename: src/transformers/modeling_flax_pytorch_utils.py
patch: @@ -66,7 +66,7 @@ def load_pytorch_checkpoint_in_flax_state_dict(
             except (ImportError, ModuleNotFoundError):
                 logger.error(
                     "Loading a PyTorch model in Flax, requires both PyTorch and Flax to be installed. Please see"
-                    " https://pytorch.org/ and https://flax.readthedocs.io/en/latest/installation.html for installation"
+                    " https://pytorch.org/ and https://flax.readthedocs.io/en/latest/index.html#installation for installation"
                     " instructions."
                 )
                 raise
@@ -360,7 +360,7 @@ def load_flax_weights_in_pytorch_model(pt_model, flax_state):
     except (ImportError, ModuleNotFoundError):
         logger.error(
             "Loading a Flax weights in PyTorch, requires both PyTorch and Flax to be installed. Please see"
-            " https://pytorch.org/ and https://flax.readthedocs.io/en/latest/installation.html for installation"
+            " https://pytorch.org/ and https://flax.readthedocs.io/en/latest/index.html#installation for installation"
             " instructions."
         )
         raise
Repository: ggml-org/llama.cpp
Pull request: When listening on a unix domain socket don't print http:// and port

Instead show something like this:

main: server is listening on file.sock - starting the main loop


Changed files:
filename: tools/server/server.cpp
patch: @@ -4878,7 +4878,9 @@ int main(int argc, char ** argv) {
     };
 
     bool was_bound = false;
+    bool is_sock = false;
     if (string_ends_with(std::string(params.hostname), ".sock")) {
+        is_sock = true;
         LOG_INF("%s: setting address family to AF_UNIX\n", __func__);
         svr->set_address_family(AF_UNIX);
         // bind_to_port requires a second arg, any value other than 0 should
@@ -4956,7 +4958,9 @@ int main(int argc, char ** argv) {
     SetConsoleCtrlHandler(reinterpret_cast<PHANDLER_ROUTINE>(console_ctrl_handler), true);
 #endif
 
-    LOG_INF("%s: server is listening on http://%s:%d - starting the main loop\n", __func__, params.hostname.c_str(), params.port);
+    LOG_INF("%s: server is listening on %s - starting the main loop\n", __func__,
+            is_sock ? string_format("unix://%s", params.hostname.c_str()).c_str() :
+                      string_format("http://%s:%d", params.hostname.c_str(), params.port).c_str());
 
     // this call blocks the main thread until queue_tasks.terminate() is called
     ctx_server.queue_tasks.start_loop();
Repository: electron/electron
Pull request: fix: clang variable configuration in generated node headers

Backport of #44189

See that PR for details.


Notes: fix native addon compilation errors on macOS

Changed files:
filename: patches/node/.patches
patch: @@ -50,3 +50,4 @@ fix_add_property_query_interceptors.patch
 src_use_supported_api_to_get_stalled_tla_messages.patch
 build_don_t_redefine_win32_lean_and_mean.patch
 build_compile_with_c_20_support.patch
+build_restore_clang_as_default_compiler_on_macos.patch

filename: patches/node/build_restore_clang_as_default_compiler_on_macos.patch
patch: @@ -0,0 +1,24 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: deepak1556 <hop2deep@gmail.com>
+Date: Fri, 11 Oct 2024 15:01:25 +0900
+Subject: build: restore clang as default compiler on macOS
+
+Refs https://github.com/nodejs/node/commit/6e0a2bb54c5bbeff0e9e33e1a0c683ed980a8a0f
+configures the value at build time which doesn't work in Electron
+as it depends on the environment in which the headers got generated from which
+cannot reflect the value per platform. It works for Node.js since
+node-gyp will use the result of `process.config` that reflects the environment
+in which the binary got built.
+
+diff --git a/common.gypi b/common.gypi
+index 2eb62610db2f0ebf68fa9a55ffba98291ecfe451..3ec08ee144b586d05c4e49c2251416734cbc02c5 100644
+--- a/common.gypi
++++ b/common.gypi
+@@ -125,6 +125,7 @@
+         'v8_base': '<(PRODUCT_DIR)/obj.target/tools/v8_gypfiles/libv8_snapshot.a',
+       }],
+       ['OS=="mac"', {
++        'clang%': 1,
+         'obj_dir%': '<(PRODUCT_DIR)/obj.target',
+         'v8_base': '<(PRODUCT_DIR)/libv8_snapshot.a',
+       }],

filename: script/generate-config-gypi.py
patch: @@ -61,6 +61,10 @@ def main(target_file, target_cpu):
   v['node_module_version'] = int(args['node_module_version'])
   # Used by certain versions of node-gyp.
   v['build_v8_with_gn'] = 'false'
+  # Enable clang conditionally based on target platform
+  # in common.gypi
+  if 'clang' in v:
+    del v['clang']
 
   with open(target_file, 'w+', encoding='utf-8') as file_out:
     file_out.write(pprint.pformat(config, indent=2))
Repository: huggingface/transformers
Pull request: Make `train_dataset` attribute in `_get_train_sampler` optional 

# What does this PR do?

This PR fixes a breaking change that was caused by https://github.com/huggingface/transformers/pull/38090. We removed in that PR `train_dataset` arg but TRL lib uses it. We make it optional instead now

Changed files:
filename: src/transformers/trainer.py
patch: @@ -972,7 +972,9 @@ def _get_collator_with_removed_columns(
         )
         return remove_columns_collator
 
-    def _get_train_sampler(self, train_dataset) -> Optional[torch.utils.data.Sampler]:
+    def _get_train_sampler(self, train_dataset: Optional[Dataset] = None) -> Optional[torch.utils.data.Sampler]:
+        if train_dataset is None:
+            train_dataset = self.train_dataset
         if train_dataset is None or not has_length(train_dataset):
             return None