SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2510.05069 · ICLR · 2025

SwiReasoning: Switch-Thinking in Latent and Explicit for Pareto-Superior Reasoning LLMs

Dachuan Shi, Xiangchi Yuan, Abedelkadir Asi, Keying Li, Leyan Pan, Wenke Lee, W. Xiao

arXiv · PDF · Open in the Atlas

Code that ran

4 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 2 violated it and 0 have no contract verdict; 1 failure of our instrument; 2 no recorded run), measured 2026-11-22; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2510.05069.json · badge: /api/ran/2510.05069.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
sdc17/SwiReasoning community
Papers with Code archive
4 ran · 2 no recorded run
FunctionStatusWhere it lives
_needs_layerwise_batch_select Ran
ran, violated the contract we drafted
sdc17/SwiReasoning/generation_utils.py
code served (permissive licence) · get_code("d5bcdf294542e440")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a layer class with conv_states
class LayerWithConvStates(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv_states = torch.randn(2, 4)
    
    def forward(self, x):
        return x

# Create a layer class with recurrent_states
class LayerWithRecurrentStates(nn.Module):
    def __init__(self):
        super().__init__()
        self.recurrent_states = torch.randn(2, 4)
    
    def forward(self, x):
        return x

# Create a layer class with batch_select_indices
class LayerWithBatchSelectIndices(nn.Module):
    def __init__(self):
        super().__init__()
        self.batch_select_indices = torch.tensor([0, 1])
    
    def forward(self, x):
        return x

# Create a layer class without special attributes
class SimpleLayer(nn.Module):
    def __init__(self):
        super().__init__()
        self.weight = nn.Parameter(torch.randn(4, 4))
    
    def forward(self, x):
        return x

# Create a past_key_values object with layers attribute
class PastKeyValues:
    def __init__(self, layers):
        self.layers = layers

# Test case 1: past_key_values with layers, one has conv_states
past_key_values_with_conv = PastKeyValues([LayerWithConvStates()])

# Test case 2: past_key_values with layers, one has recurrent_states
past_key_values_with_recurrent = PastKeyValues([LayerWithRecurrentStates()])

# Test case 3: past_key_values with layers, all have batch_select_indices
past_key_values_with_batch_select = PastKeyValues([LayerWithBatchSelectIndices()])

# Test case 4: past_key_values with no layers attribute
past_key_values_no_layers = None

ARGS = {
    "past_key_values": past_key_values_with_conv
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_select_tensor_batch Ran
ran, honoured the contract we drafted
sdc17/SwiReasoning/generation_utils.py
code served (permissive licence) · get_code("a189bd15ee4e1ff7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a sample tensor with batch size 2 and feature dimension 4
value = torch.randn(2, 4)

# Create indices tensor to select from the batch dimension
indices = torch.tensor([0, 1], dtype=torch.long)

ARGS = {
    "value": value,
    "indices": indices,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
apply_sampling_filter Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
sdc17/SwiReasoning/generation_utils.py
code served (permissive licence) · get_code("967ff3ce2cc35de8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Create a small logits tensor
# Shape: (batch_size=2, vocab_size=4)
logits = torch.randn(2, 4)

# Define arguments for apply_sampling_filter
ARGS = {
    "logits": logits,
    "top_k": 2,
    "top_p": 0.9,
    "min_p": 0.1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
batch_select_hybrid_cache Ran
ran, violated the contract we drafted
sdc17/SwiReasoning/generation_utils.py
code served (permissive licence) · get_code("e82cd21aaa74d27a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned PastKeyValues. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a simple layer class with the attributes and methods used in the function
class SimpleCacheLayer(nn.Module):
    def __init__(self):
        super().__init__()
        self.keys = torch.randn(2, 4, 3)  # batch=2, seq_len=4, hidden=3
        self.values = torch.randn(2, 4, 3)
        self.max_batch_size = 2
    
    def batch_select_indices(self, indices):
        pass

# Create a past_key_values object with layers attribute
class PastKeyValues:
    def __init__(self):
        self.layers = [SimpleCacheLayer() for _ in range(2)]

# Test with tuple format as well
past_key_values_tuple = (
    (torch.randn(2, 4, 3), torch.randn(2, 4, 3)),
    (torch.randn(2, 4, 3), torch.randn(2, 4, 3)),
)

# Create indices for batch selection (select elements 0 and 1 from batch dim)
indices = torch.tensor([1, 0])

# Create a past_key_values object with layers
past_key_values_with_layers = PastKeyValues()

ARGS = {
    "past_key_values": past_key_values_with_layers,
    "indices": indices,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PastKeyValues — a PastKeyValues output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PastKeyValues output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_batch_select_cache_layer Not yet run
unverified (harvested, no recorded run)
sdc17/SwiReasoning/generation_utils.py
code served (permissive licence) · get_code("13ab7ac2f6980b29")
How it ran

no invocation recorded.

generate_swir Not yet run
unverified (harvested, no recorded run)
sdc17/SwiReasoning/generation_utils.py
code served (permissive licence) · get_code("dc5158e1746be759")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Recent work shows that, beyond discrete reasoning through explicit chain-ofthought steps, which are limited by the boundaries of natural languages, large language models (LLMs) can also reason continuously in latent space, allowing richer information per step and thereby improving token efficiency. Despite this promise, latent reasoning still faces two challenges, especially in training-free settings: 1) purely latent reasoning broadens the search distribution by maintaining multiple implicit paths, which diffuses probability mass, introduces noise, and impedes convergence to a single high-confidence solution, thereby hurting accuracy; and 2) overthinking persists even without explicit text, wasting tokens and degrading efficiency. To address these issues, we introduce SWIREASONING, a training-free framework for LLM reasoning which features two key innovations: 1) SWIREASONING dynamically switches between explicit and latent reasoning, guided by block-wise confidence estimated from entropy trends in next-token distributions, to balance exploration and exploitation and promote timely convergence. 2) By limiting the maximum number of thinking-block switches, SWIREA-SONING curbs overthinking and improves token efficiency across varying problem difficulties. On widely used mathematics, STEM, coding, and general benchmarks, SWIREASONING consistently improves average accuracy by 1.8%-3.1% across reasoning LLMs of different model families and scales. Furthermore, under constrained budgets, SWIREASONING improves average token efficiency by 57%-79%, with larger gains as budgets tighten.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2510.05069")
get_code_for_paper("2510.05069")
have("2510.05069")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2510.05069.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2510.05069.svg)](https://syntology.ai/paper/2510.05069)

Connect an agent — have() is free.