HCIP-AI EI Developer study materials
HCIP-AI EI Developer study resources

HCIP-AI EI Developer practice questions

One question at a time. Build your HCIP-AI EI Developer understanding.

First 50 of 200 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.

Continue in the practice tool above to load more questions, 50 at a time.

Question 1AI Development Fundamentals and Huawei AI Platform

In the Huawei Ascend AI software stack, which component provides the operator library and graph engine that sit directly beneath high-level frameworks such as MindSpore and TensorFlow?

  1. MindX SDK
  2. ModelArts
  3. CANN (Compute Architecture for Neural Networks) Correct answer.
  4. MindStudio

Explanation

CANN is the heterogeneous compute architecture layer of the Ascend stack; it supplies the operator library, graph compiler and runtime that higher-level frameworks call into. MindStudio is an IDE, MindX SDK provides industry application components, and ModelArts is a cloud development platform, so only CANN occupies that position.

Question 2AI Development Fundamentals and Huawei AI Platform

A developer wants a single framework that natively supports both Ascend and GPU training with automatic parallel strategy search. Which Huawei framework best matches this requirement?

  1. PyTorch
  2. MindSpore Correct answer.
  3. Caffe
  4. TensorFlow 1.x

Explanation

MindSpore is Huawei's own deep learning framework, designed for Ascend-first execution while also supporting GPU and CPU, and it includes automatic parallelism features. The other frameworks are third-party and do not provide native Ascend-first automatic parallel strategy search as a core design goal.

Question 3AI Development Fundamentals and Huawei AI Platform

In MindSpore's programming paradigm, a model is written as ordinary Python code executed eagerly by default, with an option to compile it into a graph for performance. What is this dual mode called?

  1. Synchronous and Asynchronous modes
  2. PyNative and Graph modes Correct answer.
  3. Training and Inference modes
  4. Static and Dynamic shape modes

Explanation

MindSpore offers PyNative mode, which executes operators immediately for easy debugging, and Graph mode, which compiles the whole network for optimization and deployment. Shape modes, execution phases and sync/async settings are different axes and do not describe this dual execution paradigm.

Question 4AI Development Fundamentals and Huawei AI Platform

Which Huawei service provides a fully managed cloud environment for dataset labeling, notebook-based development, training job scheduling and model deployment?

  1. Atlas hardware series
  2. ModelArts Correct answer.
  3. HiAI Foundation
  4. MindX SDK

Explanation

ModelArts is the end-to-end managed AI development platform on Huawei Cloud, covering data preparation, development, training and deployment. MindX SDK, Atlas hardware and HiAI Foundation are respectively application components, hardware products and an on-device inference foundation, none of which is a managed cloud workflow service.

Question 5AI Development Fundamentals and Huawei AI Platform

A team must train a model on data that cannot leave an on-premises data center for compliance reasons, yet still wants a managed development experience. Which Huawei offering is designed for this scenario?

  1. Public ModelArts with shared resource pools
  2. HiAI Foundation on a handset
  3. MindSpore Lite on a mobile phone
  4. ModelArts dedicated/private deployment option Correct answer.

Explanation

ModelArts supports dedicated deployment so the platform runs inside the customer's own data center, keeping data on-premises while preserving managed tooling. Public shared pools move data to the cloud, and the on-device options are inference runtimes that do not provide a managed training environment.

Question 6AI Development Fundamentals and Huawei AI Platform

What is the primary purpose of the Ascend Computing Language (ACL) API in an Ascend application?

  1. To define neural network layers in Python
  2. To label image datasets for supervised learning
  3. To manage devices, streams, memory and task execution on Ascend hardware Correct answer.
  4. To visualize training loss curves

Explanation

ACL is the low-level C API through which applications allocate device memory, create streams, load models and launch execution on Ascend devices. Layer definition belongs to frameworks, dataset labeling to data tools, and visualization to training dashboards.

Question 7AI Development Fundamentals and Huawei AI Platform

An engineer needs to convert a trained model into the offline format that the Ascend offline model inference flow consumes. Which tool performs this conversion?

  1. npu-smi
  2. ATC (Ascend Tensor Compiler) Correct answer.
  3. TensorBoard
  4. MindSpore Lite converter

Explanation

