Enable parallel reasoning threads on standard autoregressive inference engines without modifications to position embeddings or KV cache. ThreadWeaver achieves 1.53× speedup while maintaining chain-of-thought quality—ideal when you need faster reasoning without special hardware.
Scanned 9/9/2026
Install to Claude Code
npx -y skills add ADu2021/skillXiv --skill threadweaver-parallel-reasoning --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Threadweaver Parallel Reasoning?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/adu2021-threadweaver-parallel-reasoning)More formats (shields.io, HTML) on the badges page.
---
name: threadweaver-parallel-reasoning
title: "ThreadWeaver: Adaptive Threading for Efficient Parallel Reasoning in Language Models"
version: 0.0.2
engine: skillxiv-v0.0.2-claude-opus-4.6
license: MIT
url: https://arxiv.org/abs/2512.07843
keywords: [parallel reasoning, speculative decoding, inference optimization, chain-of-thought, adaptive parallelization]
description: "Enable parallel reasoning threads on standard autoregressive inference engines without modifications to position embeddings or KV cache. ThreadWeaver achieves 1.53× speedup while maintaining chain-of-thought quality—ideal when you need faster reasoning without special hardware."
---
## Overview
ThreadWeaver implements adaptive parallel reasoning through a trie-based training-inference co-design that operates on standard autoregressive inference engines. The framework combines parallel trajectory generation, trie-structured reasoning paths, and parallelization-aware RL to balance reasoning accuracy with effective parallelization strategies.
## When to Use
- Reasoning tasks where sequential chain-of-thought is bottleneck
- Scenarios requiring compatibility with standard LLM inference
- Need for 1.5× speedup without architectural changes
- Mathematical reasoning and problem-solving tasks
- Applications where multiple reasoning paths are beneficial
- Inference on existing autoregressive engines
## When NOT to Use
- Tasks with strict sequential dependencies
- Simple one-step reasoning requirements
- Scenarios where parallel execution fails
- Applications already achieving acceptable latency
- Models without reasoning components
## Core Technique
Trie-based parallel reasoning with training-inference co-design:
```python
# Adaptive threading for parallel reasoning
class ThreadWeaverReasoner:
def __init__(self, base_model):
self.model = base_model
self.trie_structure = ReasoningTrie()
def two_stage_trajectory_generation(self, problems, num_trajectories=4):
"""
Stage 1: Generate large-scale, high-quality chain-of-thought data
with parallel annotations for supervised fine-tuning.
"""
parallel_data = []
for problem in problems:
# Generate multiple reasoning trajectories
trajectories = []
for seed in range(num_trajectories):
# Sequential CoT generation
traj = self.model.generate_cot(problem, seed=seed)
trajectories.append(traj)
# Identify where trajectories diverge (parallelizable points)
divergence_points = self.find_divergence_points(trajectories)
# Create parallel annotations
parallel_structure = {
'problem': problem,
'trajectories': trajectories,
'divergence_points': divergence_points,
'parallel_paths': self.extract_parallel_paths(trajectories)
}
parallel_data.append(parallel_structure)
return parallel_data
def find_divergence_points(self, trajectories):
"""
Identify steps where reasoning can safely branch in parallel.
"""
divergence_points = []
# Compare trajectories step by step
max_len = max(len(t) for t in trajectories)
for step_idx in range(max_len):
# Check if step exists in all trajectories
steps_at_idx = [
t[step_idx] if step_idx < len(t) else None
for t in trajectories
]
# Check if trajectory can branch here
if self.can_branch_here(steps_at_idx):
divergence_points.append(step_idx)
return divergence_points
def trie_based_training_inference_codesign(self, parallel_data):
"""
Trie structure enables efficient parallel reasoning without
modifications to position embeddings or KV cache.
Core innovation: standard AR engines can handle trie structure.
"""
# Build trie from parallel data
trie = ReasoningTrie()
for item in parallel_data:
problem = item['problem']
for traj in item['trajectories']:
# Insert trajectory into trie
trie.insert(problem, traj)
# Fine-tune model on trie structure
for batch in self.create_trie_batches(trie):
problem, shared_prefix, parallel_branches = batch
# Forward pass through trie
# Shared prefix computed once
shared_hidden = self.model.encode(problem + shared_prefix)
# Parallel branches branching from shared computation
branch_losses = []
for branch in parallel_branches:
# Branch continues from shared hidden state
# No position embedding modifications needed
branch_loss = self.compute_branch_loss(
shared_hidden,
branch
)
branch_losses.append(branch_loss)
# Aggregate loss
total_loss = torch.stack(branch_losses).mean()
total_loss.backward()
self.optimizer.step()
self.trie_structure = trie
return trie
def parallelization_aware_reinforcement_learning(self):
"""
RL training balances reasoning accuracy with effective parallelization.
Model learns when parallelization is beneficial vs harmful.
"""
# Create RL environment
env = ReasoningEnvironment()
for episode in range(num_episodes):
problem = env.sample_problem()
state = env.reset(problem)
total_reward = 0
trajectory = []
for step in range(max_steps):
# Policy: decide whether to parallelize next step
parallelize_action = self.policy.sample_action(state)
if parallelize_action:
# Generate multiple candidate branches in parallel
candidates = self.generate_parallel_candidates(
state,
num_candidates=4
)
next_step = self.select_best_candidate(candidates)
else:
# Sequential reasoning
next_step = self.model.generate_step(state)
# Environment reward: accuracy of step
accuracy_reward = env.step(next_step)
# Efficiency reward: latency savings from parallelization
efficiency_reward = self.compute_efficiency_reward(
parallelize_action
)
# Combined reward
reward = accuracy_reward + 0.3 * efficiency_reward
state = env.get_next_state(next_step)
trajectory.append((state, parallelize_action, reward))
total_reward += reward
# Policy gradient update
self.update_policy(trajectory, total_reward)
return self.policy
def generate_parallel_candidates(self, state, num_candidates):
"""
Generate multiple reasoning branches in parallel.
Exploits parallel computation capability.
"""
candidates = []
for candidate_idx in range(num_candidates):
# Stochastic generation (different seeds)
# Executed in parallel
candidate = self.model.generate_step(
state,
temperature=0.7,
seed=candidate_idx
)
candidates.append(candidate)
return candidates
def select_best_candidate(self, candidates):
"""
Select among parallel candidates.
Uses confidence or verifier if available.
"""
scores = []
for candidate in candidates:
# Score candidate (e.g., via verifier or confidence)
score = self.score_candidate(candidate)
scores.append(score)
best_idx = torch.argmax(torch.tensor(scores))
return candidates[best_idx]
def inference_with_parallel_threads(self, problem):
"""
Inference on standard AR engine using trie structure.
No modifications to position embeddings or KV cache needed.
"""
# Start with problem encoding
initial_state = self.model.encode(problem)
# Navigate trie structure
current_node = self.trie_structure.root
reasoning_trace = []
num_steps = 0
while not current_node.is_leaf() and num_steps < max_steps:
# Check if node has parallel branches
if len(current_node.children) > 1:
# Parallel opportunity!
# Execute all children branches in parallel
parallel_results = []
for child_node in current_node.children:
# Each branch is a continuation
branch_output = self.execute_branch(
initial_state,
reasoning_trace,
child_node
)
parallel_results.append(branch_output)
# Merge results (select best or aggregate)
merged = self.merge_parallel_results(parallel_results)
current_node = merged['next_node']
reasoning_trace.append(merged['step'])
else:
# Single branch: sequential execution
child = current_node.children[0]
step = self.execute_branch(
initial_state,
reasoning_trace,
child
)
current_node = child
reasoning_trace.append(step['output'])
num_steps += 1
return '\n'.join(reasoning_trace)
def execute_branch(self, initial_state, history, node):
"""
Execute single reasoning branch.
Efficient computation using standard AR mechanisms.
"""
# Concatenate history with branch continuation
full_context = history + [node.step_text]
# Forward pass (standard AR computation)
hidden = self.model.compute_hidden(full_context)
# Generate next step
next_step = self.model.generate_from_hidden(hidden)
return {
'output': next_step,
'next_node': node,
'hidden': hidden
}
```
The framework achieves parallelization-aware training where models learn when parallel execution is beneficial versus when sequential reasoning is superior.
## Key Results
- 1.53× average speedup in token latency
- 79.9% accuracy on AIME24 (vs 71.9% baseline)
- Qwen3-8B achieves strong performance across six benchmarks
- Works on standard autoregressive inference engines
- No modifications to existing infrastructure needed
## Implementation Notes
- Trie structure organizes parallel reasoning paths
- No changes to position embeddings or KV cache
- RL training balances accuracy-efficiency tradeoff
- Shared computation amortized across branches
- Compatible with any AR model
## References
- Original paper: https://arxiv.org/abs/2512.07843
- Focus: Parallel reasoning on standard LLMs
- Domain: Inference optimization, reasoning enhancement
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!