Metadata-Version: 2.4
Name: alienskyqwen
Version: 0.1.3
Summary: AlienSky optimized inference engine for Qwen on Apple Silicon
Author: AlienSky LLC
License: AlienSky Software License
        Version 1.0, April 2026
        
        Copyright (c) 2026 AlienSky LLC.
        All rights reserved.
        
        TERMS AND CONDITIONS
        
        1. DEFINITIONS
        
           "Software" means the AlienSky inference optimization software,
           including all compiled binaries, configuration files, data files,
           model artifacts, and documentation files distributed within the same
           package or repository by AlienSky LLC under this License.
        
           "Use" means to install, load, execute, access the functionality of,
           or benefit from the output of the Software, including use of any
           data, artifacts, or cached results produced by the Software.
        
           "Personal Use" means Use by an individual for private, non-commercial
           purposes, including personal projects, learning, experimentation,
           academic research, and hobby use. Personal Use includes making the
           results of the Software available to no more than ten (10) individuals
           for non-commercial purposes, provided you do not operate the Software
           as a service or make it available to the general public. Personal Use
           does not include any Use that generates revenue, reduces costs,
           creates economic value, or confers competitive advantage, whether
           directly or indirectly; any Use that provides services to third
           parties; or any Use conducted on behalf of or in connection with a
           commercial entity, including sole proprietorships, LLCs, partnerships,
           corporations, and pre-revenue startups. Academic research conducted
           under a grant or contract from, or in collaboration with, a
           commercial entity constitutes Commercial Use.
        
           "Commercial Use" means any Use that is not Personal Use, including but
           not limited to: Use within or on behalf of a business, organization,
           or government entity; Use in connection with any product or service
           that generates revenue, reduces costs, or creates economic value; Use
           to provide services to third parties; integration into commercial
           products or services; and Use for commercial research and development.
           For avoidance of doubt, Use by individuals employed by or affiliated
           with a government entity or government-funded institution is Personal
           Use only when conducted independently and not in furtherance of any
           institutional mission, contract, or funded project.
        
           "Modification" means any alteration, adaptation, translation, or
           creation of derivative works of the Software or any part thereof.
        
        2. PERSONAL USE LICENSE
        
           Subject to the terms of this License, you are granted a non-exclusive,
           non-transferable, royalty-free license to Use the Software for
           Personal Use only. You may not use the Software itself, or any cached
           artifacts, data files, or intermediate outputs produced by the
           Software, in connection with Commercial Use. This restriction does
           not extend to general knowledge or techniques learned through
           Personal Use of the Software.
        
        3. COMMERCIAL USE
        
           Commercial Use of the Software requires a separate written license
           agreement from AlienSky LLC. To obtain a commercial license,
           contact: licensing [at] aliensky.ai
        
        4. NO MODIFICATIONS; REVERSE ENGINEERING
        
           You may not Modify the Software. You may not reverse engineer,
           decompile, or disassemble any compiled components of the Software.
           Nothing in this License is intended to restrict rights expressly
           granted under applicable U.S. law, including lawful security research
           under 17 U.S.C. Section 1201(j).
        
        5. NO REDISTRIBUTION
        
           You may not redistribute, sublicense, sell, lease, or otherwise
           transfer the Software to any third party. You may reference the
           Software as a dependency in package manifests (e.g., requirements.txt,
           pyproject.toml) that cause automated installation directly from
           official AlienSky LLC repositories on PyPI or HuggingFace.
           Bundling the Software into container images, binary distributions,
           or any other aggregate work for distribution to third parties
           constitutes prohibited redistribution.
        
        6. PROPRIETARY NOTICES
        
           You may not remove, alter, or obscure any copyright, trademark, or
           other proprietary notices contained in the Software. "AlienSky" is a
           trademark of AlienSky LLC. This License does not grant any right to use such
           trademarks. By using the Software, you represent that you have the
           legal capacity to enter into this agreement.
        
        7. PATENT NOTICE
        
           The Software embodies inventions covered by one or more pending patent
           applications. This License does not grant any rights under such
           patents except as necessary to exercise the rights expressly granted
           in Section 2.
        
        8. DATA COLLECTION
        
           The Software does not collect, transmit, or store any personal data
           or usage information.
        
        9. NO WARRANTY
        
           THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
           EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
           MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
           NONINFRINGEMENT. IN NO EVENT SHALL ALIENSKY LLC BE LIABLE FOR ANY
           CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF
           CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN
           CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
           SOFTWARE.
        
        10. INDEMNIFICATION
        
            You shall indemnify, defend, and hold harmless AlienSky LLC from
            any claims, damages, losses, or expenses (including reasonable
            attorneys' fees) arising from your breach of this License or your
            Use of the Software in a manner not authorized by this License.
        
        11. EQUITABLE RELIEF
        
            You acknowledge that any breach of Sections 3, 4, or 5 would cause
            irreparable harm to AlienSky LLC for which monetary damages
            would be inadequate, and that AlienSky LLC shall be entitled to
            seek equitable relief, including injunction and specific performance,
            in addition to any other remedies available at law or in equity.
        
        12. TERMINATION
        
            This License terminates automatically if you violate any of its
            terms. Upon termination, you must destroy all copies of the Software
            in your possession. Sections 1, 6, 7, 8, 9, 10, 11, 12, 13, and 14
            shall survive any termination of this License.
        
        13. EXPORT COMPLIANCE
        
            You shall comply with all applicable export control laws and
            regulations, including the U.S. Export Administration Regulations
            (EAR). You may not export or re-export the Software to any country,
            entity, or person prohibited by applicable law.
        
        14. GOVERNING LAW AND JURISDICTION
        
            This License is governed by the laws of the State of Delaware,
            United States of America, without regard to its conflict of laws
            provisions. Any dispute arising under this License shall be subject
            to the exclusive jurisdiction of the state and federal courts located
            in the State of Delaware.
        
        15. UPDATES
        
            AlienSky LLC may modify the terms of this License for future
            releases of the Software. Material changes will be identified in
            the release notes or changelog accompanying the updated version.
            Your installation and Use of updated versions constitutes acceptance
            of the revised terms. Prior versions of the Software remain governed
            by the License in effect at the time of their distribution. You are
            under no obligation to update.
        
        16. THIRD-PARTY COMPONENTS
        
            The Software may include third-party components subject to their own
            license terms. In the event of a conflict between this License and
            any third-party license, the third-party license governs with
            respect to that component only.
        
        TRADEMARK ACKNOWLEDGMENT
        
        "Qwen" and "Qwen3.5" and "Qwen3.6" are trademarks of Alibaba Group
        and/or its affiliates. AlienSky LLC is not affiliated with,
        endorsed by, or sponsored by Alibaba Group. The use of Qwen model names
        in this Software is solely to indicate compatibility with those models.
        
        For commercial licensing inquiries: licensing [at] aliensky.ai
        
Project-URL: Homepage, https://aliensky.ai
Classifier: Development Status :: 4 - Beta
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mlx>=0.20.0
Requires-Dist: mlx-lm<0.31.3,>=0.20.0
Dynamic: license-file

# AlienSkyQwen

**10x longer conversations. Better accuracy. On your Mac. Works with Qwen3.6 and Qwen3.5 models.**

AlienSkyQwen brings enterprise-grade inference optimization to your Mac. Built on the same AlienSky technology licensed to hyperscalers and inference providers, it reduces the memory needed for conversation history by up to **16x** while improving reasoning accuracy by up to **+7.8 percentage points** — no model changes, no quality trade-offs.

AlienSky improves reasoning accuracy on every model tested. Perplexity improves or shows near-zero impact — the optimized model predicts text as well or better than baseline.

<p align="center">
  <a href="https://aliensky.ai">AlienSky.ai</a> &nbsp;|&nbsp;
  <a href="https://x.com/AlienSkyAI">@AlienSkyAI</a>
</p>

![KV Cache Memory — 16x Reduction](https://aliensky.ai/pypi/assets/kv_cache.png)

![Reasoning Accuracy — AlienSky Improves Every Model](https://aliensky.ai/pypi/assets/arc_accuracy.png)

![Perplexity — Minimal Impact, Often Improves](https://aliensky.ai/pypi/assets/perplexity.png)

## Quick Start

### Step 1: Install Python 3.11 or newer

Open Terminal and check your Python version:

```bash
python3 --version
```

If it shows 3.10 or older, install a newer version:

```bash
brew install python@3.14
```

Don't have Homebrew? Install it first: https://brew.sh

### Step 2: Create a virtual environment

```bash
python3 -m venv ~/.aliensky
source ~/.aliensky/bin/activate
```

You'll see `(.aliensky)` appear in your terminal prompt. This means the environment is active.

> **Note:** Every time you open a new terminal window, you need to re-activate:
> ```bash
> source ~/.aliensky/bin/activate
> ```

### Step 3: Install AlienSkyQwen

```bash
pip install alienskyqwen
```

This will also install `mlx` and `mlx-lm` automatically.

### Step 4: Run your first model

```python
python3 -c "
from alienskyqwen import aliensky_load
import mlx_lm

model, tokenizer = aliensky_load('mlx-community/Qwen3.5-27B-4bit')
print(mlx_lm.generate(model, tokenizer, 'Explain quantum computing in simple terms', max_tokens=500))
"
```

The first run will download the model (~14 GB). Subsequent runs use the cached version.

### Or run as an OpenAI-compatible server

```bash
alienskyqwen-serve --model mlx-community/Qwen3.5-27B-4bit --port 8080
```

Then connect any chat interface (Open WebUI, chatbot-ui, or curl) to `http://localhost:8080/v1`.

## Optimization Profiles

| Profile | KV Compression | Best For |
|---------|---------------|----------|
| `aliensky_v1_std` | 9.85x | General use with dense models (default) |
| `aliensky_v1_fast` | 16x | Maximum memory savings, long contexts |
| `aliensky_v1_quality` | 6.56x | Peak accuracy on dense models |
| `aliensky_v1_balance` | 10.67x | MoE models (recommended for 35B-A3B, 122B) |

```python
model, tokenizer = aliensky_load("mlx-community/Qwen3.6-35B-A3B-4bit",
                                  profile="aliensky_v1_balance")
```

## Supported Models

| Model | Model Size (Q4) | Recommended Profile |
|-------|-----------------|---------------------|
| Qwen3.6-35B-A3B | ~18 GB | `aliensky_v1_balance` |
| Qwen3.5-27B | ~14 GB | `aliensky_v1_std` |
| Qwen3.5-27B-Claude-Distilled | ~15 GB | `aliensky_v1_std` |
| Qwen3.5-122B-A10B | ~68 GB | `aliensky_v1_balance` |
| Qwen3.5-9B | ~5 GB | `aliensky_v1_std` |

## Results at a Glance

All benchmarks run on Mac Studio M3 Ultra (512 GB). Full methodology and per-context breakdowns available in [BENCHMARKS](https://aliensky.ai/pypi/alienskyqwen/0.1.1/benchmarks.html).

### Accuracy

| Model | Profile | ARC-Challenge | MMLU (5-shot) | HellaSwag | Perplexity (C4) |
|-------|---------|--------------|---------------|-----------|----------------|
| **Qwen3.6-35B-A3B** (Q4) | `v1_balance` | +0.34pp | **+0.20pp** | -0.50pp | +2.1% |
| **Qwen3.5-27B** (Q4) | `v1_std` | **+7.76pp** | -2.00pp | -1.90pp | **-4.3%** |
| **Qwen3.5-27B-Claude-Distilled** (Q4) | `v1_quality` | **+2.22pp** | — | — | **-3.5%** |
| **Qwen3.5-27B** (8-bit) | `v1_quality` | **+2.82pp** | -1.00pp | -1.30pp | +0.5% |
| **Qwen3.5-122B-A10B** (Q4) | `v1_quality` | **+1.28pp** | -2.20pp | -1.45pp | +1.7% |
| **Qwen3.5-9B** (Q4) | `v1_std` | **+1.54pp** | — | -2.25pp | — |

AlienSky improves ARC-Challenge reasoning accuracy on **every model tested**. Perplexity *improves* on both 27B variants (lower is better) — the optimized model predicts text more accurately than baseline. The 8-bit and MoE models show near-zero PPL impact.

### Memory Savings (KV Cache)

| Context Length | Baseline (27B) | AlienSky (`v1_std`, 9.85x) | AlienSky (`v1_fast`, 16x) |
|---------------|----------------|---------------------------|--------------------------|
| 32K tokens | 2.0 GB | 208 MB | 128 MB |
| 131K tokens | 8.0 GB | 832 MB | 512 MB |
| 262K tokens | 16.0 GB | 1.6 GB | 1.0 GB |

MoE models (35B-A3B, 122B-A10B) achieve **10.67x** savings with the `v1_balance` profile.

### Decode Speed

| Context | Baseline | AlienSky (`v1_std`) | Ratio |
|---------|----------|---------------------|-------|
| 4K tokens | 103.7 tok/s | 88.6 tok/s | 0.85x |
| 8K tokens | 99.3 tok/s | 85.8 tok/s | 0.86x |
| 32K tokens | 87.1 tok/s | 72.0 tok/s | 0.83x |

On Apple Silicon, decode speed is bottlenecked by model weight loading, not the KV cache. AlienSky's overhead is minimal in practice.

## How It Works

When an LLM generates text, it stores the entire conversation in a structure called the KV cache. This cache grows with every token and can consume gigabytes of RAM.

AlienSky optimizes this at multiple levels:

1. **Compresses** conversation memory to a fraction of its original size
2. **Computes attention directly** on the compressed form — no decompression needed, up to **5x faster attention** at long contexts
3. **Runs on Apple Metal** via a custom GPU kernel for maximum speed

The result: 10-16x less memory, faster attention, and in many cases better answers — the optimization acts as noise reduction for the model's internal state.

**What this unlocks:** With 16x less memory per conversation, you can run **multiple conversations in parallel**, keep **several models loaded simultaneously**, or handle **book-length contexts** that would otherwise exhaust your Mac's RAM.

## Requirements

- Apple Silicon Mac (M1 or newer)
- macOS 14.0+
- Python 3.11-3.14
- 16 GB+ unified memory (64 GB+ recommended for 27B models)

## API Reference

### `aliensky_load(model, profile, data_path)`

Load a model with AlienSky optimization.

- `model` — HuggingFace model ID or local path
- `profile` — Optimization profile (default: `"aliensky_v1_std"`)
- `data_path` — Path to AlienSky data file (auto-detected by default)

Returns `(model, tokenizer)` for use with `mlx_lm.generate()` or `mlx_lm.server`.

### `alienskyqwen-serve`

```
alienskyqwen-serve [--model MODEL] [--profile PROFILE] [--port PORT] [--host HOST]
```

OpenAI-compatible API server. Default model: Qwen3.5-27B-4bit. Default port: 8080.

## FAQ

**Does AlienSky modify the model weights?**
No. It only optimizes how the model stores and retrieves conversation memory.

**Why does reasoning accuracy improve?**
The compression acts as regularization, filtering noise in the model's internal representations. This effect is strongest on reasoning benchmarks and distilled models.

**Can I use this with LM Studio?**
Not directly. Run `alienskyqwen-serve` and connect any OpenAI-compatible client (Open WebUI, chatbot-ui, curl, etc.) to `http://localhost:8080/v1`.

**What about Llama, Gemma, or other models?**
AlienSky currently supports Qwen3.5 and Qwen3.6. Additional architectures are planned.

## License

Free for personal use. Commercial use requires a license. No modifications permitted. See [LICENSE](https://aliensky.ai/pypi/alienskyqwen/0.1.1/license.html) for full terms.

Copyright (c) 2026 AlienSky LLC.

"Qwen" is a trademark of Alibaba Group. AlienSky LLC is not affiliated with, endorsed by, or sponsored by Alibaba Group.

---

<p align="center">
  <a href="https://aliensky.ai">AlienSky.ai</a> &nbsp;|&nbsp;
  <a href="https://x.com/AlienSkyAI">@AlienSkyAI</a>
</p>