ATC compiles supported framework models into the offline model format used by Ascend inference, applying operator mapping and optimization. MindSpore Lite conversion targets lightweight edge runtimes, TensorBoard is a visualization tool, and npu-smi monitors device status.

Question 8AI Development Fundamentals and Huawei AI Platform

Which command-line utility is used to query the health, temperature and utilization of an Ascend NPU on a server?

  1. top
  2. npu-smi Correct answer.
  3. nvidia-smi
  4. ifconfig

Explanation

npu-smi is Huawei's device management tool for Ascend NPUs, reporting health, temperature, memory and utilization. nvidia-smi targets NVIDIA GPUs, top shows general process statistics, and ifconfig configures network interfaces.

Question 9AI Development Fundamentals and Huawei AI Platform

In MindSpore, which API is used to define a forward computation that can be automatically differentiated and compiled into a graph?

  1. nn.Cell Correct answer.
  2. nn.Optimizer
  3. Dataset
  4. Callback

Explanation

nn.Cell is the base class for network building blocks in MindSpore; subclasses implement construct() for forward computation, and the framework handles differentiation and graph compilation. Optimizers update parameters, Dataset handles data loading, and Callback hooks into training events.

Question 10AI Development Fundamentals and Huawei AI Platform

A MindSpore training script calls a gradient function on a forward graph. What does the framework return from that call?

  1. The loss value of the current batch
  2. The updated model weights after one optimizer step
  3. A new graph that computes gradients when executed Correct answer.
  4. A serialized model file

Explanation

Automatic differentiation in MindSpore is graph-based: the gradient API transforms the forward graph into a gradient graph that is evaluated later. Weight updates happen only when an optimizer is applied, and loss values or serialized files are separate outputs.

Question 11AI Development Fundamentals and Huawei AI Platform

Which MindSpore mechanism enables training to continue from a previously saved state after a job is interrupted?

  1. Model quantization
  2. Data augmentation
  3. Checkpoint saving and loading Correct answer.
  4. Learning rate warmup

Explanation

Checkpoints persist parameters and optimizer state to storage, and loading them restores training exactly where it stopped. Augmentation, warmup and quantization affect data or optimization behavior but do not preserve resumable training state.

Question 12AI Development Fundamentals and Huawei AI Platform

A developer wants MindSpore to distribute one model across many Ascend devices with minimal code change. Which feature should be used?

  1. Manual device placement with explicit send/recv
  2. Automatic parallel mode Correct answer.
  3. Single-device PyNative execution only
  4. Host-side CPU offloading

Explanation

MindSpore's automatic parallel mode searches for and applies operator-level and pipeline strategies across devices with little code change. Explicit manual placement requires far more engineering, single-device execution uses only one device, and CPU offloading does not create multi-device distribution.

Question 13AI Development Fundamentals and Huawei AI Platform

What distinguishes pipeline parallelism from data parallelism in distributed deep learning training?

  1. Pipeline parallelism eliminates the need for any inter-device communication
  2. Pipeline parallelism replicates the full model on every device and averages gradients
  3. Pipeline parallelism only reduces the batch size on each device
  4. Pipeline parallelism splits model layers across devices and passes activations between stages Correct answer.

Explanation

Pipeline parallelism partitions the model by layers so different devices hold different stages and exchange activations, while data parallelism replicates the model and synchronizes gradients. Reducing batch size is a tuning choice, and pipelining still requires communication between stages.

Question 14AI Development Fundamentals and Huawei AI Platform

In the context of Huawei Ascend development, what is the role of the Data Processing Unit (DPU) concept in MindSpore data pipelines?

  1. It offloads data preprocessing to improve pipeline throughput Correct answer.
  2. It stores model checkpoints on the device
  3. It compiles the model graph for inference
  4. It manages NPU temperature and power

Explanation

MindSpore data pipelines can offload preprocessing operations to improve throughput and reduce host bottlenecks, keeping accelerators fed. Checkpoint storage, graph compilation and device telemetry are handled by other components such as storage, ATC and npu-smi.

Question 15AI Development Fundamentals and Huawei AI Platform

Which statement best describes the relationship between MindX SDK and CANN?

  1. MindX SDK builds application-level components on top of CANN's device capabilities Correct answer.
  2. CANN is built on top of MindX SDK
  3. They are unrelated products targeting different hardware vendors
  4. MindX SDK replaces CANN as the device runtime

