Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. Spark
  3. spark
  4. SparkProxy

spark.SparkProxy

export type SparkProxy<T extends Record<string, unknown>> = {
  /**
   * Map exposed values to SparkExposedValue, functions to callable async functions.
   */
  [K in keyof T]: T[K] extends (...args: infer A) => infer R
    ? (...args: A) => Promise<Awaited<R>>
    : SparkExposedValue<T[K]>;
} & {
  /**
   * Controller for pause/resume/stop.
   */
  ctrl: SparkController;
};
Textends Record<string, unknown>

Reactive proxy for accessing exposed values and calling functions.

Created by spark.use(). Allows type-safe access to worker bindings.

Examples

const s = spark.use(torch);

// Access reactive value
console.log(s.loss.value);

// Set value
s.lr.set(0.001);

// Call function
await s.train();

// Control training
s.ctrl.pause();
s.ctrl.resume();
s.ctrl.stop();
Previous
SparkMessage
Next
SparkResultMessage