Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .exp/design-workflow-1-grok-1-inference-and-sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The workflow orchestrates model loading, compilation of sharded compute function
- Defines Grok-1 hyperparameters via `LanguageModelConfig` and `TransformerConfig` (e.g., vocab_size=131072, sequence_len=8192, emb_size=6144, num_layers=64, num_q_heads=48, num_kv_heads=8, num_experts=8, num_selected_experts=2, widening_factor=8, key_size=128, shard_activations=True).
- Instantiates `InferenceRunner` with `ModelRunner`, checkpoint_path=\"./checkpoints/\", tokenizer_path=\"./tokenizer.model\", mesh configs (local=(1,8) for 8 GPUs, between_hosts=(1,1)).
- Calls `initialize()` and `run()` generator, demonstrates sampling via `sample_from_model(gen, prompt, max_len=100, temperature=0.01)` on example prompt.
- **PR #415 Impact**: This PR [#415](https://github.com/xai-org/grok-1/pull/415) titled "Update run.py" appends ~444 lines of unrelated JavaScript/React/Three.js code for a VR experience called "LumoraCity". Features include French speech synthesis for AI messages, real-time microphone audio frequency data visualization as 3D spheres, Gematria value display, energy portal, and VR controls. This invalidates the Python file, causing SyntaxError on import/parse, preventing workflow execution. Core inference code intact; remove added code (starting from "import React..." after main()) to fix. PR description: "luméa" likely references the "Lumora" theme. Implications: Breaks entry point; no design enhancements to Grok-1 sampling.

### runners.py
- **ModelRunner**: Configures model dtype (bfloat16), computes batch sizes from bs_per_device * devices * replicas, creates hybrid JAX mesh, defines/transforms Haiku forward functions for full pass and logits-only, applies partition rules for sharding, loads or inits params via checkpoint restore. Supports quantization and activation sharding.
Expand Down
61 changes: 61 additions & 0 deletions pr-analysis-415.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# PR #415: Workflow Design Impact Analysis

## Affected Workflows
- **Workflow 1: Grok-1 Inference and Sampling**: The PR modifies \`run.py\`, listed as a key relevant file and entry point in \`.exp/workflows.json\` ("entry_point": "run.py or runners.InferenceRunner().run() generator"). Evidence: Changed files include \`run.py\`; commit ad07edd "Update run.py" adds unrelated code affecting executability.

No other workflows impacted, as they lack reference to \`run.py\`.

## Workflow 1 Analysis
### Summary of design changes
The PR [Update run.py](https://github.com/xai-org/grok-1/pull/415) appends ~444 lines of JavaScript code to \`run.py\`, implementing a browser-based VR/3D simulation "LumoraCity" using React, @react-three/fiber, Three.js, WebXR, SpeechSynthesis API (French), and Web Audio API for microphone input. Features: AI helper spheres with dynamic messages and voice output, floating Gematria displays (English alphabet numerology), energy portal torus, golden pathway spheres, and audio-reactive frequency spheres colored by HSL.

**Affected design aspects:**
- **Components**: \`run.py\` (RunPy participant) modified—core Python remains, but file now hybrid Python+JS, causing parse failure.
- **Sequences/Flows**: Initialization fails at file parsing before reaching model config or runner creation. No changes to downstream steps (e.g., sharding, sampling).
- **Interactions**: Introduces non-functional (in Python) elements; no integration with JAX/Haiku or inference logic.

**Implementation:**
- Added after Python main(): Full React component \`LumoraCity\` with useState for frequency data and AI messages, useEffect for audio analysis and speech, 3D scene with Canvas/XR, meshes, lights, controls.
- Computes Gematria on messages; responds to voice volume with message changes (e.g., "Les vibrations sont fortes" if avg freq >100).
- No Python adaptations; pure JS append breaks syntax.

**Benefits/Implications:**
- **Benefits**: None for workflow; added code could be a creative web VR art piece exploring themes of listening, energy, mysticism (Gematria, portals), possibly tying to "luméa" (light/world?). Standalone, requires npm setup.
- **Implications**: Breaks workflow execution (SyntaxError on \`python run.py\`), halts inference/sampling. Increases file size, adds irrelevant deps/security (mic access). Suggest reject PR or extract JS to separate repo/file. To fix: Delete added lines.

The **Initialization Sequence** diagram requires update to depict parse failure. No changes to **Inference and Sampling Sequence**.

```mermaid
flowchart TD
classDef addition fill:#90EE90,stroke:#333,stroke-width:4px
classDef pre fill:#D4EDDA
classDef change fill:#FFFF00,stroke:#333,stroke-width:4px
classDef removal fill:#FF9999,stroke:#333,stroke-width:4px
classDef defaultStyle fill:#E0E0E0,stroke:#333,stroke-width:2px

subgraph prepr ["Pre-PR: Original Initialization Sequence (Functional)"]
U[User] --> RP[run.py Execute main]
RP --> IR[Create InferenceRunner]
IR --> MR[ModelRunner initialize]
MR --> M[model.py Init]
M --> J[JAX Mesh & Sharding]
J --> C[Checkpoint Restore]
C --> I[Compile PJIT funcs]
I --> G[Start run generator]
end

subgraph postpr ["Post-PR: Modified with PR #415 (Broken)"]
U2[User] --> RP2[run.py - Modified w/ JS Addition Yellow]
class RP2 change
RP2 --> P[Python Parser Addition Green]
class P addition
P --> JS[LumoraCity JS Code Addition Green]
class JS addition
JS --> E[SyntaxError Red]
class E removal
E -->|Blocks All| U2
end

U -.->|Contrast| U2
prepr -.->|vs| postpr
```