Explanation

MindX SDK provides higher-level, industry-oriented components such as vision and video analytics plugins that rely on CANN for device execution and operator support. It does not replace CANN, nor is CANN layered above it, and both belong to the same Huawei Ascend ecosystem.

Question 16AI Development Fundamentals and Huawei AI Platform

A team wants to run an image classification model on a camera device with limited memory and no Ascend NPU. Which Huawei runtime is the appropriate choice?

  1. ATC offline model compiler
  2. ModelArts training service
  3. MindSpore Lite Correct answer.
  4. CANN graph engine on server

Explanation

MindSpore Lite is a lightweight inference runtime designed for edge and device scenarios with constrained memory and heterogeneous hardware including CPU. ATC targets Ascend offline models, ModelArts is a cloud training service, and the server graph engine assumes Ascend hardware.

Question 17AI Development Fundamentals and Huawei AI Platform

What does the term 'operator' refer to in the context of Ascend AI software development?

  1. A network protocol between training nodes
  2. A person who monitors the training cluster
  3. A primitive computation unit such as convolution or matrix multiplication executed on the device Correct answer.
  4. A configuration file describing the dataset

Explanation

Operators are the fundamental computation kernels, for example convolution, activation or matrix multiplication, that the graph engine schedules onto the device. Human roles, dataset configuration and network protocols are unrelated to this technical meaning.

Question 18AI Development Fundamentals and Huawei AI Platform

A developer finds that a model converted by ATC fails because a certain operator is unsupported on the target Ascend hardware. Which approach is most appropriate?

  1. Implement a custom operator or use an equivalent supported operator combination Correct answer.
  2. Switch the device to GPU mode
  3. Increase the batch size and reconvert
  4. Disable graph optimization entirely

Explanation

Unsupported operators must be addressed at the operator level, either by developing a custom operator for the target or by rewriting the computation as supported operators. Batch size, device switching and disabling optimization do not resolve the missing operator capability.

Question 19AI Development Fundamentals and Huawei AI Platform

Which MindSpore component is responsible for assembling batches, shuffling and parallel data loading during training?

  1. mindspore.nn
  2. mindspore.dataset Correct answer.
  3. mindspore.ops
  4. mindspore.train

Explanation

The mindspore.dataset module provides dataset objects and transformations for loading, shuffling, batching and parallel prefetching. The nn module defines network layers, train provides training and evaluation wrappers, and ops supplies primitive operations.

Question 20AI Development Fundamentals and Huawei AI Platform

In ModelArts, what is the function of an AI gallery or model hub feature?

  1. To share and reuse published models, datasets and notebooks Correct answer.
  2. To physically host Ascend NPUs for training
  3. To replace the need for a training dataset
  4. To provide network firewall rules for the cluster

Explanation

ModelArts includes a gallery where developers publish and reuse models, datasets and notebooks, accelerating project start-up. It is not the physical hardware layer, does not remove the need for training data, and does not manage firewall rules.

Question 21AI Development Fundamentals and Huawei AI Platform

A developer must debug a MindSpore network step by step with Python breakpoints. Which execution mode should be selected?

  1. Ascend offline inference mode
  2. Distributed automatic parallel mode
  3. Graph mode
  4. PyNative mode Correct answer.

Explanation

PyNative mode executes operators immediately, so standard Python debugging tools and breakpoints work naturally. Graph mode compiles the network and obscures per-operator Python execution, while offline inference and automatic parallel modes are deployment and scaling configurations.

Question 22AI Development Fundamentals and Huawei AI Platform

Which of the following best explains why Ascend developers use the offline model flow rather than on-device graph compilation at inference time?

  1. It removes the need for any device memory allocation
  2. It moves compilation cost to build time and produces a deployable artifact with predictable startup Correct answer.
  3. It guarantees higher numerical precision than online compilation
  4. It eliminates the need to validate model accuracy

Explanation

Offline conversion compiles and optimizes the model ahead of deployment, so the runtime loads a ready artifact and starts quickly with predictable resource behavior. It does not remove memory allocation, change numerical precision guarantees, or substitute for accuracy validation.

Question 23AI Development Fundamentals and Huawei AI Platform

What is the purpose of MindStudio in the Ascend development workflow?

  1. It serves as the production inference runtime on devices
  2. It stores training datasets in object storage
  3. It provides an IDE with project management, profiling and debugging for Ascend applications Correct answer.
  4. It provides the cloud billing interface for ModelArts

Explanation

MindStudio is the integrated development environment for Ascend, bundling project templates, code editing, profiling and debugging tools. It is not a production runtime, a storage service, or a billing interface.

Question 24AI Development Fundamentals and Huawei AI Platform

A training job on Ascend shows low device utilization while the host CPU is saturated. Which is the most likely cause to investigate first?

  1. The model has too few parameters
  2. The data input pipeline cannot feed the device fast enough Correct answer.
  3. The checkpoint directory is on a fast local disk
  4. The learning rate is too small

Explanation

High host CPU usage with idle accelerators is a classic input-bound symptom: preprocessing and data loading on the host cannot keep pace with device consumption. Model size, fast local storage and learning rate do not explain host saturation paired with low device utilization.

Question 25AI Development Fundamentals and Huawei AI Platform

Which Huawei component allows a trained model to be served as a RESTful inference service in ModelArts?

  1. Model deployment as an online service Correct answer.
  2. Dataset versioning
  3. Notebook instance
  4. Code repository

Explanation

ModelArts can deploy a trained model as an online inference service exposing an endpoint for real-time requests. Dataset versioning, notebooks and code repositories support development activities but do not themselves serve predictions.

Question 26AI Development Fundamentals and Huawei AI Platform

In the CANN software stack, which layer sits directly above the Ascend hardware and provides the low-level driver and runtime services that higher-level frameworks call into?

  1. MindSpore Lite
  2. MindX SDK
  3. ModelArts
  4. The CANN runtime and driver layer Correct answer.

Explanation

CANN is organized as a layered stack in which the runtime and driver layer is the lowest software tier, directly managing the Ascend device and exposing execution services upward. Frameworks and SDKs such as MindSpore, MindSpore Lite and MindX SDK are consumers of that layer rather than part of it. ModelArts is a cloud platform that is even further removed from the silicon.

Question 27AI Development Fundamentals and Huawei AI Platform

A developer is writing an inference program with the ACL API and wants to run a model that was already compiled offline by ATC. Which sequence of ACL operations matches the intended offline inference flow?

  1. Execute the model first, then load the model, then copy outputs back to the host
  2. Load the model, create a dataset from input buffers, execute the model, then read output buffers Correct answer.
  3. Create a stream, compile the graph, execute it, then destroy the stream
  4. Compile the graph on device, then load the model, then execute it

Explanation

In the offline flow the model has already been converted by ATC, so ACL only has to load the .om file, bind input and output datasets to device buffers, run the execution call, and copy results back. Graph compilation is the job of ATC, not of the runtime inference program. The order of loading before execution is fixed, since the model handle must exist before it can be run.

Question 28AI Development Fundamentals and Huawei AI Platform

A MindSpore network must be trained with a custom training loop that lets the engineer inspect intermediate losses and adjust the optimizer each step. Which MindSpore capability supports this requirement?

  1. The value_and_grad function combined with a manual loop over the dataset Correct answer.
  2. Only the Model.train high-level interface
  3. The Profiler module
  4. The export API used for MindIR serialization

Explanation

MindSpore exposes functional differentiation through grad and value_and_grad, which return a gradient function that can be called inside an ordinary Python loop. This gives full control over per-step logging and optimizer updates, unlike the encapsulated Model.train interface. Export and Profiler serve serialization and performance analysis respectively, not custom training control.

Question 29AI Development Fundamentals and Huawei AI Platform

Which statement correctly describes how MindSpore's automatic differentiation treats a Python control-flow construct such as an if statement inside a network under graph mode?

  1. It traces only the branch taken during the first call and reuses it forever
  2. It raises an error because graph mode forbids conditional statements
  3. It converts the control flow into graph control-flow operators so that the branch is resolved at execution time Correct answer.
  4. It silently removes the conditional and always executes the first branch

Explanation

In graph mode MindSpore compiles the whole network into an intermediate representation, and Python control flow is translated into graph control-flow operators whose branches are evaluated when the graph executes. This preserves the semantics of the condition for each input rather than freezing a single path. The source code is not required to be branch-free.

Question 30AI Development Fundamentals and Huawei AI Platform

What is the main purpose of the ATC tool in an Ascend development workflow?

  1. To manage distributed parameter servers
  2. To profile NPU utilization during training
  3. To convert a trained model from a framework format into an offline .om model for Ascend inference Correct answer.
  4. To label training images for supervised learning

Explanation

ATC, the Ascend Tensor Compiler, performs model conversion: it parses a model exported from a framework, applies graph optimizations, and emits an offline model file that the Ascend runtime can load. It is a build-time conversion step, not a runtime profiler or a data tool. Its output is consumed by ACL or MindX inference applications.

Question 31AI Development Fundamentals and Huawei AI Platform

An engineer exports a trained MindSpore model as a MindIR file. Which statement best describes what a MindIR file contains?

  1. Only the trained weight values in a plain binary dump
  2. The model's computational graph structure together with its parameters, in a format that can be loaded for inference or further compilation Correct answer.
  3. A Python source listing of the network class
  4. A dataset manifest describing the training inputs

Explanation

MindIR is MindSpore's intermediate representation: it stores the network graph together with the parameter data, which is why it can be loaded for inference on other backends or fed into further conversion. It is not merely a weight dump, because the graph structure is required to reconstruct the computation. Source code and dataset descriptions are not part of it.

Question 32AI Development Fundamentals and Huawei AI Platform

A team building an Ascend inference pipeline needs image decoding, resizing and batching to run efficiently ahead of the model. Which Huawei component is designed for this pre-processing stage?

  1. The ModelArts dataset versioning service
  2. The MindSpore optimizer module
  3. The CANN driver layer
  4. The MindX SDK plug-in and stream processing framework Correct answer.

Explanation

MindX SDK provides a stream-based plug-in framework in which decoding, resizing and batching are implemented as plug-ins that can be chained and executed efficiently on Ascend hardware. Optimizers, drivers and dataset versioning do not perform media pre-processing. Placing pre-processing in this framework avoids costly host-side copies.

Question 33AI Development Fundamentals and Huawei AI Platform

Which MindSpore feature allows a single training script to run unchanged on one Ascend device or across many devices by setting a configuration?

  1. The automatic parallel and distributed training configuration, which partitions the graph across devices Correct answer.
  2. Running separate scripts per device and merging weights by hand
  3. Manual insertion of device-specific communication calls in every layer
  4. Rewriting the network in a lower-level language for each device count

Explanation

MindSpore separates the network definition from the parallel strategy, so the same script can be launched with different device counts and parallel modes configured at runtime. The framework inserts the required communication and graph partitioning automatically. Manual per-layer communication code or per-device scripts defeats the purpose of that abstraction.

Question 34AI Development Fundamentals and Huawei AI Platform

A developer wants to evaluate a trained MindSpore model on a validation set and obtain metrics such as accuracy without writing a manual loop. Which interface is intended for this?

  1. The value_and_grad function
  2. The Tensor.scatter_update operation
  3. The export function
  4. The Model.eval interface with a configured metrics object Correct answer.

Explanation

The Model object bundles the network, loss, optimizer and metrics, and its eval method runs the network over a dataset and computes the configured metrics. Differentiation utilities, serialization and tensor mutation operations do not orchestrate evaluation. Using Model.eval avoids reimplementing batching and metric aggregation.

Question 35AI Development Fundamentals and Huawei AI Platform

A model converted by ATC reports that an operator in the graph is unsupported for the chosen Ascend target. Which approach is most appropriate for resolving this?

  1. Replace the operator with a supported equivalent or supply a custom operator implementation, then reconvert Correct answer.
  2. Ignore the warning, because unsupported operators are silently dropped at runtime
  3. Switch the output format from .om to .onnx
  4. Increase the batch size in the conversion command

Explanation

ATC validates the graph against the operator library available for the target hardware, so an unsupported operator must be replaced by a supported equivalent or implemented as a custom operator before conversion succeeds. Silently dropping an operator would change the model's semantics and produce wrong results. Batch size and output format do not affect operator support.

Question 36AI Development Fundamentals and Huawei AI Platform

What is the role of the Ascend hardware abstraction that lets MindSpore target both Ascend and other backends from one script?

  1. It requires the user to write separate kernels per backend
  2. It converts Python into C automatically at import time
  3. It provides a device management and kernel dispatch layer so the same graph can be lowered to the selected backend Correct answer.
  4. It restricts training to CPU only

Explanation

MindSpore's device abstraction manages context, memory and kernel selection so that the same front-end graph can be lowered to Ascend or another supported backend. Kernels are registered per backend rather than written by the user for each target. This is what allows a single script to run on different hardware.

Question 37AI Development Fundamentals and Huawei AI Platform

In the context of Ascend model deployment, what does the term 'dynamic shape' refer to?

  1. A graph that contains no operators
  2. A model whose weights change after each inference
  3. Input tensors whose dimensions are fixed at conversion time
  4. Input tensors whose dimensions may vary between inference calls and are therefore handled by shape-generic kernels Correct answer.

Explanation

Dynamic shape means input dimensions are not fixed when the model is compiled, so the runtime must support kernels and memory planning that adapt to the actual shapes at each call. Fixed dimensions at conversion time describe static shape, the opposite case. Weight mutation and empty graphs are unrelated concepts.

Question 38AI Development Fundamentals and Huawei AI Platform

A developer running a MindSpore job on Ascend observes that the device is idle most of the time while the host CPU is fully loaded. Which cause should be investigated first?

  1. Data loading and pre-processing on the host cannot keep pace with device computation Correct answer.
  2. The model has too few parameters to use the device
  3. The loss function is numerically unstable
  4. The NPU clock is locked at maximum frequency

Explanation

When the accelerator waits on input, host-side decoding, augmentation or batching becomes the bottleneck, so device utilization falls while CPU load rises. The fix is usually to move pre-processing to Ascend or increase parallel data loading. Clock frequency, model size and loss stability do not explain a CPU-saturated, device-idle pattern.

Question 39AI Development Fundamentals and Huawei AI Platform

Which MindSpore API is used to save the parameters of a trained network to disk so training can later resume?

  1. mindspore.load_dataset
  2. mindspore.ops.Conv2D
  3. mindspore.set_context
  4. mindspore.save_checkpoint Correct answer.

Explanation

save_checkpoint serializes the parameter dictionary of a network into a checkpoint file, which load_checkpoint can later restore to resume training. Dataset loading, context configuration and operator construction serve entirely different purposes. Checkpointing is the standard mechanism for fault tolerance and continued training.

Question 40AI Development Fundamentals and Huawei AI Platform

An engineer must decide between running inference with the MindSpore Lite runtime and with the full MindSpore framework on a constrained edge device. Which consideration best justifies choosing MindSpore Lite?

  1. It supports automatic differentiation for on-device training of large models
  2. It replaces the need for any model conversion step
  3. It provides a smaller runtime footprint and a dedicated model format suited to resource-limited devices Correct answer.
  4. It only runs on cloud servers with GPUs

Explanation

MindSpore Lite is an inference-oriented runtime with a reduced footprint and its own compact model format, which suits devices with limited memory and compute. Full training features such as automatic differentiation are not its purpose, and a conversion step is still required. It targets edge and device deployment rather than cloud GPU servers.

Question 41Python and AI Development Frameworks

In a MindSpore training script, which API is used to define a model by subclassing and implementing the forward computation in the `construct` method?

  1. ops.Conv2D
  2. nn.Dense
  3. nn.Cell Correct answer.
  4. nn.SequentialCell

Explanation

MindSpore uses the `nn.Cell` base class for user-defined models; subclasses implement the forward pass in `construct`, and the framework then handles gradient and device execution. `nn.SequentialCell` is a container that chains existing cells rather than the base class for custom models.

Question 42Python and AI Development Frameworks

A PyTorch tensor `x` has shape `(32, 3, 224, 224)`. After `x.permute(0, 2, 3, 1)`, what is the resulting shape?

  1. (32, 3, 224, 224)
  2. (224, 224, 3, 32)
  3. (3, 32, 224, 224)
  4. (32, 224, 224, 3) Correct answer.

Explanation

`permute` reorders dimensions according to the given index sequence. Mapping the original dims (0=32, 1=3, 2=224, 3=224) into order (0,2,3,1) yields (32, 224, 224, 3), which is the NHWC layout often needed for deployment runtimes.

Question 43Python and AI Development Frameworks

In PyTorch, which call correctly detaches a tensor from the autograd graph so that no gradients are tracked through it?

  1. x.float()
  2. x.contiguous()
  3. x.detach() Correct answer.
  4. x.clone()

Explanation

`detach()` returns a new tensor sharing storage but detached from the computation graph, so operations on it do not record gradients. This is common when converting tensors to NumPy or logging intermediate values during training.

Question 44Python and AI Development Frameworks

Which NumPy operation broadcasts a bias vector `b` of shape `(C,)` onto an activation `a` of shape `(N, C, H, W)` correctly?

  1. a + b[:, None]
  2. a + b.reshape(C, 1, 1)
  3. a + b.T
  4. a + b Correct answer.

Explanation

NumPy aligns trailing dimensions when broadcasting, so shape `(C,)` is treated as `(1,1,1,C)` and aligns with the last axis of `(N,C,H,W)`, which is wrong for a channel bias. Adding a bias requires reshaping `b` so the channel axis matches index 1.

Question 45Python and AI Development Frameworks

A training loop calls `loss.backward()` repeatedly without zeroing gradients. What is the effect in PyTorch?

  1. Gradients are automatically reset each backward call
  2. The optimizer raises an error on the second step
  3. Gradients accumulate across iterations, producing incorrect updates Correct answer.
  4. The loss becomes detached from the graph

Explanation

PyTorch accumulates gradients into `.grad` by default rather than overwriting them, so `optimizer.zero_grad()` must be called each iteration. Without it, updates use the sum of gradients from all previous steps.

Question 46Python and AI Development Frameworks

In MindSpore, which context setting selects graph mode with static shape compilation for Ascend hardware?

  1. mindspore.set_context(mode=mindspore.GRAPH_MODE, device_target='Ascend') Correct answer.
  2. mindspore.enable_dynamic_shape()
  3. mindspore.set_device('GPU')
  4. mindspore.set_context(mode=mindspore.PYNATIVE_MODE, device_target='CPU')

Explanation

`set_context` configures execution mode and device target; `GRAPH_MODE` with `device_target='Ascend'` requests graph compilation on Ascend. PYNATIVE_MODE instead runs operators eagerly for easier debugging.

Question 47Python and AI Development Frameworks

Which PyTorch construct is appropriate for a dataset too large to fit in memory, where samples are generated on the fly?

  1. torch.utils.data.random_split
  2. torch.utils.data.IterableDataset Correct answer.
  3. torch.utils.data.Subset
  4. torch.utils.data.TensorDataset

Explanation

`IterableDataset` supports streaming or procedurally generated samples without random indexing, ideal for data that cannot be materialized. `TensorDataset` and `Subset` require an in-memory indexable collection.

Question 48Python and AI Development Frameworks

In a PyTorch `nn.Module`, why is `super().__init__()` required at the start of the constructor?

  1. It initializes internal structures so submodules and parameters register correctly Correct answer.
  2. It freezes pretrained weights by default
  3. It enables mixed precision automatically
  4. It compiles the module for the target device

Explanation

The base `nn.Module` initializer sets up the dictionaries that track parameters, buffers, and submodules. Skipping it means later assignments like `self.fc = nn.Linear(...)` are not registered, so the optimizer cannot see those weights.

Question 49Python and AI Development Frameworks

A developer wants reproducible training results in PyTorch on a single GPU. Which combination is most appropriate?

  1. Only call torch.cuda.synchronize()
  2. Disable the optimizer's momentum
  3. Set torch.manual_seed, seed NumPy and random, and configure cuDNN deterministic behavior Correct answer.
  4. Only set the Python random seed

Explanation

Reproducibility requires seeding all randomness sources (PyTorch, NumPy, Python) and requesting deterministic cuDNN algorithms. Synchronization and optimizer settings do not control random initialization or data shuffling.

Question 50Python and AI Development Frameworks

Which statement about `torch.nn.DataParallel` versus `torch.nn.parallel.DistributedDataParallel` is accurate?

  1. DDP uses per-process replicas and all-reduce, while DataParallel uses one process with threads Correct answer.
  2. DataParallel scales better because it avoids communication
  3. DDP only works on CPU devices
  4. DataParallel requires launching one process per GPU

Explanation

DDP runs one process per device and synchronizes gradients via all-reduce, avoiding the GIL and replication bottlenecks of single-process DataParallel. This makes DDP the recommended approach for multi-GPU training.